Commit 36bf2baf55235b58e395103190fd05baf697c9fc

Authored by Rodrigo Souto
2 parents 84645da3 b07cbc9b

Merge branch 'AI3171-categories_block_bug' into 'master'

Ai3171 categories block bug

This MR fix the problem that makes feature/categories_block.feature cucumber/selenium test fails.

Detailed description: http://noosfero.org/Development/ActionItem3171
Showing 1 changed file with 18 additions and 9 deletions   Show diff stats
app/helpers/application_helper.rb
... ... @@ -1002,17 +1002,26 @@ module ApplicationHelper
1002 1002 def display_category_menu(block, categories, root = true)
1003 1003 categories = categories.sort{|x,y| x.name <=> y.name}
1004 1004 return "" if categories.blank?
1005   - content_tag(:ul,
  1005 + content_tag(:ul) do
1006 1006 categories.map do |category|
1007 1007 category_path = category.kind_of?(ProductCategory) ? {:controller => 'search', :action => 'assets', :asset => 'products', :product_category => category.id} : { :controller => 'search', :action => 'category_index', :category_path => category.explode_path }
1008   - category.display_in_menu? ?
1009   - content_tag(:li,
1010   - ( !category.is_leaf_displayable_in_menu? ? content_tag(:a, collapsed_item_icon, :href => "#", :id => "block_#{block.id}_category_#{category.id}", :class => 'category-link-expand ' + (root ? 'category-root' : 'category-no-root'), :onclick => "expandCategory(#{block.id}, #{category.id}); return false", :style => 'display: none') : leaf_item_icon) +
1011   - link_to(content_tag(:span, category.name, :class => 'category-name'), category_path, :class => ("category-leaf" if category.is_leaf_displayable_in_menu?)) +
1012   - content_tag(:div, display_category_menu(block, category.children, false), :id => "block_#{block.id}_category_content_#{category.id}", :class => 'child-category')
1013   - ) : ''
1014   - end
1015   - ) +
  1008 + if category.display_in_menu?
  1009 + content_tag(:li) do
  1010 + if !category.is_leaf_displayable_in_menu?
  1011 + content_tag(:a, collapsed_item_icon, :href => "#", :id => "block_#{block.id}_category_#{category.id}", :class => "category-link-expand " + (root ? "category-root" : "category-no-root"), :onclick => "expandCategory(#{block.id}, #{category.id}); return false", :style => "display: none")
  1012 + else
  1013 + leaf_item_icon
  1014 + end +
  1015 + link_to(content_tag(:span, category.name, :class => "category-name"), category_path, :class => ("category-leaf" if category.is_leaf_displayable_in_menu?)) +
  1016 + content_tag(:div, :id => "block_#{block.id}_category_content_#{category.id}", :class => 'child-category') do
  1017 + display_category_menu(block, category.children, false)
  1018 + end
  1019 + end
  1020 + else
  1021 + ""
  1022 + end
  1023 + end.join.html_safe
  1024 + end +
1016 1025 content_tag(:p) +
1017 1026 (root ? javascript_tag("
1018 1027 jQuery('.child-category').hide();
... ...