From dd61d0cf17d2498e596b7c62ec7214fa0bf5cffc Mon Sep 17 00:00:00 2001 From: AurelioAHeckert Date: Fri, 11 Jul 2008 20:12:15 +0000 Subject: [PATCH] ActionItem518: product icons on profile and product category selector --- app/helpers/application_helper.rb | 26 +++++++++++++++++++++++++- app/views/blocks/profile_info.rhtml | 4 +++- app/views/manage_products/_subcategories.rhtml | 33 +++++++++++++++++---------------- db/schema.rb | 4 ++-- public/images/icons-cat/Produtos_Alimentação.png | Bin 0 -> 382 bytes public/images/icons-cat/Produtos_Software.png | Bin 0 -> 408 bytes public/images/icons-cat/Produtos_Software_Livre.png | Bin 0 -> 408 bytes public/images/icons-cat/undefined.png | Bin 0 -> 338 bytes public/stylesheets/blocks/profile-info-block.css | 4 ---- public/stylesheets/common.css | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- test/functional/manage_products_controller_test.rb | 6 +++--- 11 files changed, 104 insertions(+), 31 deletions(-) create mode 100644 public/images/icons-cat/Produtos_Alimentação.png create mode 100644 public/images/icons-cat/Produtos_Software.png create mode 100644 public/images/icons-cat/Produtos_Software_Livre.png create mode 100644 public/images/icons-cat/undefined.png diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bf68a67..f9240a6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -346,6 +346,30 @@ module ApplicationHelper sex end + def profile_cat_icons( profile ) + if profile.class == Enterprise + icons = + profile.product_categories.map{ |c| c.size > 1 ? [c[0],c[1]] : nil }. + compact.uniq.map{ |c| + cat_name = (c[0]+'_'+c[1]).gsub( /\s/, '_' ) + cat_icon = "/images/icons-cat/#{cat_name}.png" + if ! File.exists? RAILS_ROOT.to_s() + '/public/' + cat_icon + cat_icon = '/images/icons-cat/undefined.png' + end + content_tag 'span', + content_tag( 'span', c.join(' → ') ), + :title => c.join(' → '), + :class => 'product-cat-icon cat_icon_' + cat_name, + :style => "background-image:url(#{cat_icon})" + }.join "\n" + content_tag 'div', + content_tag( 'span', _('Principal Product Categories'), :class => 'header' ) +"\n"+ icons, + :class => 'product-category-icons' + else + '' + end + end + # displays a link to the profile homepage with its image (as generated by # #profile_image) and its name below it. def profile_image_link( profile, size=:portrait, tag='li' ) @@ -360,7 +384,7 @@ module ApplicationHelper link_to( content_tag( 'span', profile_image( profile, size ), :class => 'profile-image' ) + content_tag( 'span', name, :class => ( profile.class == Person ? 'fn' : 'org' ) ) + - city + profile_sex_icon( profile ), + city + profile_sex_icon( profile ) + profile_cat_icons( profile ), profile.url, :class => 'profile_link url', :help => _('Click on this icon to go to the %s\'s home page') % profile.name ), diff --git a/app/views/blocks/profile_info.rhtml b/app/views/blocks/profile_info.rhtml index dd6beee..de0bc95 100644 --- a/app/views/blocks/profile_info.rhtml +++ b/app/views/blocks/profile_info.rhtml @@ -7,12 +7,14 @@ <%= profile_image(block.owner, :thumb) +"\n"+ - profile_sex_icon( profile ) + profile_sex_icon( profile ) + + profile_cat_icons( profile ) %> +