Commit 6db82f82c71736b813ee97d8f06406f0415d7c97

Authored by MoisesMachado
1 parent f13ee31e

ActionItem527: products now is shown in the map


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2179 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/public/search_controller.rb
... ... @@ -120,7 +120,11 @@ class SearchController < ApplicationController
120 120 # TODO: dont hardcore like this
121 121 def limit
122 122 searching = @searching.values.select{|v|v}
123   - (searching.size == 1) ? 10 : 6
  123 + if params[:display] == 'map'
  124 + 100
  125 + else
  126 + (searching.size == 1) ? 20 : 6
  127 + end
124 128 end
125 129  
126 130 public
... ...
app/helpers/search_helper.rb
... ... @@ -41,9 +41,9 @@ module SearchHelper
41 41  
42 42 def display_item_map_info(item)
43 43 if item.kind_of?(Profile)
44   - display_profile_info
  44 + display_profile_info(item)
45 45 elsif item.kind_of?(Product)
46   - display_product_info
  46 + display_product_info(item)
47 47 end
48 48 end
49 49  
... ... @@ -77,6 +77,24 @@ module SearchHelper
77 77 )
78 78 end
79 79  
  80 + def display_product_info(product)
  81 + data = ''
  82 + unless product.price.nil?
  83 + data << content_tag('strong', _('Price: ')) + product.price + '<br/>'
  84 + end
  85 + unless product.enterprise.nil?
  86 + data << content_tag('strong', _('Provider: ')) + link_to_profile(product.enterprise.name, product.enterprise.identifier)
  87 + end
  88 + unless product.product_category.nil?
  89 + data << content_tag('strong', _('Category: ')) + link_to(product.product_category.name, :controller => 'search', :action => 'assets', :asset => 'products', :product_category => product.product_category.id)
  90 + end
  91 + content_tag('table',
  92 + content_tag('tr',
  93 + content_tag('td', content_tag('div', image_tag(product.image ? product.image.public_filename(:thumb) : '/images/icons-app/product-default-pic-portrait.png'), :class => 'profile-info-picture')) +
  94 + content_tag('td', content_tag('strong', link_to(product.name, :controller => 'catalog', :profile => product.enterprise.identifier, :action => 'show', :id => product)) + '<br/>' + data)
  95 + ), :class => 'profile-info')
  96 + end
  97 +
80 98 def pagination_links(collection, options={})
81 99 options = {:prev_label => '&laquo; ' + _('Previous'), :next_label => _('Next') + ' &raquo;'}.merge(options)
82 100 will_paginate(collection, options)
... ...
app/views/search/_google_maps.rhtml
... ... @@ -56,7 +56,7 @@ if (GBrowserIsCompatible()) {
56 56 results.each do |item|
57 57 if item.lat && item.lng
58 58 %>
59   - putMarker(<%= item.lat.to_json %>, <%= item.lng.to_json %>, <%= item.name.to_json %>, <%= display_profile_info(item).to_json %>);
  59 + putMarker(<%= item.lat.to_json %>, <%= item.lng.to_json %>, <%= item.name.to_json %>, <%= display_item_map_info(item).to_json %>);
60 60 <%
61 61 else
62 62 missed = true
... ...