From 57484551b6a5e1fb6e6d80c26decaca0142e8a3a Mon Sep 17 00:00:00 2001 From: Daniel Cunha Date: Fri, 31 Aug 2012 17:22:58 -0300 Subject: [PATCH] Displaying blocks types that are acceptable for each box position --- app/controllers/box_organizer_controller.rb | 3 ++- app/views/box_organizer/_block_types.rhtml | 12 ++++++++++++ app/views/box_organizer/add_block.rhtml | 47 ++++++++++++++++++++++++++++++----------------- 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 app/views/box_organizer/_block_types.rhtml diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb index c563801..254582f 100644 --- a/app/controllers/box_organizer_controller.rb +++ b/app/controllers/box_organizer_controller.rb @@ -68,7 +68,8 @@ class BoxOrganizerController < ApplicationController raise ArgumentError.new("Type %s is not allowed. Go away." % type) end else - @block_types = available_blocks + @center_block_types = Box.acceptable_center_blocks & available_blocks + @side_block_types = Box.acceptable_side_blocks & available_blocks @boxes = boxes_holder.boxes render :action => 'add_block', :layout => false end diff --git a/app/views/box_organizer/_block_types.rhtml b/app/views/box_organizer/_block_types.rhtml new file mode 100644 index 0000000..b8f9b83 --- /dev/null +++ b/app/views/box_organizer/_block_types.rhtml @@ -0,0 +1,12 @@ +<% block_types.in_groups_of(2) do |block1, block2| %> +
+ <%= radio_button_tag('type', block1.name) %> + <%= label_tag "type_#{block1.name.downcase}", block1.description %> +
+ <% if block2 %> +
+ <%= radio_button_tag('type', block2.name) %> + <%= label_tag "type_#{block2.name.downcase}", block2.description %> +
+ <% end %> +<% end %> diff --git a/app/views/box_organizer/add_block.rhtml b/app/views/box_organizer/add_block.rhtml index 496b811..a1f9a19 100644 --- a/app/views/box_organizer/add_block.rhtml +++ b/app/views/box_organizer/add_block.rhtml @@ -2,25 +2,38 @@

<%= _('In what area do you want to put your new block?') %>

- <%# FIXME hardcoded stuff %> - <%= select_tag('box_id', options_for_select(@boxes.select { |item| item.position != 1 }.map {|item| [ _("Area %d") % item.position, item.id]})) %> - -

<%= _('Select the type of block you want to add to your page.') %>

- - <% @block_types.in_groups_of(2) do |block1, block2| %> -
- <%= radio_button_tag('type', block1.name) %> - <%= label_tag "type_#{block1.name.downcase}", block1.description %> -
- <% if block2 %> -
- <%= radio_button_tag('type', block2.name) %> - <%= label_tag "type_#{block2.name.downcase}", block2.description %> -
- <% end %> + <% @boxes.each do |box| %> + <%= radio_button_tag 'box-position', box.id, box.central?, { :class => 'box-position', 'data-position' => box.position } %> + <%= label_tag _("Area %d") % box.position %> <% end %> + + + +

<%= _('Select the type of block you want to add to your page.') %>

+ +
+ <%= render :partial => 'block_types', :locals => { :block_types => @center_block_types } %> +
+ + +
- + <% button_bar do %> <%= submit_button(:add, _("Add")) %> <%= lightbox_close_button(_('Close')) %> -- libgit2 0.21.2