diff options
Diffstat (limited to 'app')
6 files changed, 37 insertions, 36 deletions
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb index cff67d5cb..b45e85d49 100644 --- a/app/controllers/compliance_control_sets_controller.rb +++ b/app/controllers/compliance_control_sets_controller.rb @@ -33,10 +33,6 @@ class ComplianceControlSetsController < InheritedResources::Base redirect_to(compliance_control_sets_path) end - def select_compliance_control_set - @compliance_control_sets = ComplianceControlSet.all - end - protected def begin_of_association_chain diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 6b479e938..b08f58514 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -54,6 +54,16 @@ class ReferentialsController < InheritedResources::Base end end + def select_compliance_control_set + @compliance_control_sets = ComplianceControlSet.all + end + + def validate + ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id]) + flash[:notice] = I18n.t("referentials.operation_in_progress") + redirect_to(referential_path) + end + def destroy workbench = referential.workbench_id diff --git a/app/decorators/referential_decorator.rb b/app/decorators/referential_decorator.rb index 3876d966d..4103790aa 100644 --- a/app/decorators/referential_decorator.rb +++ b/app/decorators/referential_decorator.rb @@ -17,12 +17,12 @@ class ReferentialDecorator < Draper::Decorator ) end - # if policy.validate? + if policy.validate? links << Link.new( content: h.t('actions.validate'), - href: h.compliance_control_set_select_compliance_control_set_path(object.id, referential_id: context[:referential_id]) + href: h.referential_select_compliance_control_set_path(object.id) ) - # end + end if policy.archive? links << Link.new( diff --git a/app/policies/referential_policy.rb b/app/policies/referential_policy.rb index fdc80516c..bc8a3e24b 100644 --- a/app/policies/referential_policy.rb +++ b/app/policies/referential_policy.rb @@ -17,12 +17,14 @@ class ReferentialPolicy < ApplicationPolicy !archived? && organisation_match? && user.has_permission?('referentials.update') end - - def clone? !archived? && create? end + def validate? + !archived? && create? + end + def archive? record.archived_at.nil? && organisation_match? && user.has_permission?('referentials.update') end diff --git a/app/views/compliance_control_sets/select_compliance_control_set.html.slim b/app/views/compliance_control_sets/select_compliance_control_set.html.slim deleted file mode 100644 index 4b76fdac2..000000000 --- a/app/views/compliance_control_sets/select_compliance_control_set.html.slim +++ /dev/null @@ -1,27 +0,0 @@ -/ PageHeader -- header_params = ['jeux-de-controle', - t('referentials.select_jdc.title'), - ''] -= pageheader(*header_params) do - -/ PageContent -.page_content - .container-fluid - .row - .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 - = form_tag '#', {class: 'form-horizontal', id: 'select_compliance_control_set', wrapper: :horizontal_form} do - .row - .col-lg-12 - .form-group - = label_tag 'name', nil, class: 'string required col-sm-4 col-xs-5 control-label' - .col-sm-8.col-xs-7 - = select_tag :name, options_from_collection_for_select(@compliance_control_sets, "id", "name"), class: 'select optional form-control' - .separator - = button_tag t('actions.submit'), class: 'btn btn-default formSubmitr' - - - /= simple_form_for @compliance_control_sets, html: { class: 'form-horizontal', id: 'select_compliance_control_set' }, wrapper: :horizontal_form do |f| - / .row - / .col-lg-12 - / = f.association :compliance_control_set, collection: @compliance_control_sets, label_method: lambda {@compliance_control_sets.name} - /= f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'select_compliance_control_set' diff --git a/app/views/referentials/select_compliance_control_set.html.slim b/app/views/referentials/select_compliance_control_set.html.slim new file mode 100644 index 000000000..2d3f2344c --- /dev/null +++ b/app/views/referentials/select_compliance_control_set.html.slim @@ -0,0 +1,20 @@ +/ PageHeader +- header_params = ['jeux-de-controle', + t('referentials.select_compliance_control_set.title'), + ''] += pageheader(*header_params) do + +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + = form_tag validate_referential_path(params[:referential_id]), {class: 'form-horizontal', id: 'select_compliance_control_set', wrapper: :horizontal_form} do + .row + .col-lg-12 + .form-group + = label_tag 'name', nil, class: 'string required col-sm-4 col-xs-5 control-label' + .col-sm-8.col-xs-7 + = select_tag :compliance_control_set, options_from_collection_for_select(@compliance_control_sets, "id", "name"), class: 'select optional form-control' + .separator + = button_tag t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'select_compliance_control_set'
\ No newline at end of file |
