diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index 7bf7a74..b538f2d 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -104,14 +104,16 @@ module BoxesHelper result = filter_html(result, block) end - box_decorator.block_target(block.box, block) + - content_tag('div', - content_tag('div', + content_tag('div', + box_decorator.block_target(block.box, block) + + content_tag('div', content_tag('div', - result + footer_content + box_decorator.block_edit_buttons(block), - :class => 'block-inner-2'), - :class => 'block-inner-1'), - options) + + content_tag('div', + result + footer_content + box_decorator.block_edit_buttons(block), + :class => 'block-inner-2'), + :class => 'block-inner-1'), + options), + :class => 'block-outer') + box_decorator.block_handle(block) end diff --git a/app/models/article_block.rb b/app/models/article_block.rb index e30a9c8..6a2d2e5 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -49,8 +49,8 @@ class ArticleBlock < Block end def available_articles - return [] if self.box.nil? or self.box.owner.nil? - self.box.owner.kind_of?(Environment) ? self.box.owner.portal_community.articles : self.box.owner.articles + return [] if self.owner.nil? + self.owner.kind_of?(Environment) ? self.owner.portal_community.articles : self.owner.articles end def posts_per_page diff --git a/app/views/box_organizer/_article_block.rhtml b/app/views/box_organizer/_article_block.rhtml index 9b26c5c..90b4e29 100644 --- a/app/views/box_organizer/_article_block.rhtml +++ b/app/views/box_organizer/_article_block.rhtml @@ -1,5 +1,5 @@
-<% if @block.box.owner.kind_of?(Environment) and @block.box.owner.portal_community.nil? %> +<% if @block.owner.kind_of?(Environment) and @block.owner.portal_community.nil? %>

<%= _("You don't have an community defined as the portal community. Define it before use this block properly.") %>

diff --git a/plugins/container_block/lib/ext/block.rb b/plugins/container_block/lib/ext/block.rb index c4bd470..eebfa7e 100644 --- a/plugins/container_block/lib/ext/block.rb +++ b/plugins/container_block/lib/ext/block.rb @@ -2,14 +2,11 @@ require_dependency 'block' class Block - def box_with_container_block_plugin - box = box_without_container_block_plugin - if box && box.owner.kind_of?(ContainerBlock) - box = box.owner.box - end - box + def owner_with_container_block_plugin + owner = owner_without_container_block_plugin + owner.kind_of?(ContainerBlock) ? owner.owner : owner end - alias_method_chain :box, :container_block_plugin + alias_method_chain :owner, :container_block_plugin end diff --git a/plugins/container_block/public/style.css b/plugins/container_block/public/style.css index b02dd34..962563d 100644 --- a/plugins/container_block/public/style.css +++ b/plugins/container_block/public/style.css @@ -1,7 +1,15 @@ -#content .boxes .container-block .container_block_child { +#content .boxes .container-block .container_block_child, .container-block .block-outer { float: left; } +.container-block .block-target { + clear: both; +} + +.container-block .block-target[id^='end-of-box-'] { + display: none; +} + #content .boxes .container-block .block .icon-down, #content .boxes .container-block .block .icon-down-disabled { background-image: url(/designs/icons/default/Tango/16x16/actions/go-next.png); } diff --git a/plugins/container_block/test/unit/block_test.rb b/plugins/container_block/test/unit/block_test.rb index 0850e1d..877b3d1 100644 --- a/plugins/container_block/test/unit/block_test.rb +++ b/plugins/container_block/test/unit/block_test.rb @@ -3,22 +3,29 @@ require File.dirname(__FILE__) + '/../test_helper' class BlockTest < ActiveSupport::TestCase def setup - @environment = Environment.new + @environment = fast_create(Environment) + @box = Box.create!(:owner => @environment) + @container = ContainerBlock.create!(:box => @box) + end - @box = Box.new(:owner => @environment) - @block = Block.new(:box => @box) + should 'return environment box if block owner is not a ContainerBlock' do + block = Block.create!(:box => @box) + assert_equal @box, block.box + end - @container_box = Box.new(:owner => @environment) - @container = ContainerBlock.new(:box => @container_box) + should 'return container box if block owner is a ContainerBlock' do + block = Block.create!(:box => @container.container_box) + assert_equal @container.container_box, block.box end - should 'return block box if block owner is not a ContainerBlock' do - assert_equal @box, @block.box + should 'return block owner if block onwer is not a ContainerBlock' do + block = Block.create!(:box => @box) + assert_equal @environment, block.owner end - should 'return container box if block onwer is a ContainerBlock' do - @box.owner = @container - assert_equal @container_box, @block.box + should 'return environment as owner if block onwer is a ContainerBlock' do + block = Block.create!(:box => @container.container_box) + assert_equal @environment, block.owner end end diff --git a/plugins/container_block/views/blocks/container.rhtml b/plugins/container_block/views/blocks/container.rhtml index 6ec0ee9..6c5069f 100644 --- a/plugins/container_block/views/blocks/container.rhtml +++ b/plugins/container_block/views/blocks/container.rhtml @@ -1,19 +1,24 @@ <% edit_mode = @controller.send(:boxes_editor?) && @controller.send(:uses_design_blocks?) %> <% box_decorator = edit_mode ? self : BoxesHelper::DontMoveBlocks %> -<% box_decorator.select_blocks(block.blocks, { :article => @page, :request_path => request.path, :locale => locale }).each do |child| %> -
- <%= display_block(child, '') %> -
- -<% end %> + +
+ <%= display_box_content(block.container_box, nil) %> +
+
+ + <% if edit_mode %>
- + <%= link_to_remote '', :url => { :controller => @controller.boxes_holder.kind_of?(Environment) ? 'container_block_plugin_admin' : 'container_block_plugin_myprofile', :action => 'saveWidths', :id => block.id }, - :with => "containerChildrenWidth(#{block.id})", + :with => "containerChildrenWidth(#{block.id}, #{block.container_box.id})", :html => {:class => "button icon-save container_block_save", :id => "container_block_save_#{block.id}" }, :loading => "open_loading(DEFAULT_LOADING_MESSAGE);", :loaded => "close_loading();", @@ -21,12 +26,19 @@