Class: Pwb::SearchController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pwb/search_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

default_url_options, #set_locale, #set_theme_path

Instance Method Details

#buyObject

ordering of results happens client-side with paloma search.js



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/pwb/search_controller.rb', line 33

def buy
  @page = Pwb::Page.find_by_slug "buy"
  @page_title = @current_agency.company_name
  # @content_to_show = []
  if @page.present?
    @page_title = @page.page_title + ' - ' + @current_agency.company_name
    # TODO: - allow addition of custom content
    # @page.ordered_visible_page_contents.each do |page_content|
    #   @content_to_show.push page_content.content.raw
    # end
  end

  # @page_title = I18n.t("searchForProperties")
  # in erb template for this action, I have js that will render search_results template
  # for properties - like search_ajax action does
  @operation_type = "for_sale"
  # above used to decide if link to result should be to buy or rent path

  @properties = Prop.visible.for_sale.limit 45
  # ordering happens clientside
  # .order('price_sale_current_cents ASC').limit 35
  @prices_from_collection = @current_website.sale_price_options_from
  @prices_till_collection = @current_website.sale_price_options_till
  # @prices_collection = @current_website.sale_price_options_from

  # %W(#{''} 25,000 50,000 75,000 100,000 150,000 250,000 500,000 1,000,000 2,000,000 5,000,000 )
  # ..

  set_common_search_inputs
  set_select_picker_texts
  apply_search_filter filtering_params(params)
  set_map_markers

  # below allows setting in form of any input values that might have been passed by param
  @search_defaults = params[:search].present? ? params[:search] : {}
  # {"property_type" => ""}
  # below won't sort right away as the list of results is loaded by js
  # and so won't be ready for sorting when below is called - but will wire up for sorting button
  # initial client sort called by       INMOAPP.sortSearchResults();
  js 'Main/Search#sort' # trigger client-side paloma script

  render "/pwb/search/buy"
end

#rentObject

TODO: - avoid duplication b/n rent and buy



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'app/controllers/pwb/search_controller.rb', line 78

def rent
  @page = Pwb::Page.find_by_slug "rent"
  @page_title = @current_agency.company_name
  # @content_to_show = []
  if @page.present?
    @page_title = @page.page_title + ' - ' + @current_agency.company_name
    # TODO: - allow addition of custom content
    # @page.ordered_visible_page_contents.each do |page_content|
    #   @content_to_show.push page_content.content.raw
    # end
  end
  # @page_title = I18n.t("searchForProperties")
  # in erb template for this action, I have js that will render search_results template
  # for properties - like search_ajax action does
  @operation_type = "for_rent"
  # above used to decide if link to result should be to buy or rent path

  @properties = Prop.visible.for_rent.limit 45
  # .order('price_rental_monthly_current_cents ASC').limit 35

  @prices_from_collection = @current_website.rent_price_options_from
  @prices_till_collection = @current_website.rent_price_options_till
  # @prices_collection = %W(#{''}
  #                         150 250 500 1,000 1,500 2,000 2,500 3,000 4,000 5,000 10,000)

  set_common_search_inputs
  set_select_picker_texts
  apply_search_filter filtering_params(params)
  set_map_markers
  @search_defaults = params[:search].present? ? params[:search] : {}

  js 'Main/Search#sort' # trigger client-side paloma script
  render "/pwb/search/rent"
end

#search_ajax_for_rentObject



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/pwb/search_controller.rb', line 20

def search_ajax_for_rent
  @operation_type = "for_rent"
  # above used to decide if link to result should be to buy or rent path
  # http://www.justinweiss.com/articles/search-and-filter-rails-models-without-bloating-your-controller/
  @properties = Prop.visible.for_rent

  apply_search_filter filtering_params(params)
  set_map_markers
  render "/pwb/search/search_ajax.js.erb", layout: false
  #  view rendered will use js to inject results...
end

#search_ajax_for_saleObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/pwb/search_controller.rb', line 7

def search_ajax_for_sale
  @operation_type = "for_sale"
  # above used to decide if link to result should be to buy or rent path
  # http://www.justinweiss.com/articles/search-and-filter-rails-models-without-bloating-your-controller/
  @properties = Prop.visible.for_sale
  # .order('price_sale_current_cents ASC')
  # @properties = Prop.where(nil) # creates an anonymous scope
  apply_search_filter filtering_params(params)
  set_map_markers
  render "/pwb/search/search_ajax.js.erb", layout: false
  #  view rendered will use js to inject results...
end