From cd6e13d4ea86de054911a2c9bab0e733ba63095f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 22 Nov 2017 18:35:07 +0100 Subject: ReferentialsController: Fix typo in `build_referenial` name Rename the method to `build_referential`. Saw it because my project grep didn't work. Refs #5024 --- app/controllers/referentials_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index b63741ef6..d6c4327f9 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -8,13 +8,13 @@ class ReferentialsController < InheritedResources::Base def new new! do - build_referenial + build_referential end end def create create! do |format| - build_referenial + build_referential if !!@referential.created_from_id format.html { redirect_to workbench_path(@referential.workbench) } @@ -132,7 +132,7 @@ class ReferentialsController < InheritedResources::Base super end - def build_referenial + def build_referential if params[:from] source_referential = Referential.find(params[:from]) @referential = Referential.new_from(source_referential, current_functional_scope) -- cgit v1.2.3 From dfd3f9ecb78974c4fe90a24c0e779bef87c38e09 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 18 Dec 2017 13:36:29 +0100 Subject: Referentials#validate: Update flash message * Luc specified a new flash message string to use here. Update the old one with the new version. * Move the translation key to `notice.referentials.validate` because we have multiple "operation_in_progress" messages (this one for validation, and another for referential cloning/duplication). * Add a test to confirm that the flash message is set. Refs #5317 --- app/controllers/referentials_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index ee1236912..f97e2c211 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -60,7 +60,7 @@ class ReferentialsController < ChouetteController def validate ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id]) - flash[:notice] = I18n.t("referentials.operation_in_progress") + flash[:notice] = I18n.t('notice.referentials.validate') redirect_to(referential_path) end -- cgit v1.2.3 From 5ecfe32c539527017ab03b96b4a14b1daccac54c Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 18 Dec 2017 13:42:57 +0100 Subject: Referentials#validate: Remove `I18n.` prefix Call `#t` directly since we can and because the rest of the controller does this without the `I18n.` prefix. Refs #5317 --- app/controllers/referentials_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index f97e2c211..773de04fd 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -60,7 +60,7 @@ class ReferentialsController < ChouetteController def validate ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id]) - flash[:notice] = I18n.t('notice.referentials.validate') + flash[:notice] = t('notice.referentials.validate') redirect_to(referential_path) end -- cgit v1.2.3 From 1b690a6dbd7175eb29e543246a057e4a868974cd Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 18 Dec 2017 17:23:04 +0100 Subject: Referentials#create: Add flash message on referential duplication When a "duplicate referential" action is initiated, show a flash message to let users know that it started and is in progress (and will take a while since it's an asynchronous task). Refs #5317 --- app/controllers/referentials_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 773de04fd..40e8264ce 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -17,6 +17,8 @@ class ReferentialsController < ChouetteController build_referenial if !!@referential.created_from_id + flash[:notice] = t('notice.referentials.duplicate') + format.html { redirect_to workbench_path(@referential.workbench) } end end -- cgit v1.2.3 From 685e834bb96fa0c3aea77aed48770b8577d74c7e Mon Sep 17 00:00:00 2001 From: Xinhui Date: Wed, 20 Dec 2017 14:24:02 +0100 Subject: Fix referential create redirect when invalid Refs #5297 --- app/controllers/referentials_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 40e8264ce..9dbd659da 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -13,14 +13,16 @@ class ReferentialsController < ChouetteController end def create - create! do |format| + create! do |success, failure| build_referenial - if !!@referential.created_from_id - flash[:notice] = t('notice.referentials.duplicate') - - format.html { redirect_to workbench_path(@referential.workbench) } + success.html do + if @referential.created_from_id.present? + flash[:notice] = t('notice.referentials.duplicate') + redirect_to workbench_path(@referential.workbench) + end end + failure.html { render :new } end end -- cgit v1.2.3 From e20ce60629e91c63d75701651c117177ce02aced Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Thu, 28 Dec 2017 12:16:19 +0100 Subject: Add log messages when Referential can't be created. Remove useless build_referenial invocation in ReferentialsController#create. Refs #5297 --- app/controllers/referentials_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 9dbd659da..f63abf685 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -14,15 +14,16 @@ class ReferentialsController < ChouetteController def create create! do |success, failure| - build_referenial - success.html do if @referential.created_from_id.present? flash[:notice] = t('notice.referentials.duplicate') redirect_to workbench_path(@referential.workbench) end end - failure.html { render :new } + failure.html do + Rails.logger.info "Can't create Referential : #{@referential.errors.inspect}" + render :new + end end end -- cgit v1.2.3 From 048927f6ebc442ce3f2165b043801faf0ac95b14 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Tue, 2 Jan 2018 17:33:19 +0100 Subject: Fixes redirect on Referential creation (without cloning). Refs #5452. Refs #5297 --- app/controllers/referentials_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index f63abf685..6f398b7f5 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -17,8 +17,8 @@ class ReferentialsController < ChouetteController success.html do if @referential.created_from_id.present? flash[:notice] = t('notice.referentials.duplicate') - redirect_to workbench_path(@referential.workbench) end + redirect_to workbench_path(@referential.workbench) end failure.html do Rails.logger.info "Can't create Referential : #{@referential.errors.inspect}" -- cgit v1.2.3 From c2ca588ec9ec70ccd77690feacd45c7aae56b355 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Thu, 4 Jan 2018 17:49:06 +0100 Subject: Refs #5468 Change redirect after Referential#validate --- app/controllers/referentials_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 83e3bc56a..436d5ccb5 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -66,7 +66,7 @@ class ReferentialsController < ChouetteController def validate ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id]) flash[:notice] = t('notice.referentials.validate') - redirect_to(referential_path) + redirect_to workbench_compliance_check_sets_path(referential.workbench_id) end def destroy -- cgit v1.2.3 From fc462f368bc45143b9f0b8649e5bec1f69e414c7 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 17 Jan 2018 10:16:55 +0100 Subject: Refs #5586 @1h; Refactor ReferentialDecorator Plus: - Fix a bug on `html_options` in AF83::Decorator::Link - Add a `t` helper in AF83::Decorator to handle i18n --- app/controllers/referentials_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 436d5ccb5..41ddc3870 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -80,6 +80,7 @@ class ReferentialsController < ChouetteController referential.archive! redirect_to workbench_path(referential.workbench_id), notice: t('notice.referential.archived') end + def unarchive if referential.unarchive! flash[:notice] = t('notice.referential.unarchived') @@ -97,7 +98,7 @@ class ReferentialsController < ChouetteController helper_method :current_referential def resource - @referential ||= current_organisation.find_referential(params[:id]) + @referential ||= current_organisation.find_referential(params[:id]).decorate end def collection -- cgit v1.2.3 From 8957ab3e9b28e7548d3a4028308558bec1403c33 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 24 Jan 2018 13:25:28 +0100 Subject: ReferentialLineDecorator: Convert action links to new interface Refs #5586 --- app/controllers/referentials_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/controllers/referentials_controller.rb') diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 41ddc3870..0ed3f75dd 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -32,9 +32,8 @@ class ReferentialsController < ChouetteController show! do |format| @referential = @referential.decorate(context: { current_workbench_id: params[:current_workbench_id] } ) @reflines = lines_collection.paginate(page: params[:page], per_page: 10) - @reflines = ModelDecorator.decorate( + @reflines = ReferentialLineDecorator.decorate( @reflines, - with: ReferentialLineDecorator, context: { referential: referential, current_organisation: current_organisation -- cgit v1.2.3