summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-09 19:08:02 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-09 19:08:02 +0000
commiteb0a93d353bd04a82303c8faaefe38493fcd9f9d (patch)
treed293e16afdba98a2bfd176419ca0c05f1e7efae5
parentd171aa83988b08e1aa3a0a23345635af0db83f1e (diff)
downloadredmine-eb0a93d353bd04a82303c8faaefe38493fcd9f9d.tar.gz
redmine-eb0a93d353bd04a82303c8faaefe38493fcd9f9d.zip
Removes MyControllerTest#page_layout (#25297).
git-svn-id: http://svn.redmine.org/redmine/trunk@16385 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/my_controller.rb17
-rw-r--r--app/helpers/my_helper.rb9
-rw-r--r--app/views/my/page.html.erb37
-rw-r--r--app/views/my/page_layout.html.erb29
-rw-r--r--config/routes.rb1
-rw-r--r--public/javascripts/application.js15
-rw-r--r--public/stylesheets/application.css19
-rw-r--r--test/functional/my_controller_test.rb11
-rw-r--r--test/integration/routing/my_test.rb1
9 files changed, 52 insertions, 87 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index be1c3c36d..7d8770776 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -142,12 +142,6 @@ class MyController < ApplicationController
@updated_blocks = block_settings.keys
end
- # User's page layout configuration
- def page_layout
- @user = User.current
- @blocks = @user.pref.my_page_layout
- end
-
# Add a block to user's page
# The block is added on top of the page
# params[:block] : id of the block to add
@@ -155,7 +149,7 @@ class MyController < ApplicationController
@user = User.current
@user.pref.add_block params[:block]
@user.pref.save
- redirect_to my_page_layout_path
+ redirect_to my_page_path
end
# Remove a block to user's page
@@ -164,18 +158,17 @@ class MyController < ApplicationController
@user = User.current
@user.pref.remove_block params[:block]
@user.pref.save
- redirect_to my_page_layout_path
+ redirect_to my_page_path
end
# Change blocks order on user's page
# params[:group] : group to order (top, left or right)
# params[:blocks] : array of block ids of the group
def order_blocks
- group = params[:group]
@user = User.current
- if group.is_a?(String)
- group_items = (params["blocks"] || []).collect(&:underscore)
- group_items.each {|s| s.sub!(/^block_/, '')}
+ group = params[:group].to_s
+ if %w(top left right).include? group
+ group_items = (params[:blocks] || []).collect(&:underscore)
# remove group blocks if they are presents in other groups
group_items.each {|s| @user.pref.remove_block(s)}
@user.pref.my_page_layout[group] = group_items
diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb
index 0a9324515..d8930c077 100644
--- a/app/helpers/my_helper.rb
+++ b/app/helpers/my_helper.rb
@@ -26,10 +26,9 @@ module MyHelper
blocks.each do |block|
content = render_block_content(block, user)
if content.present?
- if options[:edit]
- close = link_to(l(:button_delete), {:action => "remove_block", :block => block}, :method => 'post', :class => "icon-only icon-close")
- content = close + content_tag('div', content, :class => 'handle')
- end
+ handle = content_tag('span', '', :class => 'hanlde sort-handle')
+ close = link_to(l(:button_delete), {:action => "remove_block", :block => block}, :method => 'post', :class => "icon-only icon-close")
+ content = content_tag('div', handle + close, :class => 'contextual') + content
s << content_tag('div', content, :class => "mypage-box", :id => "block-#{block}")
end
@@ -60,7 +59,7 @@ module MyHelper
Redmine::MyPage.block_options.each do |label, block|
options << content_tag('option', label, :value => block, :disabled => disabled.include?(block))
end
- select_tag('block', options, :id => "block-select")
+ select_tag('block', options, :id => "block-select", :onchange => "this.form.submit();")
end
def calendar_items(startdt, enddt)
diff --git a/app/views/my/page.html.erb b/app/views/my/page.html.erb
index d5b8e3e30..2eb29ad0c 100644
--- a/app/views/my/page.html.erb
+++ b/app/views/my/page.html.erb
@@ -1,21 +1,50 @@
<div class="contextual">
- <%= link_to l(:label_personalize_page), {:action => 'page_layout'}, :class => 'icon icon-edit' %>
+ <%= form_tag({:action => "add_block"}, :id => "block-form") do %>
+ <%= label_tag('block-select', l(:button_add)) %>:
+ <%= block_select_tag(@user) %>
+ <% end %>
</div>
<h2><%=l(:label_my_page)%></h2>
-<div id="list-top">
+<div id="my-page">
+<div id="list-top" class="block-receiver">
<%= render_blocks(@blocks['top'], @user) %>
</div>
-<div id="list-left" class="splitcontentleft">
+<div id="list-left" class="splitcontentleft block-receiver">
<%= render_blocks(@blocks['left'], @user) %>
</div>
-<div id="list-right" class="splitcontentright">
+<div id="list-right" class="splitcontentright block-receiver">
<%= render_blocks(@blocks['right'], @user) %>
</div>
+</div>
<%= 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 @@
-<div class="contextual">
-
-<%= 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' %>
-</div>
-
-<h2><%=l(:label_my_page)%></h2>
-
-<div id="list-top" class="block-receiver">
- <%= render_blocks(@blocks['top'], @user, :edit => true) %>
-</div>
-
-<div id="list-left" class="splitcontentleft block-receiver">
- <%= render_blocks(@blocks['left'], @user, :edit => true) %>
-</div>
-
-<div id="list-right" class="splitcontentright block-receiver">
- <%= render_blocks(@blocks['right'], @user, :edit => true) %>
-</div>
-
-<%= 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;
+ border:1px dashed #fff;
+ padding: 15px 0 0 0;
+}
+.dragging .block-receiver {
+ border:1px dashed #777;
margin-bottom: 20px;
- padding: 15px 0 15px 0;
}
-
.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'