aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorteddywing2017-11-08 15:17:42 +0100
committerGitHub2017-11-08 15:17:42 +0100
commit4dbe0a7b5acf4e244016d58d59a96aca36035263 (patch)
treedc5e6224ebf14e87d8e3adeb22c1a0bb5d1ed246 /app
parent0fc367c0095839f5089d5807767c1319e3d94ec0 (diff)
parent5fee40024adbdbcfc858170019b327a031b15848 (diff)
downloadchouette-core-4dbe0a7b5acf4e244016d58d59a96aca36035263.tar.bz2
Merge pull request #110 from af83/4755-page_for_validate_referential
4755 page for validate referential
Diffstat (limited to 'app')
-rw-r--r--app/controllers/referentials_controller.rb10
-rw-r--r--app/decorators/referential_decorator.rb8
-rw-r--r--app/policies/referential_policy.rb6
-rw-r--r--app/views/referentials/select_compliance_control_set.html.slim20
4 files changed, 42 insertions, 2 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 6b479e938..b63741ef6 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.where(organisation: current_organisation)
+ 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 dccf0052c..4103790aa 100644
--- a/app/decorators/referential_decorator.rb
+++ b/app/decorators/referential_decorator.rb
@@ -16,6 +16,14 @@ class ReferentialDecorator < Draper::Decorator
href: h.new_referential_path(from: object.id, current_workbench_id: context[:current_workbench_id])
)
end
+
+ if policy.validate?
+ links << Link.new(
+ content: h.t('actions.validate'),
+ href: h.referential_select_compliance_control_set_path(object.id)
+ )
+ end
+
if policy.archive?
links << Link.new(
content: h.t('actions.archive'),
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/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