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
This commit is contained in:
Jean-Philippe Lang
2017-03-13 20:02:34 +00:00
parent 327a6e54da
commit 28e34e101c
6 changed files with 40 additions and 11 deletions

View File

@@ -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