+
<%= render_blocks(@blocks['left'], @user) %>
-
+
<%= render_blocks(@blocks['right'], @user) %>
+
<%= context_menu %>
+<%= javascript_tag do %>
+$(document).ready(function(){
+ $('#list-top, #list-left, #list-right').sortable({
+ connectWith: '.block-receiver',
+ tolerance: 'pointer',
+ start: function(event, ui){$(this).parent().addClass('dragging');},
+ stop: function(event, ui){$(this).parent().removeClass('dragging');},
+ update: function(event, ui){
+ // trigger the call on the list that receives the block only
+ if ($(this).find(ui.item).length > 0) {
+ $.ajax({
+ url: "<%= escape_javascript url_for(:action => "order_blocks") %>",
+ type: 'post',
+ data: {
+ 'group': $(this).attr('id').replace(/^list-/, ''),
+ 'blocks': $.map($(this).children(), function(el){return $(el).attr('id').replace(/^block-/, '');})
+ }
+ });
+ }
+ }
+ });
+});
+<% end %>
+
<% html_title(l(:label_my_page)) -%>
diff --git a/app/views/my/page_layout.html.erb b/app/views/my/page_layout.html.erb
deleted file mode 100644
index 09475c09b..000000000
--- a/app/views/my/page_layout.html.erb
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-<%= form_tag({:action => "add_block"}, :id => "block-form") do %>
- <%= label_tag('block-select', l(:label_my_page_block)) %>:
- <%= block_select_tag(@user) %>
- <%= link_to l(:button_add), '#', :onclick => '$("#block-form").submit(); return false;', :class => 'icon icon-add' %>
-<% end %>
-<%= link_to l(:button_back), {:action => 'page'}, :class => 'icon icon-cancel' %>
-
-
-
<%=l(:label_my_page)%>
-
-
- <%= render_blocks(@blocks['top'], @user, :edit => true) %>
-
-
-
- <%= render_blocks(@blocks['left'], @user, :edit => true) %>
-
-
-
- <%= render_blocks(@blocks['right'], @user, :edit => true) %>
-
-
-<%= javascript_tag "initMyPageSortable('top', '#{ escape_javascript url_for(:action => "order_blocks", :group => "top") }');" %>
-<%= javascript_tag "initMyPageSortable('left', '#{ escape_javascript url_for(:action => "order_blocks", :group => "left") }');" %>
-<%= javascript_tag "initMyPageSortable('right', '#{ escape_javascript url_for(:action => "order_blocks", :group => "right") }');" %>
-
-<% html_title(l(:label_my_page)) -%>
diff --git a/config/routes.rb b/config/routes.rb
index c2a400349..ab1e1bcab 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -80,7 +80,6 @@ Rails.application.routes.draw do
post 'my/api_key', :to => 'my#reset_api_key'
post 'my/rss_key', :to => 'my#reset_rss_key', :as => 'my_rss_key'
match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
- match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index c99e35ab5..5fdf5ecb4 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -710,21 +710,6 @@ function beforeShowDatePicker(input, inst) {
}
}( jQuery ));
-function initMyPageSortable(list, url) {
- $('#list-'+list).sortable({
- connectWith: '.block-receiver',
- tolerance: 'pointer',
- update: function(){
- $.ajax({
- url: url,
- type: 'post',
- data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
- });
- }
- });
- $("#list-top, #list-left, #list-right").disableSelection();
-}
-
var warnLeavingUnsavedMessage;
function warnLeavingUnsaved(message) {
warnLeavingUnsavedMessage = message;
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 7754fc565..b60f6a51b 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1115,28 +1115,23 @@ div.wiki img {vertical-align:middle; max-width:100%;}
/***** My page layout *****/
.block-receiver {
- border:1px dashed #c0c0c0;
- margin-bottom: 20px;
- padding: 15px 0 15px 0;
+ border:1px dashed #fff;
+ padding: 15px 0 0 0;
+}
+.dragging .block-receiver {
+ border:1px dashed #777;
+ margin-bottom: 20px;
}
-
.mypage-box {
+ border:1px solid #ddd;
+ padding:8px;
margin:0 0 20px 0;
color:#505050;
line-height:1.5em;
}
-.mypage-box .icon-close {
- float:right;
-}
.handle {cursor: move;}
-body.action-page_layout .block-receiver .contextual {
- display: none;
-}
-body.action-page_layout .block-receiver .hascontextmenu {
- cursor: move;
-}
/***** Gantt chart *****/
.gantt_hdr {
position:absolute;
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb
index 043ab8cdf..e40dd91e3 100644
--- a/test/functional/my_controller_test.rb
+++ b/test/functional/my_controller_test.rb
@@ -233,25 +233,20 @@ class MyControllerTest < Redmine::ControllerTest
assert_equal({:days => "14"}, user.reload.pref.my_page_settings('timelog'))
end
- def test_page_layout
- get :page_layout
- assert_response :success
- end
-
def test_add_block
post :add_block, :block => 'issuesreportedbyme'
- assert_redirected_to '/my/page_layout'
+ assert_redirected_to '/my/page'
assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme')
end
def test_add_invalid_block_should_redirect
post :add_block, :block => 'invalid'
- assert_redirected_to '/my/page_layout'
+ assert_redirected_to '/my/page'
end
def test_remove_block
post :remove_block, :block => 'issuesassignedtome'
- assert_redirected_to '/my/page_layout'
+ assert_redirected_to '/my/page'
assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome')
end
diff --git a/test/integration/routing/my_test.rb b/test/integration/routing/my_test.rb
index c2291b01f..39b3b4fa1 100644
--- a/test/integration/routing/my_test.rb
+++ b/test/integration/routing/my_test.rb
@@ -36,7 +36,6 @@ class RoutingMyTest < Redmine::RoutingTest
should_route 'GET /my/password' => 'my#password'
should_route 'POST /my/password' => 'my#password'
- should_route 'GET /my/page_layout' => 'my#page_layout'
should_route 'POST /my/add_block' => 'my#add_block'
should_route 'POST /my/remove_block' => 'my#remove_block'
should_route 'POST /my/order_blocks' => 'my#order_blocks'