mirror of
https://github.com/redmine/redmine.git
synced 2025-11-10 07:16:03 +01:00
Removes MyControllerTest#page_layout (#25297).
git-svn-id: http://svn.redmine.org/redmine/trunk@16385 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)) -%>
|
||||
|
||||
@@ -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)) -%>
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user