aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2018-05-09 15:15:05 +0200
committerAlban Peignier2018-05-09 15:15:05 +0200
commit9684831ac650d633ddfab1062e2285f9482b1157 (patch)
tree7e4b30940d05db3ebcdd12d7daf9877f803880cf
parent64933b6903583b585f7de5bc391a9ab2ade1c6a7 (diff)
downloadchouette-core-9684831ac650d633ddfab1062e2285f9482b1157.tar.bz2
Rewrite compliance_control_sets associated to workbench or workgroup edits and imports. Refs #6960
-rw-r--r--app/controllers/workbenches_controller.rb2
-rw-r--r--app/controllers/workgroups_controller.rb2
-rw-r--r--app/models/workgroup.rb46
-rw-r--r--app/views/imports/import/_workbench.html.slim2
-rw-r--r--app/views/workbenches/_form.html.slim4
-rw-r--r--app/views/workgroups/_form.html.slim6
-rw-r--r--config/locales/workgroups.en.yml14
-rw-r--r--config/locales/workgroups.fr.yml15
8 files changed, 48 insertions, 43 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index cecd071d8..1432518dc 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.available_compliance_control_sets.keys)
+ params.require(:workbench).permit(owner_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 5d422380c..70aa89cf9 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.available_compliance_control_sets.keys])
+ params[:workgroup].permit(workbenches_attributes: [:id, owner_compliance_control_set_ids: @workgroup.compliance_control_sets_by_workgroup.keys])
end
end
diff --git a/app/models/workgroup.rb b/app/models/workgroup.rb
index 499441cd3..6bb03c7fa 100644
--- a/app/models/workgroup.rb
+++ b/app/models/workgroup.rb
@@ -27,30 +27,34 @@ class Workgroup < ApplicationModel
export_types.include? export_name
end
- def available_compliance_control_sets
- %i(
- import
- merge
- automatic
- workgroup
- workbench
- ).inject({}) do |h, k|
- h[k] = "workgroups.available_compliance_control_sets.#{k}".t.capitalize
- h
- end
+ def all_compliance_control_sets
+ %i(after_import
+ after_import_by_workgroup
+ before_merge
+ before_merge_by_workgroup
+ after_merge
+ after_merge_by_workgroup
+ automatic_by_workgroup
+ )
+ end
+
+ def compliance_control_sets_by_workgroup
+ compliance_control_sets_labels all_compliance_control_sets.grep(/by_workgroup$/)
+ end
+
+ def compliance_control_sets_by_workbench
+ compliance_control_sets_labels all_compliance_control_sets.grep_v(/by_workgroup$/)
end
+
def import_compliance_control_sets
- %i(
- import
- workbench
- ).inject({}) do |h, k|
- h[k] = "workgroups.available_compliance_control_sets.#{k}".t.capitalize
+ compliance_control_sets_labels all_compliance_control_sets.grep(/^after_import/)
+ end
+
+ private
+ def compliance_control_sets_labels(keys)
+ keys.inject({}) do |h, k|
+ h[k] = "workgroups.compliance_control_sets.#{k}".t.capitalize
h
end
end
-
- # XXX
- # def import_compliance_control_sets
- # @import_compliance_control_sets ||= import_compliance_control_set_ids.map{|id| ComplianceControlSet.find(id)}
- # end
end
diff --git a/app/views/imports/import/_workbench.html.slim b/app/views/imports/import/_workbench.html.slim
index a2eeca1e5..e41ceb0f0 100644
--- a/app/views/imports/import/_workbench.html.slim
+++ b/app/views/imports/import/_workbench.html.slim
@@ -9,7 +9,7 @@
= render 'shared/iev_interfaces/messages', messages: @import.messages
ruby:
- controls = @workbench.workgroup.available_compliance_control_sets.map do |key, label|
+ controls = @workbench.workgroup.import_compliance_control_sets.map do |key, label|
TableBuilderHelper::Column.new(
name: label,
attribute: Proc.new { |n| n.workbench.compliance_control_set(key).present? ? import_status(n.workbench_import_check_set(key)&.status, verbose: true, default_status: (n.status == "ERROR" ? :aborted : :pending)) : '-' },
diff --git a/app/views/workbenches/_form.html.slim b/app/views/workbenches/_form.html.slim
index a6b778e94..95c7d16b3 100644
--- a/app/views/workbenches/_form.html.slim
+++ b/app/views/workbenches/_form.html.slim
@@ -2,9 +2,7 @@
.row
.col-lg-12
= f.fields_for :owner_compliance_control_set_ids do |ff|
- - @workbench.workgroup.available_compliance_control_sets.each do |cc, label|
+ - @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
- .separator
-
= f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'workbench_form'
diff --git a/app/views/workgroups/_form.html.slim b/app/views/workgroups/_form.html.slim
index c32be6d22..bd02fdc80 100644
--- a/app/views/workgroups/_form.html.slim
+++ b/app/views/workgroups/_form.html.slim
@@ -2,14 +2,14 @@
table.table
thead
th
- - @workgroup.available_compliance_control_sets.values.each do |cc|
+ - @workgroup.compliance_control_sets_by_workgroup.values.each do |cc|
th= cc
- @workgroup.workbenches.each_with_index do |w,i|
tr
th= w.organisation.name
- - @workgroup.available_compliance_control_sets.keys.each do |cc|
+ - @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(w.organisation.compliance_control_sets, :id, :name, w.compliance_control_set(cc).try(:id)), include_blank: true
+ = 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
= f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'workgroup_form'
diff --git a/config/locales/workgroups.en.yml b/config/locales/workgroups.en.yml
index 506d5367e..935f1a5fa 100644
--- a/config/locales/workgroups.en.yml
+++ b/config/locales/workgroups.en.yml
@@ -2,9 +2,11 @@ en:
workgroups:
edit:
title: "Paramétrages de l'application"
- available_compliance_control_sets:
- import: after import
- merge: after merge
- automatic: automatic
- workgroup: workgroup
- workbench: workbench
+ compliance_control_sets:
+ after_import: after import
+ after_import_by_workgroup: after import (group)
+ before_merge: before merge
+ before_merge_by_workgroup: before merge (group)
+ after_merge: after merge
+ after_merge_by_workgroup: after merge (group)
+ automatic_by_workgroup: automatic
diff --git a/config/locales/workgroups.fr.yml b/config/locales/workgroups.fr.yml
index 17e40f720..d209410e7 100644
--- a/config/locales/workgroups.fr.yml
+++ b/config/locales/workgroups.fr.yml
@@ -2,10 +2,11 @@ fr:
workgroups:
edit:
title: "Paramétrages de l'application"
-
- available_compliance_control_sets:
- import: jeu de données après import
- merge: jeu de données avant intégration
- automatic: offre transporteur
- workgroup: offre idf
- workbench: automatique
+ compliance_control_sets:
+ after_import: après import
+ after_import_by_workgroup: après import (groupe)
+ before_merge: avant finalisation
+ before_merge_by_workgroup: avant finalisation (groupe)
+ after_merge: après finalisation
+ after_merge_by_workgroup: après finalisation (groupe)
+ automatic_by_workgroup: automatique