Commit d8b607f920c351e985374cb0c2aa79d82d6ea796

Authored by MoisesMachado
1 parent 944fc830

ActionItem509: pagination everywhere


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2143 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/public/search_controller.rb
... ... @@ -89,11 +89,11 @@ class SearchController < ApplicationController
89 89 def load_product_categories_menu(asset)
90 90 @results[asset].uniq!
91 91 @categories_menu = ProductCategory.menu_categories(@product_category, environment).map do |cat|
92   - hits = @finder.count(:products, @filtered_query, calculate_find_options(asset, nil, nil, cat, @region, params[:radius]))
  92 + hits = @finder.count(asset, @filtered_query, calculate_find_options(asset, nil, nil, cat, @region, params[:radius]))
93 93 childs = []
94 94 # REFACTOR DUPLICATED CODE inner loop doing the same thing that outter loop
95 95 childs = cat.children.map do |child|
96   - child_hits = @finder.count(:products, @filtered_query, calculate_find_options(asset, nil, nil, child, @region, params[:radius]))
  96 + child_hits = @finder.count(asset, @filtered_query, calculate_find_options(asset, nil, nil, child, @region, params[:radius]))
97 97 [child, child_hits]
98 98 end.select{|child, child_hits| child_hits > 0 }
99 99 [cat, hits, childs]
... ...
app/helpers/search_helper.rb
... ... @@ -39,6 +39,14 @@ module SearchHelper
39 39 content_tag('div', data[:toggle] + (render :partial => data[:partial]), :class => "map-or-list-search-results #{data[:class]}")
40 40 end
41 41  
  42 + def display_item_map_info(item)
  43 + if item.kind_of?(Profile)
  44 + display_profile_info
  45 + elsif item.kind_of?(Product)
  46 + display_product_info
  47 + end
  48 + end
  49 +
42 50 def display_profile_info(profile)
43 51 # FIXME add distance
44 52 data = ''
... ... @@ -67,4 +75,9 @@ module SearchHelper
67 75 )
68 76 end
69 77  
  78 + def pagination_links(collection, options={})
  79 + options = {:prev_label => '« ' + _('Previous'), :next_label => _('Next') + ' »'}.merge(options)
  80 + will_paginate(collection, options)
  81 + end
  82 +
70 83 end
... ...
app/views/search/enterprises.rhtml
... ... @@ -16,4 +16,6 @@
16 16  
17 17 <%= display_results %>
18 18  
  19 +<%= pagination_links @results[:enterprises] %>
  20 +
19 21 <br style="clear:both" />
... ...
app/views/search/people.rhtml
... ... @@ -19,9 +19,10 @@
19 19 </div>
20 20 <% end %>
21 21  
22   -
23 22 <%= render :partial => 'search_form', :locals => { :form_title => @query.blank? ? _('Search') : _("Refine your search"), :simple_search => true } %>
24 23  
25 24 <%= display_results %>
26 25  
  26 +<%= pagination_links @results.values.first %>
  27 +
27 28 <br style="clear:both" />
... ...
app/views/search/products.rhtml
... ... @@ -24,19 +24,12 @@
24 24  
25 25 <%= render :partial => 'product_categories_menu', :object => @categories_menu %>
26 26  
27   -<div id="search-results" class="only-one-result-box">
28   - <div class="search-results-products search-results-box">
29   - <div class="search-results-innerbox search-results-type-product">
30   - <ul><%= render :partial => 'product', :collection => @results[:products] %></ul>
31   - </div>
32   - <hr />
33   - </div>
34   -</div>
  27 +<%= display_results %>
35 28  
36 29 <% if @categories_menu %>
37 30 </div><!-- class="has_cat_list" -->
38 31 <% end %>
39 32  
40   -<%= will_paginate @results[:products], :id => 'products-pagination' %>
  33 +<%= will_paginate @results[:products] %>
41 34  
42 35 <br style="clear:both" />
... ...