Commit a72fb5dd8808f76dc77d3b288a0dbcc01fb5c51d
1 parent
9a799cfa
Exists in
master
and in
28 other branches
Better styles for default layout and small improvements in the UI
(ActionItem2928)
Showing
7 changed files
with
37 additions
and
49 deletions
Show diff stats
app/controllers/box_organizer_controller.rb
... | ... | @@ -99,17 +99,6 @@ class BoxOrganizerController < ApplicationController |
99 | 99 | end |
100 | 100 | end |
101 | 101 | |
102 | - def update_categories | |
103 | - @object = params[:id] ? boxes_holder.blocks.find(params[:id]) : nil | |
104 | - if params[:category_id] | |
105 | - @current_category = Category.find(params[:category_id]) | |
106 | - @categories = @current_category.children | |
107 | - else | |
108 | - @categories = environment.top_level_categories | |
109 | - end | |
110 | - render :partial => 'shared/select_categories', :locals => {:object_name => 'block', :multiple => true}, :layout => false | |
111 | - end | |
112 | - | |
113 | 102 | protected :boxes_editor? |
114 | 103 | |
115 | 104 | end | ... | ... |
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -221,11 +221,10 @@ class CmsController < MyProfileController |
221 | 221 | |
222 | 222 | def update_categories |
223 | 223 | @object = params[:id] ? @profile.articles.find(params[:id]) : Article.new |
224 | + @categories = @toplevel_categories = environment.top_level_categories | |
224 | 225 | if params[:category_id] |
225 | 226 | @current_category = Category.find(params[:category_id]) |
226 | 227 | @categories = @current_category.children |
227 | - else | |
228 | - @categories = environment.top_level_categories | |
229 | 228 | end |
230 | 229 | render :partial => 'shared/select_categories', :locals => {:object_name => 'article', :multiple => true}, :layout => false |
231 | 230 | end | ... | ... |
app/controllers/my_profile/profile_editor_controller.rb
... | ... | @@ -55,11 +55,10 @@ class ProfileEditorController < MyProfileController |
55 | 55 | |
56 | 56 | def update_categories |
57 | 57 | @object = profile |
58 | + @categories = @toplevel_categories = environment.top_level_categories | |
58 | 59 | if params[:category_id] |
59 | 60 | @current_category = Category.find(params[:category_id]) |
60 | 61 | @categories = @current_category.children |
61 | - else | |
62 | - @categories = environment.top_level_categories | |
63 | 62 | end |
64 | 63 | render :partial => 'shared/select_categories', :locals => {:object_name => 'profile_data', :multiple => true}, :layout => false |
65 | 64 | end | ... | ... |
app/views/shared/_select_categories.rhtml
1 | 1 | <% extend CategoriesHelper %> |
2 | 2 | |
3 | -<% categories_for_selection = @categories.select{|i| !@object.respond_to?(:accept_category?) || @object.accept_category?(i)} %> | |
4 | - | |
5 | 3 | <% if !@current_category.nil? %> |
6 | 4 | <%= hidden_field_tag "#{object_name}[#{object_name}_category_id]", @current_category.id unless multiple %> |
7 | 5 | <%= hidden_field_tag "#{object_name}[category_ids][]", @current_category.id if multiple %> |
... | ... | @@ -26,24 +24,11 @@ |
26 | 24 | page.insert_html :bottom, 'selected-categories', content_tag('div', |
27 | 25 | hidden_field_tag("#{object_name}[category_ids][]", categories.first.id) + |
28 | 26 | selected_category_link(categories.first), :id => "selected-category-#{categories.first.id}") |
27 | + page.replace_html 'select-categories', :partial => 'shared/select_subcategories', | |
28 | + :locals => {:object_name => object_name, :categories => @toplevel_categories} | |
29 | 29 | end if multiple %> |
30 | - <% unless categories_for_selection.empty? %> | |
31 | - <hr> | |
32 | - <div class="category-helper-label"><%= _('Click to select a subcategory') %></div> | |
33 | - <% end %> | |
34 | -<% else %> | |
35 | - <div class="category-helper-label"><%= _('Click to select a category') %></div> | |
36 | 30 | <% end %> |
37 | 31 | |
38 | 32 | <div class="toplevel-categories"> |
39 | -<% categories_for_selection.each do |category| %> | |
40 | - <%= link_to_remote category.name, | |
41 | - { :update => "select-categories", | |
42 | - :url => { :action => "update_categories", :category_id => category.id, :id => @object}, | |
43 | - :loaded => visual_effect(:highlight, "select-categories") | |
44 | - }, | |
45 | - :class => 'select-subcategory-link', | |
46 | - :id => "select-category-#{category.id}-link" | |
47 | - %> | |
48 | -<% end %> | |
33 | + <%= render :partial => 'shared/select_subcategories', :locals => {:object_name => object_name, :categories => @categories} %> | |
49 | 34 | </div> | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +<% if !categories.nil? && !categories.empty? && !@object.nil? %> | |
2 | + <hr> | |
3 | + <div class="category-helper-label"><%= _('Click to select a category') %></div> | |
4 | + | |
5 | + <% categories.select{|i| @object.accept_category?(i)}.each do |category| %> | |
6 | + | |
7 | + <%= link_to_remote category.name, | |
8 | + { :update => "select-categories", | |
9 | + :url => { :action => "update_categories", :category_id => category.id, :id => @object}, | |
10 | + :loaded => visual_effect(:highlight, "select-categories") | |
11 | + }, | |
12 | + :class => 'select-subcategory-link', | |
13 | + :id => "select-category-#{category.id}-link" | |
14 | + %> | |
15 | + <% end %> | |
16 | +<% end %> | ... | ... |
public/stylesheets/application.css
... | ... | @@ -355,7 +355,8 @@ div.pending-tasks { |
355 | 355 | } |
356 | 356 | /* * * category ajax selector * * */ |
357 | 357 | #category-ajax-selector .category-helper-label { |
358 | - font-size: 8pt; color: rgb(158, 158, 158); | |
358 | + font-size: 16px; | |
359 | + color: rgb(158, 158, 158); | |
359 | 360 | padding: 5px 0px; |
360 | 361 | } |
361 | 362 | #category-ajax-selector { |
... | ... | @@ -364,6 +365,7 @@ div.pending-tasks { |
364 | 365 | margin: 0px 0px 0px 0px; |
365 | 366 | position: relative; |
366 | 367 | font-size: 10px; |
368 | + background-color: #fcfcf9; | |
367 | 369 | } |
368 | 370 | #category-ajax-selector a { |
369 | 371 | font-size: 12px; |
... | ... | @@ -372,8 +374,9 @@ div.pending-tasks { |
372 | 374 | padding-bottom: 5px; |
373 | 375 | } |
374 | 376 | #selected-categories .label { |
375 | - font-weight: bold; | |
377 | + font-size: 16px; | |
376 | 378 | margin-bottom: 10px; |
379 | + margin-top: 5px; | |
377 | 380 | } |
378 | 381 | .selected-category { |
379 | 382 | padding: 2px 0; |
... | ... | @@ -399,8 +402,12 @@ div.pending-tasks { |
399 | 402 | margin: 0px 1px; |
400 | 403 | text-decoration: none; |
401 | 404 | white-space: nowrap; |
402 | - font-size: 11px; | |
403 | - line-height: 18px; | |
405 | + font-size: 12px; | |
406 | + line-height: 20px; | |
407 | + border-radius: 3px; | |
408 | +} | |
409 | +#category-ajax-selector .selected-category .select-subcategory-link { | |
410 | + border: 0; | |
404 | 411 | } |
405 | 412 | #category-ajax-selector .select-subcategory-link:hover, |
406 | 413 | .select-subcategory-link:hover { |
... | ... | @@ -410,6 +417,11 @@ div.pending-tasks { |
410 | 417 | top: 4px; |
411 | 418 | right: 2px; |
412 | 419 | } |
420 | +#category-ajax-selector hr { | |
421 | + border: 0; | |
422 | + border-bottom: 1px solid #EEE; | |
423 | + margin-top: 15px; | |
424 | +} | |
413 | 425 | #profile-header, #profile-footer { |
414 | 426 | clear: both; |
415 | 427 | max-height: 150px; | ... | ... |
test/functional/environment_design_controller_test.rb
... | ... | @@ -366,16 +366,4 @@ class EnvironmentDesignControllerTest < ActionController::TestCase |
366 | 366 | assert @controller.instance_variable_get('@side_block_types').include?(CustomBlock8) |
367 | 367 | end |
368 | 368 | |
369 | - should 'update categories' do | |
370 | - env = Environment.default | |
371 | - login_as(create_admin_user(env)) | |
372 | - top = env.categories.create!(:display_in_menu => true, :name => 'Top-Level category') | |
373 | - c1 = env.categories.create!(:display_in_menu => true, :name => "Test category 1", :parent_id => top.id) | |
374 | - c2 = env.categories.create!(:display_in_menu => true, :name => "Test category 2", :parent_id => top.id) | |
375 | - get :update_categories, :category_id => top.id | |
376 | - assert_template 'shared/_select_categories' | |
377 | - assert_equal top, assigns(:current_category) | |
378 | - assert_equal [c1, c2], assigns(:categories) | |
379 | - end | |
380 | - | |
381 | 369 | end | ... | ... |