summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/my_controller.rb22
-rw-r--r--app/views/my/_block.rhtml4
2 files changed, 14 insertions, 12 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 5e1b9d2c8..ae063d60a 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -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
diff --git a/app/views/my/_block.rhtml b/app/views/my/_block.rhtml
index bb5dd1f9f..b8e7192b8 100644
--- a/app/views/my/_block.rhtml
+++ b/app/views/my/_block.rhtml
@@ -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>