Commit 76f0404512f9e275d65f8b86cb5f9eba9a182646
1 parent
b5f245c4
Exists in
master
and in
29 other branches
Use select instead of radio button to choose display options
(ActionItem3037)
Showing
4 changed files
with
18 additions
and
16 deletions
Show diff stats
app/models/block.rb
@@ -185,12 +185,12 @@ class Block < ActiveRecord::Base | @@ -185,12 +185,12 @@ class Block < ActiveRecord::Base | ||
185 | 'never' => __('Don\'t display'), | 185 | 'never' => __('Don\'t display'), |
186 | } | 186 | } |
187 | 187 | ||
188 | - def display_options | 188 | + def display_options_available |
189 | DISPLAY_OPTIONS.keys | 189 | DISPLAY_OPTIONS.keys |
190 | end | 190 | end |
191 | 191 | ||
192 | - def display_option_label(option) | ||
193 | - DISPLAY_OPTIONS[option] | 192 | + def display_options |
193 | + DISPLAY_OPTIONS.slice(*display_options_available) | ||
194 | end | 194 | end |
195 | 195 | ||
196 | def display_user_options | 196 | def display_user_options |
app/models/main_block.rb
app/views/box_organizer/edit.rhtml
@@ -7,13 +7,10 @@ | @@ -7,13 +7,10 @@ | ||
7 | 7 | ||
8 | <%= render :partial => partial_for_class(@block.class) %> | 8 | <%= render :partial => partial_for_class(@block.class) %> |
9 | 9 | ||
10 | - <%= labelled_form_field _('Display this block:'), '' %> | ||
11 | - <div style='margin-left: 10px'> | ||
12 | - <% @block.display_options.each do |option| %> | ||
13 | - <%= radio_button(:block, :display, option) %> | ||
14 | - <%= label_tag("block_display_#{option}", _(@block.display_option_label(option))) %> | ||
15 | - <br/> | ||
16 | - <% end %> | 10 | + <div class="display"> |
11 | + <%= labelled_form_field _('Display this block:'), | ||
12 | + select_tag('block[display]', options_from_collection_for_select(@block.display_options, :first, :last, @block.display)) | ||
13 | + %> | ||
17 | </div> | 14 | </div> |
18 | <div class="display_user"> | 15 | <div class="display_user"> |
19 | <%= labelled_form_field _('Display to users:'), '' %> | 16 | <%= labelled_form_field _('Display to users:'), '' %> |
test/functional/profile_design_controller_test.rb
@@ -173,7 +173,8 @@ class ProfileDesignControllerTest < ActionController::TestCase | @@ -173,7 +173,8 @@ class ProfileDesignControllerTest < ActionController::TestCase | ||
173 | should 'have options to display blocks' do | 173 | should 'have options to display blocks' do |
174 | get :edit, :profile => 'designtestuser', :id => @b1.id | 174 | get :edit, :profile => 'designtestuser', :id => @b1.id |
175 | %w[always home_page_only except_home_page never].each do |option| | 175 | %w[always home_page_only except_home_page never].each do |option| |
176 | - assert_tag :input, :attributes => { :type => 'radio', :value => option} | 176 | + assert_tag :select, :attributes => {:name => 'block[display]'}, |
177 | + :descendant => {:tag => 'option', :attributes => {:value => option}} | ||
177 | end | 178 | end |
178 | end | 179 | end |
179 | 180 | ||
@@ -302,22 +303,26 @@ class ProfileDesignControllerTest < ActionController::TestCase | @@ -302,22 +303,26 @@ class ProfileDesignControllerTest < ActionController::TestCase | ||
302 | 303 | ||
303 | should 'not edit main block with never option' do | 304 | should 'not edit main block with never option' do |
304 | get :edit, :profile => 'designtestuser', :id => @b4.id | 305 | get :edit, :profile => 'designtestuser', :id => @b4.id |
305 | - assert_no_tag :input, :attributes => { :type => 'radio', :value => 'never'} | 306 | + assert_no_tag :select, :attributes => {:name => 'block[display]'}, |
307 | + :descendant => {:tag => 'option', :attributes => {:value => 'never'}} | ||
306 | end | 308 | end |
307 | 309 | ||
308 | should 'not edit main block with home_page_only option' do | 310 | should 'not edit main block with home_page_only option' do |
309 | get :edit, :profile => 'designtestuser', :id => @b4.id | 311 | get :edit, :profile => 'designtestuser', :id => @b4.id |
310 | - assert_no_tag :input, :attributes => { :type => 'radio', :value => 'home_page_only'} | 312 | + assert_no_tag :select, :attributes => {:name => 'block[display]'}, |
313 | + :descendant => {:tag => 'option', :attributes => {:value => 'home_page_only'}} | ||
311 | end | 314 | end |
312 | 315 | ||
313 | should 'edit main block with always option' do | 316 | should 'edit main block with always option' do |
314 | get :edit, :profile => 'designtestuser', :id => @b4.id | 317 | get :edit, :profile => 'designtestuser', :id => @b4.id |
315 | - assert_tag :input, :attributes => { :type => 'radio', :value => 'always'} | 318 | + assert_tag :select, :attributes => {:name => 'block[display]'}, |
319 | + :descendant => {:tag => 'option', :attributes => {:value => 'always'}} | ||
316 | end | 320 | end |
317 | 321 | ||
318 | should 'edit main block with except_home_page option' do | 322 | should 'edit main block with except_home_page option' do |
319 | get :edit, :profile => 'designtestuser', :id => @b4.id | 323 | get :edit, :profile => 'designtestuser', :id => @b4.id |
320 | - assert_tag :input, :attributes => { :type => 'radio', :value => 'except_home_page'} | 324 | + assert_tag :select, :attributes => {:name=> 'block[display]'}, |
325 | + :descendant => {:tag => 'option', :attributes => {:value => 'except_home_page'}} | ||
321 | end | 326 | end |
322 | 327 | ||
323 | 328 |