Commit 57484551b6a5e1fb6e6d80c26decaca0142e8a3a
Committed by
Daniela Feitosa
1 parent
b87e8539
Exists in
master
and in
22 other branches
Displaying blocks types that are acceptable for each box position
Showing
3 changed files
with
44 additions
and
18 deletions
Show diff stats
app/controllers/box_organizer_controller.rb
| ... | ... | @@ -68,7 +68,8 @@ class BoxOrganizerController < ApplicationController |
| 68 | 68 | raise ArgumentError.new("Type %s is not allowed. Go away." % type) |
| 69 | 69 | end |
| 70 | 70 | else |
| 71 | - @block_types = available_blocks | |
| 71 | + @center_block_types = Box.acceptable_center_blocks & available_blocks | |
| 72 | + @side_block_types = Box.acceptable_side_blocks & available_blocks | |
| 72 | 73 | @boxes = boxes_holder.boxes |
| 73 | 74 | render :action => 'add_block', :layout => false |
| 74 | 75 | end | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +<% block_types.in_groups_of(2) do |block1, block2| %> | |
| 2 | + <div style='float: left; width: 48%; padding-top: 2px;'> | |
| 3 | + <%= radio_button_tag('type', block1.name) %> | |
| 4 | + <%= label_tag "type_#{block1.name.downcase}", block1.description %> | |
| 5 | + </div> | |
| 6 | + <% if block2 %> | |
| 7 | + <div style='float: left; width: 48%; padding-top: 2px;'> | |
| 8 | + <%= radio_button_tag('type', block2.name) %> | |
| 9 | + <%= label_tag "type_#{block2.name.downcase}", block2.description %> | |
| 10 | + </div> | |
| 11 | + <% end %> | |
| 12 | +<% end %> | ... | ... |
app/views/box_organizer/add_block.rhtml
| ... | ... | @@ -2,25 +2,38 @@ |
| 2 | 2 | |
| 3 | 3 | <p><%= _('In what area do you want to put your new block?') %></p> |
| 4 | 4 | |
| 5 | - <%# FIXME hardcoded stuff %> | |
| 6 | - <%= select_tag('box_id', options_for_select(@boxes.select { |item| item.position != 1 }.map {|item| [ _("Area %d") % item.position, item.id]})) %> | |
| 7 | - | |
| 8 | - <p><%= _('Select the type of block you want to add to your page.') %></p> | |
| 9 | - | |
| 10 | - <% @block_types.in_groups_of(2) do |block1, block2| %> | |
| 11 | - <div style='float: left; width: 48%; padding-top: 2px;'> | |
| 12 | - <%= radio_button_tag('type', block1.name) %> | |
| 13 | - <%= label_tag "type_#{block1.name.downcase}", block1.description %> | |
| 14 | - </div> | |
| 15 | - <% if block2 %> | |
| 16 | - <div style='float: left; width: 48%; padding-top: 2px;'> | |
| 17 | - <%= radio_button_tag('type', block2.name) %> | |
| 18 | - <%= label_tag "type_#{block2.name.downcase}", block2.description %> | |
| 19 | - </div> | |
| 20 | - <% end %> | |
| 5 | + <% @boxes.each do |box| %> | |
| 6 | + <%= radio_button_tag 'box-position', box.id, box.central?, { :class => 'box-position', 'data-position' => box.position } %> | |
| 7 | + <%= label_tag _("Area %d") % box.position %> | |
| 21 | 8 | <% end %> |
| 9 | + | |
| 10 | + <script type="text/javascript"> | |
| 11 | + (function ($) { | |
| 12 | + $(document).ready(function () { | |
| 13 | + $(".box-position").live('change', function () { | |
| 14 | + if ($(this).attr('data-position') == '1') { | |
| 15 | + $('#center-block-types').show(); | |
| 16 | + $('#side-block-types').hide(); | |
| 17 | + } else { | |
| 18 | + $('#center-block-types').hide(); | |
| 19 | + $('#side-block-types').show(); | |
| 20 | + }; | |
| 21 | + }); | |
| 22 | + })})(jQuery); | |
| 23 | + </script> | |
| 24 | + | |
| 25 | + <p><%= _('Select the type of block you want to add to your page.') %></p> | |
| 26 | + | |
| 27 | + <div id='center-block-types'> | |
| 28 | + <%= render :partial => 'block_types', :locals => { :block_types => @center_block_types } %> | |
| 29 | + </div> | |
| 30 | + | |
| 31 | + <div id='side-block-types' style='display:none'> | |
| 32 | + <%= render :partial => 'block_types', :locals => { :block_types => @side_block_types } %> | |
| 33 | + </div> | |
| 34 | + | |
| 22 | 35 | <br style='clear: both'/> |
| 23 | - | |
| 36 | + | |
| 24 | 37 | <% button_bar do %> |
| 25 | 38 | <%= submit_button(:add, _("Add")) %> |
| 26 | 39 | <%= lightbox_close_button(_('Close')) %> | ... | ... |