aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorZog2018-05-09 10:19:33 +0200
committerZog2018-05-09 10:19:33 +0200
commit64933b6903583b585f7de5bc391a9ab2ade1c6a7 (patch)
tree844875f2cc8f62f9561e2b9b840dee2c6d2128d4 /app
parent9434284e4f12b4b576762dabbd2b0a308e28bc61 (diff)
downloadchouette-core-64933b6903583b585f7de5bc391a9ab2ade1c6a7.tar.bz2
Refs #6961; Update Workbench#edit
- Update the form - Use policies and update the seeds accordingly - Add a link in the navbar(s)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/workbenches_controller.rb2
-rw-r--r--app/policies/workbench_policy.rb2
-rw-r--r--app/views/layouts/navigation/_main_nav_left_content.html.slim8
-rw-r--r--app/views/layouts/navigation/_main_nav_left_content_stif.html.slim3
-rw-r--r--app/views/workbenches/_form.html.slim5
5 files changed, 15 insertions, 5 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index 43415ff60..cecd071d8 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(:import_compliance_control_set_id, :merge_compliance_control_set_id)
+ params.require(:workbench).permit(owner_compliance_control_set_ids: @workbench.workgroup.available_compliance_control_sets.keys)
end
def resource
diff --git a/app/policies/workbench_policy.rb b/app/policies/workbench_policy.rb
index 7b925e91a..9f2279c38 100644
--- a/app/policies/workbench_policy.rb
+++ b/app/policies/workbench_policy.rb
@@ -6,6 +6,6 @@ class WorkbenchPolicy < ApplicationPolicy
end
def update?
- true
+ user.has_permission?('workbenches.update')
end
end
diff --git a/app/views/layouts/navigation/_main_nav_left_content.html.slim b/app/views/layouts/navigation/_main_nav_left_content.html.slim
index 0b55578a7..889f8f944 100644
--- a/app/views/layouts/navigation/_main_nav_left_content.html.slim
+++ b/app/views/layouts/navigation/_main_nav_left_content.html.slim
@@ -15,6 +15,9 @@
span = t('layouts.navbar.workbench_outputs.organisation')
= link_to '#', class: 'list-group-item disabled' do
span = t('layouts.navbar.workbench_outputs.workgroup')
+ - if policy(workbench.workgroup).edit?
+ = link_to [:edit, workbench.workgroup], class: 'list-group-item' do
+ span = t('layouts.navbar.workbench_outputs.edit_workgroup')
.menu-item.panel
.panel-heading
@@ -36,7 +39,10 @@
span = t('activerecord.models.compliance_check_set.other').capitalize
= link_to compliance_control_sets_path, class: 'list-group-item' do
span = t('activerecord.models.compliance_control_set.other').capitalize
-
+ - if policy(workbench).edit?
+ = link_to [:edit, workbench], class: 'list-group-item' do
+ span = t('workbenches.edit.link')
+
.menu-item.panel
.panel-heading
h4.panel-title
diff --git a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim
index 382d80e0d..a7bb3f511 100644
--- a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim
+++ b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim
@@ -38,6 +38,9 @@
span = t('activerecord.models.compliance_check_set.other').capitalize
= link_to compliance_control_sets_path, class: 'list-group-item' do
span = t('activerecord.models.compliance_control_set.other').capitalize
+ - if policy(workbench).edit?
+ = link_to [:edit, workbench], class: 'list-group-item' do
+ span = t('workbenches.edit.link')
.menu-item.panel
.panel-heading
diff --git a/app/views/workbenches/_form.html.slim b/app/views/workbenches/_form.html.slim
index 534a5f378..a6b778e94 100644
--- a/app/views/workbenches/_form.html.slim
+++ b/app/views/workbenches/_form.html.slim
@@ -1,8 +1,9 @@
= simple_form_for @workbench, html: { class: 'form-horizontal', id: 'workbench_form' }, wrapper: :horizontal_form do |f|
.row
.col-lg-12
- = f.input :import_compliance_control_set_id, as: :select, collection: current_organisation.compliance_control_sets, value_method: :id
- = f.input :merge_compliance_control_set_id, as: :select, collection: current_organisation.compliance_control_sets, value_method: :id
+ = f.fields_for :owner_compliance_control_set_ids do |ff|
+ - @workbench.workgroup.available_compliance_control_sets.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