aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorAlban Peignier2018-05-09 15:53:44 +0200
committerAlban Peignier2018-05-09 15:53:44 +0200
commit7107266518c028bebea7e4a89fd1db1040935b35 (patch)
tree77ea7d1eb966fca197b1074b4f4f22ef44f69212 /app
parentd0ab0eb848a96587ac0e0ab26db962c15e559185 (diff)
downloadchouette-core-7107266518c028bebea7e4a89fd1db1040935b35.tar.bz2
Use Workbench#compliance_control_set_ids virtual attribute to merge with existing owner_compliance_control_set_ids. Refs #6960
Diffstat (limited to 'app')
-rw-r--r--app/controllers/workbenches_controller.rb2
-rw-r--r--app/controllers/workgroups_controller.rb2
-rw-r--r--app/models/workbench.rb4
-rw-r--r--app/views/workbenches/_form.html.slim2
-rw-r--r--app/views/workgroups/_form.html.slim2
5 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index 1432518dc..d4dfdebe3 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -42,7 +42,7 @@ class WorkbenchesController < ChouetteController
private
def workbench_params
- params.require(:workbench).permit(owner_compliance_control_set_ids: @workbench.workgroup.compliance_control_sets_by_workbench.keys)
+ params.require(:workbench).permit(compliance_control_set_ids: @workbench.workgroup.compliance_control_sets_by_workbench.keys)
end
def resource
diff --git a/app/controllers/workgroups_controller.rb b/app/controllers/workgroups_controller.rb
index 70aa89cf9..3acea248d 100644
--- a/app/controllers/workgroups_controller.rb
+++ b/app/controllers/workgroups_controller.rb
@@ -8,6 +8,6 @@ class WorkgroupsController < ChouetteController
end
def workgroup_params
- params[:workgroup].permit(workbenches_attributes: [:id, owner_compliance_control_set_ids: @workgroup.compliance_control_sets_by_workgroup.keys])
+ params[:workgroup].permit(workbenches_attributes: [:id, compliance_control_set_ids: @workgroup.compliance_control_sets_by_workgroup.keys])
end
end
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index 64e9ae92d..1bca91c56 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -61,6 +61,10 @@ class Workbench < ApplicationModel
id.present? && ComplianceControlSet.find(id)
end
+ def compliance_control_set_ids=(compliance_control_set_ids)
+ self.owner_compliance_control_set_ids = (owner_compliance_control_set_ids || {}).merge compliance_control_set_ids
+ end
+
private
def initialize_output
diff --git a/app/views/workbenches/_form.html.slim b/app/views/workbenches/_form.html.slim
index 95c7d16b3..819346c35 100644
--- a/app/views/workbenches/_form.html.slim
+++ b/app/views/workbenches/_form.html.slim
@@ -1,7 +1,7 @@
= simple_form_for @workbench, html: { class: 'form-horizontal', id: 'workbench_form' }, wrapper: :horizontal_form do |f|
.row
.col-lg-12
- = f.fields_for :owner_compliance_control_set_ids do |ff|
+ = f.fields_for :compliance_control_set_ids do |ff|
- @workbench.workgroup.compliance_control_sets_by_workbench.each do |cc, label|
= ff.input cc, as: :select, collection: current_organisation.compliance_control_sets, value_method: :id, label: label, selected: @workbench.compliance_control_set(cc).try(:id).try(:to_s), include_blank: true
diff --git a/app/views/workgroups/_form.html.slim b/app/views/workgroups/_form.html.slim
index bd02fdc80..7245cfc40 100644
--- a/app/views/workgroups/_form.html.slim
+++ b/app/views/workgroups/_form.html.slim
@@ -10,6 +10,6 @@
- @workgroup.compliance_control_sets_by_workgroup.keys.each do |cc|
td
= hidden_field_tag "workgroup[workbenches_attributes][#{i}][id]", w.id
- = select_tag "workgroup[workbenches_attributes][#{i}][owner_compliance_control_set_ids][#{cc}]", options_from_collection_for_select(current_organisation.compliance_control_sets, :id, :name, w.compliance_control_set(cc).try(:id)), include_blank: true
+ = select_tag "workgroup[workbenches_attributes][#{i}][compliance_control_set_ids][#{cc}]", options_from_collection_for_select(current_organisation.compliance_control_sets, :id, :name, w.compliance_control_set(cc).try(:id)), include_blank: true
= f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'workgroup_form'