diff --git a/app/views/consumed_products/index.rhtml b/app/views/consumed_products/index.rhtml index eb3afc8..9c7c03f 100644 --- a/app/views/consumed_products/index.rhtml +++ b/app/views/consumed_products/index.rhtml @@ -1,12 +1,12 @@ -
<%= link_to _('Add product'), :action => 'new' %>
<% @consumptions.each do |consumption| %> -<%= link_to_category(consumption.product_category) %>
+<%= link_to_category(consumption.product_category) %> <%= link_to _('remove'), { :action => 'destroy', :id => consumption }, :confirm => _('Are you sure, you want to remove this product from your list') %> -
<%= consumption.aditional_specifications %>+
<%= consumption.aditional_specifications %><% end %> <%= link_to_myprofile(_('Back'), {}, @profile.identifier)%> diff --git a/app/views/manage_products/_subcategories.rhtml b/app/views/manage_products/_subcategories.rhtml index 1a4b1c8..c6f58ac 100644 --- a/app/views/manage_products/_subcategories.rhtml +++ b/app/views/manage_products/_subcategories.rhtml @@ -1,19 +1,29 @@ -
<%= _('Current category:') %>
-<%= hidden_field_tag 'product[product_category_id]', @current_category ? @current_category.id : nil %> -<% - categories = [@current_category] - categories.push(@current_category) while @current_category and @current_category = @current_category.parent -%> -<%= categories.compact.reverse.map{|i| - link_to_remote(i.name, - :update => "subcategories", - :url => { :action => 'update_subcategories', :id => i, :loaded => visual_effect(:highlight, "subcategories") }, - :class => 'select-current-category-link')}.join(' → ') -%> +<% if !@current_category.nil? and !@current_category.top_level? %> + +<%= _('Current category:') %>
+ <%= hidden_field_tag 'product[product_category_id]', @current_category.id %> + <% + categories = [@current_category] + categories.push(@current_category) while @current_category = @current_category.parent + categories.last.name = _('Back') + %> + <% if categories.size > 1 %> + <%= categories.compact.reverse.map{|i| + link_to_remote(i.name, + :update => "subcategories", + :url => { :action => 'update_subcategories', :id => i, :loaded => visual_effect(:highlight, "subcategories") }, + :class => 'select-current-category-link')}.join(' → ') + %> + <% end %> -<% unless @categories.empty? %> +<% end %> + +<% if @current_category %> +<%= _('Select a category:') %>
+<% elsif !@categories.empty? %><%= _('Select a subcategory:') %>
<% end %> + <% for category in @categories do %> <%= link_to_remote category.name, { :update => "subcategories", diff --git a/app/views/manage_products/index.rhtml b/app/views/manage_products/index.rhtml index c398766..37ecccc 100644 --- a/app/views/manage_products/index.rhtml +++ b/app/views/manage_products/index.rhtml @@ -1,6 +1,6 @@ -<%= link_to _('New product'), :action => 'new' %>
+<%= link_to _('New product or service'), :action => 'new' %>
<% @products.each do |product| %><%= link_to product.name, :action => 'show', :id => product %> diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml index b331bd4..dbce520 100644 --- a/app/views/profile_editor/index.rhtml +++ b/app/views/profile_editor/index.rhtml @@ -22,7 +22,7 @@ <%= file_manager_button(_('Consumed Products'), 'icons-app/consumed_product.png', :controller => 'consumed_products') if profile.enterprise? %> - <%= file_manager_button(_('Manage Products'), 'icons-app/products.png', :controller => 'manage_products') if profile.enterprise? %> + <%= file_manager_button(_('Manage Products and Services'), 'icons-app/products.png', :controller => 'manage_products') if profile.enterprise? %> <%= file_manager_button(_('Enterprise Validation'), 'icons-app/validation.png', :controller => 'enterprise_validation') if profile.is_validation_entity? %> diff --git a/test/functional/manage_products_controller_test.rb b/test/functional/manage_products_controller_test.rb index 2e48126..b1e4f8b 100644 --- a/test/functional/manage_products_controller_test.rb +++ b/test/functional/manage_products_controller_test.rb @@ -112,21 +112,30 @@ class ManageProductsControllerTest < Test::Unit::TestCase end end - should 'show current category' do + should 'show categories list' do environment = Environment.default category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) category3 = ProductCategory.create!(:name => 'Category 3', :environment => environment, :parent => category2) - category4 = ProductCategory.create!(:name => 'Category 4', :environment => environment, :parent => category3) get :new, :profile => @enterprise.identifier - assert_tag :tag => 'p', :content => /Current category:/, :sibling => { :tag => 'a', :content => /#{category1.name}/ } + assert_tag :tag => 'p', :content => /Select a category:/, :sibling => { :tag => 'a', :content => /#{category2.name}/ } + end + + should 'show current category' do + environment = Environment.default + category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) + category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) + category3 = ProductCategory.create!(:name => 'Category 3', :environment => environment, :parent => category2) + get 'update_subcategories', :profile => @enterprise.identifier, :id => category2.id + assert_tag :tag => 'p', :content => /Current category:/, :sibling => { :tag => 'a', :content => /#{category3.name}/ } end should 'show subcategories list' do environment = Environment.default category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) - get 'new', :profile => @enterprise.identifier + category3 = ProductCategory.create!(:name => 'Category 3', :environment => environment, :parent => category2) + get 'update_subcategories', :profile => @enterprise.identifier, :id => category2.id assert !assigns(:categories).empty? assert_tag :tag => 'p', :content => /Select a subcategory:/, :sibling => { :tag => 'a', :attributes => { :href => '#' }, :content => /#{category2.name}/ } end -- libgit2 0.21.2