aboutsummaryrefslogtreecommitdiffstats
path: root/app/decorators
diff options
context:
space:
mode:
authorTeddy Wing2018-01-25 14:01:13 +0100
committerZog2018-01-25 17:18:03 +0100
commit2bf4cf2e3a9e54bc9b91bf3efcac721951df730d (patch)
tree19c9c1c588b13b721c7d0aa61d7c9b1684f22cf4 /app/decorators
parent9ee14d84ccfd19fb6a53c83826f352088f06b57c (diff)
downloadchouette-core-2bf4cf2e3a9e54bc9b91bf3efcac721951df730d.tar.bz2
ComplianceControlDecorator: Convert to new action links interface
I was getting this error: ActionView::Template::Error (undefined method `split' for nil:NilClass Did you mean? split_all): 16: 17: / compliance controls without block 18: = render_compliance_control_block 19: = render_compliance_controls(@direct_compliance_controls) 20: 21: / compliance controls with block 22: - if params[:q] && params[:q][:compliance_control_block_id_eq_any].try(:present?) app/helpers/table_builder_helper.rb:110:in `item_row_class_name' app/helpers/table_builder_helper.rb:290:in `tbody' app/helpers/table_builder_helper.rb:97:in `table_builder_2' app/helpers/compliance_control_sets_helper.rb:79:in `block in render_table_builder' app/helpers/compliance_control_sets_helper.rb:78:in `render_table_builder' app/helpers/compliance_control_sets_helper.rb:71:in `block (2 levels) in render_compliance_controls' app/helpers/compliance_control_sets_helper.rb:70:in `block in render_compliance_controls' app/helpers/compliance_control_sets_helper.rb:69:in `render_compliance_controls' app/views/compliance_control_sets/show.html.slim:19:in `_app_views_compliance_control_sets_show_html_slim___3528509151208629266_70279137561480' The model name wasn't accessible from the view because this collection is set up in an unorthodox way without a decorated collection. Got help from Johan, and we ended up using the `model` param passed into the table builder for this. It looks terrible with `model` all over the place, but at least it gets us past the problem. Refs #5586
Diffstat (limited to 'app/decorators')
-rw-r--r--app/decorators/compliance_control_decorator.rb51
1 files changed, 27 insertions, 24 deletions
diff --git a/app/decorators/compliance_control_decorator.rb b/app/decorators/compliance_control_decorator.rb
index f56e80417..a0445faa2 100644
--- a/app/decorators/compliance_control_decorator.rb
+++ b/app/decorators/compliance_control_decorator.rb
@@ -1,30 +1,33 @@
-class ComplianceControlDecorator < Draper::Decorator
- delegate_all
-
- def action_links
- policy = h.policy(object)
- links = []
-
- links << Link.new(
- content: h.t('compliance_control_sets.actions.show'),
- href: h.compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id)
- )
+class ComplianceControlDecorator < AF83::Decorator
+ with_instance_decorator do |instance_decorator|
+ instance_decorator.show_action_link do |l|
+ l.content h.t('compliance_control_sets.actions.show')
+ l.href do
+ h.compliance_control_set_compliance_control_path(
+ object.compliance_control_set.id,
+ object.id
+ )
+ end
+ end
- if policy.edit?
- links << Link.new(
- content: h.t('compliance_controls.actions.edit'),
- href: h.edit_compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id)
- )
+ instance_decorator.edit_action_link do |l|
+ l.href do
+ h.edit_compliance_control_set_compliance_control_path(
+ object.compliance_control_set_id,
+ object.id
+ )
+ end
end
- if policy.destroy?
- links << Link.new(
- content: h.destroy_link_content,
- href: h.compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id),
- method: :delete,
- data: { confirm: h.t('compliance_controls.actions.destroy_confirm') }
- )
+ instance_decorator.destroy_action_link do |l|
+ l.content h.destroy_link_content
+ l.href do
+ h.compliance_control_set_compliance_control_path(
+ object.compliance_control_set.id,
+ object.id
+ )
+ end
+ l.data confirm: h.t('compliance_controls.actions.destroy_confirm')
end
- links
end
end