Allow underscore in block partial name (#2840).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2528 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-02-26 16:15:07 +00:00
parent 4c28291a19
commit 5b96d1b083
2 changed files with 14 additions and 12 deletions

View File

@ -108,14 +108,14 @@ class MyController < ApplicationController
session[:page_layout] = @blocks
%w(top left right).each {|f| session[:page_layout][f] ||= [] }
@block_options = []
BLOCKS.each {|k, v| @block_options << [l(v), k]}
BLOCKS.each {|k, v| @block_options << [l(v), k.dasherize]}
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
def add_block
block = params[:block]
block = params[:block].to_s.underscore
render(:nothing => true) and return unless block && (BLOCKS.keys.include? block)
@user = User.current
# remove if already present in a group
@ -128,7 +128,7 @@ class MyController < ApplicationController
# Remove a block to user's page
# params[:block] : id of the block to remove
def remove_block
block = params[:block]
block = params[:block].to_s.underscore
# remove block in all groups
%w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
render :nothing => true
@ -139,13 +139,15 @@ class MyController < ApplicationController
# params[:list-(top|left|right)] : array of block ids of the group
def order_blocks
group = params[:group]
group_items = params["list-#{group}"]
if group_items and group_items.is_a? Array
# remove group blocks if they are presents in other groups
%w(top left right).each {|f|
session[:page_layout][f] = (session[:page_layout][f] || []) - group_items
}
session[:page_layout][group] = group_items
if group.is_a?(Array)
group_items = params["list-#{group}"].collect(&:underscore)
if group_items and group_items.is_a? Array
# remove group blocks if they are presents in other groups
%w(top left right).each {|f|
session[:page_layout][f] = (session[:page_layout][f] || []) - group_items
}
session[:page_layout][group] = group_items
end
end
render :nothing => true
end

View File

@ -1,9 +1,9 @@
<div id="block_<%= block_name %>" class="mypage-box">
<div id="block_<%= block_name.dasherize %>" class="mypage-box">
<div style="float:right;margin-right:16px;z-index:500;">
<%= link_to_remote "", {
:url => { :action => "remove_block", :block => block_name },
:complete => "removeBlock('block_#{block_name}')" },
:complete => "removeBlock('block_#{block_name.dasherize}')" },
:class => "close-icon"
%>
</div>