diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb
index b56bf38..fb37c42 100644
--- a/app/controllers/box_organizer_controller.rb
+++ b/app/controllers/box_organizer_controller.rb
@@ -99,17 +99,6 @@ class BoxOrganizerController < ApplicationController
end
end
- def update_categories
- @object = params[:id] ? boxes_holder.blocks.find(params[:id]) : nil
- if params[:category_id]
- @current_category = Category.find(params[:category_id])
- @categories = @current_category.children
- else
- @categories = environment.top_level_categories
- end
- render :partial => 'shared/select_categories', :locals => {:object_name => 'block', :multiple => true}, :layout => false
- end
-
protected :boxes_editor?
end
diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb
index 3c250e7..4eeb048 100644
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -221,11 +221,10 @@ class CmsController < MyProfileController
def update_categories
@object = params[:id] ? @profile.articles.find(params[:id]) : Article.new
+ @categories = @toplevel_categories = environment.top_level_categories
if params[:category_id]
@current_category = Category.find(params[:category_id])
@categories = @current_category.children
- else
- @categories = environment.top_level_categories
end
render :partial => 'shared/select_categories', :locals => {:object_name => 'article', :multiple => true}, :layout => false
end
diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb
index f2dd003..41b3f76 100644
--- a/app/controllers/my_profile/profile_editor_controller.rb
+++ b/app/controllers/my_profile/profile_editor_controller.rb
@@ -55,11 +55,10 @@ class ProfileEditorController < MyProfileController
def update_categories
@object = profile
+ @categories = @toplevel_categories = environment.top_level_categories
if params[:category_id]
@current_category = Category.find(params[:category_id])
@categories = @current_category.children
- else
- @categories = environment.top_level_categories
end
render :partial => 'shared/select_categories', :locals => {:object_name => 'profile_data', :multiple => true}, :layout => false
end
diff --git a/app/views/shared/_select_categories.rhtml b/app/views/shared/_select_categories.rhtml
index 6dc7ba1..eb4f485 100644
--- a/app/views/shared/_select_categories.rhtml
+++ b/app/views/shared/_select_categories.rhtml
@@ -1,7 +1,5 @@
<% extend CategoriesHelper %>
-<% categories_for_selection = @categories.select{|i| !@object.respond_to?(:accept_category?) || @object.accept_category?(i)} %>
-
<% if !@current_category.nil? %>
<%= hidden_field_tag "#{object_name}[#{object_name}_category_id]", @current_category.id unless multiple %>
<%= hidden_field_tag "#{object_name}[category_ids][]", @current_category.id if multiple %>
@@ -26,24 +24,11 @@
page.insert_html :bottom, 'selected-categories', content_tag('div',
hidden_field_tag("#{object_name}[category_ids][]", categories.first.id) +
selected_category_link(categories.first), :id => "selected-category-#{categories.first.id}")
+ page.replace_html 'select-categories', :partial => 'shared/select_subcategories',
+ :locals => {:object_name => object_name, :categories => @toplevel_categories}
end if multiple %>
- <% unless categories_for_selection.empty? %>
-
- <%= _('Click to select a subcategory') %>
- <% end %>
-<% else %>
- <%= _('Click to select a category') %>
<% end %>
-<% categories_for_selection.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 %>
+ <%= render :partial => 'shared/select_subcategories', :locals => {:object_name => object_name, :categories => @categories} %>
diff --git a/app/views/shared/_select_subcategories.rhtml b/app/views/shared/_select_subcategories.rhtml
new file mode 100644
index 0000000..19533c9
--- /dev/null
+++ b/app/views/shared/_select_subcategories.rhtml
@@ -0,0 +1,16 @@
+<% if !categories.nil? && !categories.empty? && !@object.nil? %>
+
+ <%= _('Click to select a category') %>
+
+ <% categories.select{|i| @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 %>
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 3224d50..e42087c 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -355,7 +355,8 @@ div.pending-tasks {
}
/* * * category ajax selector * * */
#category-ajax-selector .category-helper-label {
- font-size: 8pt; color: rgb(158, 158, 158);
+ font-size: 16px;
+ color: rgb(158, 158, 158);
padding: 5px 0px;
}
#category-ajax-selector {
@@ -364,6 +365,7 @@ div.pending-tasks {
margin: 0px 0px 0px 0px;
position: relative;
font-size: 10px;
+ background-color: #fcfcf9;
}
#category-ajax-selector a {
font-size: 12px;
@@ -372,8 +374,9 @@ div.pending-tasks {
padding-bottom: 5px;
}
#selected-categories .label {
- font-weight: bold;
+ font-size: 16px;
margin-bottom: 10px;
+ margin-top: 5px;
}
.selected-category {
padding: 2px 0;
@@ -399,8 +402,12 @@ div.pending-tasks {
margin: 0px 1px;
text-decoration: none;
white-space: nowrap;
- font-size: 11px;
- line-height: 18px;
+ font-size: 12px;
+ line-height: 20px;
+ border-radius: 3px;
+}
+#category-ajax-selector .selected-category .select-subcategory-link {
+ border: 0;
}
#category-ajax-selector .select-subcategory-link:hover,
.select-subcategory-link:hover {
@@ -410,6 +417,11 @@ div.pending-tasks {
top: 4px;
right: 2px;
}
+#category-ajax-selector hr {
+ border: 0;
+ border-bottom: 1px solid #EEE;
+ margin-top: 15px;
+}
#profile-header, #profile-footer {
clear: both;
max-height: 150px;
diff --git a/test/functional/environment_design_controller_test.rb b/test/functional/environment_design_controller_test.rb
index 06b79fc..1c473fe 100644
--- a/test/functional/environment_design_controller_test.rb
+++ b/test/functional/environment_design_controller_test.rb
@@ -366,16 +366,4 @@ class EnvironmentDesignControllerTest < ActionController::TestCase
assert @controller.instance_variable_get('@side_block_types').include?(CustomBlock8)
end
- should 'update categories' do
- env = Environment.default
- login_as(create_admin_user(env))
- top = env.categories.create!(:display_in_menu => true, :name => 'Top-Level category')
- c1 = env.categories.create!(:display_in_menu => true, :name => "Test category 1", :parent_id => top.id)
- c2 = env.categories.create!(:display_in_menu => true, :name => "Test category 2", :parent_id => top.id)
- get :update_categories, :category_id => top.id
- assert_template 'shared/_select_categories'
- assert_equal top, assigns(:current_category)
- assert_equal [c1, c2], assigns(:categories)
- end
-
end
--
libgit2 0.21.2