diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb index 0a42d6e..5de2359 100644 --- a/app/controllers/box_organizer_controller.rb +++ b/app/controllers/box_organizer_controller.rb @@ -38,18 +38,22 @@ class BoxOrganizerController < ApplicationController @block.save! @target_box.reload + + unless request.xhr? + redirect_to :action => 'index' + end end def move_block_down @block = boxes_holder.blocks.find(params[:id]) @block.move_lower - redirect_to :back + redirect_to :action => 'index' end def move_block_up @block = boxes_holder.blocks.find(params[:id]) @block.move_higher - redirect_to :back + redirect_to :action => 'index' end def add_block diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index 8a356d2..8a38526 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -131,15 +131,30 @@ module BoxesHelper def block_edit_buttons(block) buttons = [] + nowhere = 'javascript: return false;' - if !block.first? - buttons << icon_button(:up, _('Move block up'), { :action => 'move_block_up', :id => block.id }, { :method => 'post' }) + if block.first? + buttons << icon_button('up-disabled', _("Can't move up anymore."), nowhere) + else + buttons << icon_button('up', _('Move block up'), { :action => 'move_block_up', :id => block.id }, { :method => 'post' }) end - if !block.last? + if block.last? + buttons << icon_button('down-disabled', _("Can't move down anymore."), nowhere) + else buttons << icon_button(:down, _('Move block down'), { :action => 'move_block_down' ,:id => block.id }, { :method => 'post'}) end + # move to opposite side + # FIXME too much hardcoded stuff + if profile.layout_template == 'default' + if block.box.position == 2 # area 2, left side => move to right side + buttons << icon_button('right', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + profile.boxes[2].id.to_s, :id => block.id }, :method => 'post' ) + elsif block.box.position == 3 # area 3, right side => move to left side + buttons << icon_button('left', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + profile.boxes[1].id.to_s, :id => block.id }, :method => 'post' ) + end + end + if block.editable? buttons << lightbox_icon_button(:edit, _('Edit'), { :action => 'edit', :id => block.id }) end @@ -148,6 +163,10 @@ module BoxesHelper buttons << icon_button(:delete, _('Remove block'), { :action => 'remove', :id => block.id }, { :method => 'post'}) end + if block.respond_to?(:help) + buttons << thickbox_inline_popup_icon(:help, _('Help on this block'), "help-on-box-#{block.id}") << content_tag('div', content_tag('h2', _('Help')) + content_tag('div', block.help, :style => 'margin-bottom: 1em;') + thickbox_close_button(_('Close')), :style => 'display: none;', :id => "help-on-box-#{block.id}") + end + content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') end diff --git a/app/helpers/thickbox_helper.rb b/app/helpers/thickbox_helper.rb index 1916c52..c00df57 100644 --- a/app/helpers/thickbox_helper.rb +++ b/app/helpers/thickbox_helper.rb @@ -2,6 +2,9 @@ module ThickboxHelper def thickbox_inline_popup_link(title, id, options = {}) link_to(title, "#TB_inline?height=300&width=500&inlineId=#{id}&modal=true", {:class => 'thickbox'}.merge(options)) end + def thickbox_inline_popup_icon(type, title, id, options = {}) + icon_button(type, title, "#TB_inline?height=300&width=500&inlineId=#{id}&modal=true", {:class => "thickbox"}.merge(options)) + end def thickbox_close_button(title) button_to_function(:close, title, 'tb_remove();') end diff --git a/app/models/article_block.rb b/app/models/article_block.rb index 0246086..7a18ba0 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -4,6 +4,10 @@ class ArticleBlock < Block _('Display one of your contents.') end + def help + _('This block displays one of your articles. You can edit the block to select which one of your articles is going to be displayed in the block.') + end + def content article ? article.to_html : _('Article not selected yet.') end diff --git a/app/models/communities_block.rb b/app/models/communities_block.rb index a1954d6..12efebd 100644 --- a/app/models/communities_block.rb +++ b/app/models/communities_block.rb @@ -9,7 +9,7 @@ class CommunitiesBlock < ProfileListBlock end def help - __('The communities in which the user is a member') + __('This block displays the communities in which the user is a member.') end def footer diff --git a/app/models/enterprises_block.rb b/app/models/enterprises_block.rb index cec27f9..42d0a50 100644 --- a/app/models/enterprises_block.rb +++ b/app/models/enterprises_block.rb @@ -5,7 +5,7 @@ class EnterprisesBlock < ProfileListBlock end def help - __('The enterprises where this user works.') + __('This block displays the enterprises where this user works.') end def self.description diff --git a/app/models/environment_statistics_block.rb b/app/models/environment_statistics_block.rb index d8a56d8..a43dd91 100644 --- a/app/models/environment_statistics_block.rb +++ b/app/models/environment_statistics_block.rb @@ -8,6 +8,10 @@ class EnvironmentStatisticsBlock < Block _('Statistics for %s') % owner.name end + def help + _('This block presents some statistics about your environment.') + end + def content users = owner.people.count(:conditions => { :public_profile => true }) enterprises = owner.enterprises.count(:conditions => { :public_profile => true }) diff --git a/app/models/favorite_enterprises_block.rb b/app/models/favorite_enterprises_block.rb index 4d47ad6..2ad70d5 100644 --- a/app/models/favorite_enterprises_block.rb +++ b/app/models/favorite_enterprises_block.rb @@ -5,7 +5,7 @@ class FavoriteEnterprisesBlock < ProfileListBlock end def help - __('This user\'s favorite enterprises.') + __('This block lists the favorite enterprises of the user.') end def self.description diff --git a/app/models/friends_block.rb b/app/models/friends_block.rb index 202456e..4d6e652 100644 --- a/app/models/friends_block.rb +++ b/app/models/friends_block.rb @@ -8,6 +8,10 @@ class FriendsBlock < ProfileListBlock __('Friends') end + def help + _('This block displays your friends.') + end + def footer owner_id = owner.identifier lambda do diff --git a/app/models/link_list_block.rb b/app/models/link_list_block.rb index 276f191..1364ade 100644 --- a/app/models/link_list_block.rb +++ b/app/models/link_list_block.rb @@ -9,6 +9,10 @@ class LinkListBlock < Block def self.description _('Display a list of links.') end + + def help + _('This block can be used to create a menu of links. You can add, remove and update the links as you wish.') + end def content block_title(title) + diff --git a/app/models/login_block.rb b/app/models/login_block.rb index 2ba0f24..ef81e28 100644 --- a/app/models/login_block.rb +++ b/app/models/login_block.rb @@ -4,6 +4,10 @@ class LoginBlock < Block _('A login box for your users.') end + def help + _('This block presents a login/logout block.') + end + def content lambda do if logged_in? diff --git a/app/models/main_block.rb b/app/models/main_block.rb index 0dfb72e..7d92682 100644 --- a/app/models/main_block.rb +++ b/app/models/main_block.rb @@ -4,6 +4,10 @@ class MainBlock < Block _('Block for main content (i.e. your articles, photos, etc)') end + def help + _('This block presents the main content of your pages.') + end + def content nil end diff --git a/app/models/members_block.rb b/app/models/members_block.rb index 0ea4af3..76cf0b4 100644 --- a/app/models/members_block.rb +++ b/app/models/members_block.rb @@ -8,6 +8,10 @@ class MembersBlock < ProfileListBlock _('Members') end + def help + _('This block presents the members of a collective.') + end + def footer profile = self.owner lambda do diff --git a/app/models/my_network_block.rb b/app/models/my_network_block.rb index 2dd7cf3..9bae64c 100644 --- a/app/models/my_network_block.rb +++ b/app/models/my_network_block.rb @@ -10,6 +10,10 @@ class MyNetworkBlock < Block _('My network') end + def help + _('This block displays some info about your networking.') + end + def content block_title(title) + content_tag( diff --git a/app/models/people_block.rb b/app/models/people_block.rb index f2f6e0f..ae8f2a6 100644 --- a/app/models/people_block.rb +++ b/app/models/people_block.rb @@ -12,6 +12,10 @@ class PeopleBlock < ProfileListBlock _('A block displays random people') end + def help + _('This block presents a list of people.') + end + def profile_finder @profile_finder ||= PeopleBlock::Finder.new(self) end diff --git a/app/models/products_block.rb b/app/models/products_block.rb index 152f84d..be1ebb2 100644 --- a/app/models/products_block.rb +++ b/app/models/products_block.rb @@ -12,6 +12,10 @@ class ProductsBlock < Block _('Products') end + def help + _('This block presents a list of your products.') + end + def content block_title(title) + content_tag( diff --git a/app/models/recent_documents_block.rb b/app/models/recent_documents_block.rb index c22e784..402675f 100644 --- a/app/models/recent_documents_block.rb +++ b/app/models/recent_documents_block.rb @@ -8,6 +8,10 @@ class RecentDocumentsBlock < Block _('Recent content') end + def help + _('This block lists your recent content.') + end + settings_items :limit include ActionController::UrlWriter diff --git a/app/models/sellers_search_block.rb b/app/models/sellers_search_block.rb index d5ca69d..321ab6e 100644 --- a/app/models/sellers_search_block.rb +++ b/app/models/sellers_search_block.rb @@ -12,6 +12,10 @@ class SellersSearchBlock < Block _('Search for sellers') end + def help + _('This block presents a search engine for products.') + end + def content title = self.title lambda do diff --git a/app/models/tags_block.rb b/app/models/tags_block.rb index 47e186c..7dd27dc 100644 --- a/app/models/tags_block.rb +++ b/app/models/tags_block.rb @@ -13,8 +13,8 @@ class TagsBlock < Block end def help - _('The tag is created when you add some one to your article.
- Try to add some tags to some articles and see your tag cloud to grow.') + _("Tags are created when you add some of them one to your contents. + Try to add some tags to some articles and you'l see your tag cloud growing.") end def content diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index acd0169..cc67950 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -78,8 +78,6 @@ class ProfileDesignControllerTest < Test::Unit::TestCase def test_should_move_block_to_the_end_of_another_block get :move_block, :profile => 'designtestuser', :id => "block-#{@b1.id}", :target => "end-of-box-#{@box2.id}" - assert_response :success - @b1.reload @box2.reload @@ -92,8 +90,6 @@ class ProfileDesignControllerTest < Test::Unit::TestCase # block 4 is in box 2 get :move_block, :profile => 'designtestuser', :id => "block-#{@b1.id}", :target => "before-block-#{@b4.id}" - assert_response :success - @b1.reload @b4.reload @@ -105,7 +101,6 @@ class ProfileDesignControllerTest < Test::Unit::TestCase def test_block_can_be_moved_up get :move_block, :profile => 'designtestuser', :id => "block-#{@b4.id}", :target => "before-block-#{@b3.id}" - assert_response :success @b4.reload @b3.reload @@ -125,6 +120,16 @@ class ProfileDesignControllerTest < Test::Unit::TestCase assert_equal [1,2,3], [@b4, @b3, @b5].map {|item| item.position} end + def test_move_block_should_redirect_when_not_called_via_ajax + get :move_block, :profile => 'designtestuser', :id => "block-#{@b3.id}", :target => "before-block-#{@b5.id}" + assert_redirected_to :action => 'index' + end + + def test_move_block_should_render_when_called_via_ajax + xml_http_request :get, :move_block, :profile => 'designtestuser', :id => "block-#{@b3.id}", :target => "before-block-#{@b5.id}" + assert_template 'move_block' + end + def test_should_be_able_to_move_block_directly_down post :move_block_down, :profile => 'designtestuser', :id => @b1.id assert_response :redirect -- libgit2 0.21.2