summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-13 20:02:34 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-13 20:02:34 +0000
commit28e34e101cc3222c2eefb93201cf3cd957f81f7b (patch)
tree976a4bc0f94d0dbb544c49839db81a843fd11691 /app/controllers
parent327a6e54da602670d33b33b8054a9aa421e2f09d (diff)
downloadredmine-28e34e101cc3222c2eefb93201cf3cd957f81f7b.tar.gz
redmine-28e34e101cc3222c2eefb93201cf3cd957f81f7b.zip
Don't reload the page when adding/removing a block.
git-svn-id: http://svn.redmine.org/redmine/trunk@16394 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/my_controller.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 7d8770776..66bd965ba 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -147,18 +147,29 @@ class MyController < ApplicationController
# params[:block] : id of the block to add
def add_block
@user = User.current
- @user.pref.add_block params[:block]
- @user.pref.save
- redirect_to my_page_path
+ @block = params[:block]
+ if @user.pref.add_block @block
+ @user.pref.save
+ respond_to do |format|
+ format.html { redirect_to my_page_path }
+ format.js
+ end
+ else
+ render_error :status => 422
+ end
end
# Remove a block to user's page
# params[:block] : id of the block to remove
def remove_block
@user = User.current
- @user.pref.remove_block params[:block]
+ @block = params[:block]
+ @user.pref.remove_block @block
@user.pref.save
- redirect_to my_page_path
+ respond_to do |format|
+ format.html { redirect_to my_page_path }
+ format.js
+ end
end
# Change blocks order on user's page