From 42b5c332b2c24c8dcc2581e0cd130ef930959d99 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 17 Apr 2016 07:40:39 +0000 Subject: Lists can be reordered with drag and drop (#12909). git-svn-id: http://svn.redmine.org/redmine/trunk@15336 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/custom_fields_controller.rb | 14 +++++++++++--- app/controllers/enumerations_controller.rb | 14 +++++++++++--- app/controllers/issue_statuses_controller.rb | 14 +++++++++++--- app/controllers/roles_controller.rb | 14 +++++++++++--- app/controllers/trackers_controller.rb | 20 +++++++++++++++----- 5 files changed, 59 insertions(+), 17 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb index 3c2cf7cfa..ab0d5019f 100644 --- a/app/controllers/custom_fields_controller.rb +++ b/app/controllers/custom_fields_controller.rb @@ -54,11 +54,19 @@ class CustomFieldsController < ApplicationController def update if @custom_field.update_attributes(params[:custom_field]) - flash[:notice] = l(:notice_successful_update) call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field) - redirect_back_or_default edit_custom_field_path(@custom_field) + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_back_or_default edit_custom_field_path(@custom_field) + } + format.js { render :nothing => true } + end else - render :action => 'edit' + respond_to do |format| + format.html { render :action => 'edit' } + format.js { render :nothing => true, :status => 422 } + end end end diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb index 05ca5152a..feb360398 100644 --- a/app/controllers/enumerations_controller.rb +++ b/app/controllers/enumerations_controller.rb @@ -57,10 +57,18 @@ class EnumerationsController < ApplicationController def update if @enumeration.update_attributes(params[:enumeration]) - flash[:notice] = l(:notice_successful_update) - redirect_to enumerations_path + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to enumerations_path + } + format.js { render :nothing => true } + end else - render :action => 'edit' + respond_to do |format| + format.html { render :action => 'edit' } + format.js { render :nothing => true, :status => 422 } + end end end diff --git a/app/controllers/issue_statuses_controller.rb b/app/controllers/issue_statuses_controller.rb index 6d574fe87..e49878f1d 100644 --- a/app/controllers/issue_statuses_controller.rb +++ b/app/controllers/issue_statuses_controller.rb @@ -51,10 +51,18 @@ class IssueStatusesController < ApplicationController def update @issue_status = IssueStatus.find(params[:id]) if @issue_status.update_attributes(params[:issue_status]) - flash[:notice] = l(:notice_successful_update) - redirect_to issue_statuses_path(:page => params[:page]) + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to issue_statuses_path(:page => params[:page]) + } + format.js { render :nothing => true } + end else - render :action => 'edit' + respond_to do |format| + format.html { render :action => 'edit' } + format.js { render :nothing => true, :status => 422 } + end end end diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 2732a89a1..2de185b5b 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -72,10 +72,18 @@ class RolesController < ApplicationController def update if @role.update_attributes(params[:role]) - flash[:notice] = l(:notice_successful_update) - redirect_to roles_path(:page => params[:page]) + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to roles_path(:page => params[:page]) + } + format.js { render :nothing => true } + end else - render :action => 'edit' + respond_to do |format| + format.html { render :action => 'edit' } + format.js { render :nothing => true, :status => 422 } + end end end diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 91784d16e..2b93753d0 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -59,12 +59,22 @@ class TrackersController < ApplicationController def update @tracker = Tracker.find(params[:id]) if @tracker.update_attributes(params[:tracker]) - flash[:notice] = l(:notice_successful_update) - redirect_to trackers_path(:page => params[:page]) - return + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to trackers_path(:page => params[:page]) + } + format.js { render :nothing => true } + end + else + respond_to do |format| + format.html { + edit + render :action => 'edit' + } + format.js { render :nothing => true, :status => 422 } + end end - edit - render :action => 'edit' end def destroy -- cgit v1.2.3