<% if !@current_category.nil? %>

<%= _('Current category:') %>

<%= hidden_field_tag "#{object_name}[#{object_name}_category_id]", @current_category.id unless multiple %> <% categories = [@current_category] categories.push(@current_category) while @current_category = @current_category.parent %> <%= categories.compact.reverse.map{|i| link_to_remote(i.name, :update => "select-categories", :url => { :action => 'update_categories', :category_id => i.id, :id => @object }, :loaded => visual_effect(:highlight, "select-categories"), :class => 'select-current-category-link')}.join(' → ') %> <%= button_to_function_without_text(:save, _('Save'), nil, :id => 'save-category-button') do |page| page.insert_html :bottom, 'selected-categories', content_tag('li', categories.first.full_name + hidden_field_tag("#{object_name}[category_ids][]", categories.first.id) + button_to_function_without_text(:cancel, _('Remove'), nil, :id => "remove-selected-category-#{categories.first.id}-button") {|page| page["selected-category-#{categories.first.id}"].remove}, :id => "selected-category-#{categories.first.id}") end if multiple %> <%= button_to_remote_without_text(:cancel, _('Cancel'), { :update => "select-categories", :url => { :action => 'update_categories', :id => @object }, :loaded => visual_effect(:highlight, "select-categories") }, :id => 'cancel-category-button') %> <% else %>

<%= _('Select a category:') %>

<% end %> <% if !@categories.empty? %>

<%= _('Categories:') %>

<% @categories.select{|i| !@object.respond_to?(:accept_category?) || @object.accept_category?(i)}.each do |category| %> <%= link_to_remote category.name, { :update => "select-categories", :url => { :action => "update_categories", :category_id => category.id, :id => @object}, :loaded => visual_effect(:highlight, "select-categories") }, :class => 'select-subcategory-link', :id => "select-category-#{category.id}-link" %> <% end %>   <% end %>