aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorteddywing2018-03-05 12:57:31 +0100
committerGitHub2018-03-05 12:57:31 +0100
commit272183f191ef72ec67e8e0923f6d5db9772a16c8 (patch)
tree714d835604870712bd22bf48bb59d78f71cd3cd9 /app
parent8df512c4b6dfba376b0dea8d493eadb994427b5b (diff)
parent9f218edb7e9b2843c82d85118e5caa51290aebb7 (diff)
downloadchouette-core-272183f191ef72ec67e8e0923f6d5db9772a16c8.tar.bz2
Merge pull request #358 from af83/new-ccset-affectation
New ccset affectation
Diffstat (limited to 'app')
-rw-r--r--app/controllers/workbenches_controller.rb11
-rw-r--r--app/policies/workbench_policy.rb11
-rw-r--r--app/views/workbenches/_form.html.slim9
-rw-r--r--app/views/workbenches/edit.html.slim8
-rw-r--r--app/views/workbenches/show.html.slim2
5 files changed, 39 insertions, 2 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index 2a71fe811..35438eaaf 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -3,7 +3,10 @@ class WorkbenchesController < ChouetteController
include RansackDateFilter
before_action only: [:show] { set_date_time_params("validity_period", Date) }
defaults resource_class: Workbench
- respond_to :html, only: [:show, :index]
+
+ include PolicyChecker
+
+ respond_to :html, except: :destroy
def index
redirect_to dashboard_path
@@ -24,7 +27,6 @@ class WorkbenchesController < ChouetteController
current_workbench_id: params[:id]
}
)
- show!
end
def delete_referentials
@@ -38,6 +40,11 @@ class WorkbenchesController < ChouetteController
end
private
+
+ def workbench_params
+ params.require(:workbench).permit(:import_compliance_control_set_id, :merge_compliance_control_set_id)
+ end
+
def resource
@workbench = current_organisation.workbenches.find params[:id]
end
diff --git a/app/policies/workbench_policy.rb b/app/policies/workbench_policy.rb
new file mode 100644
index 000000000..7b925e91a
--- /dev/null
+++ b/app/policies/workbench_policy.rb
@@ -0,0 +1,11 @@
+class WorkbenchPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
+ end
+ end
+
+ def update?
+ true
+ end
+end
diff --git a/app/views/workbenches/_form.html.slim b/app/views/workbenches/_form.html.slim
new file mode 100644
index 000000000..534a5f378
--- /dev/null
+++ b/app/views/workbenches/_form.html.slim
@@ -0,0 +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
+
+ .separator
+
+ = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'workbench_form'
diff --git a/app/views/workbenches/edit.html.slim b/app/views/workbenches/edit.html.slim
new file mode 100644
index 000000000..893024490
--- /dev/null
+++ b/app/views/workbenches/edit.html.slim
@@ -0,0 +1,8 @@
+- breadcrumb @workbench
+- page_header_content_for @workbench
+
+.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
+ == render 'form'
diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim
index 159aa8ea2..5c2468296 100644
--- a/app/views/workbenches/show.html.slim
+++ b/app/views/workbenches/show.html.slim
@@ -3,6 +3,8 @@
- content_for :page_header_content do
.row.mb-sm
.col-lg-12.text-right
+ - if policy(Workbench).update?
+ = link_to t('workbenches.actions.configure'), edit_workbench_path(@workbench), class: 'btn btn-primary'
- if policy(Referential).create?
= link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary'
= link_to t('actions.add'), new_workbench_referential_path(@workbench), class: 'btn btn-primary'