aboutsummaryrefslogtreecommitdiffstats
path: root/app/decorators
diff options
context:
space:
mode:
authorTeddy Wing2018-01-24 13:49:29 +0100
committerZog2018-01-25 17:18:01 +0100
commit5e41dbed021522331532eb0151ac441553be2d13 (patch)
tree9fdb81088c7fb402717b5a67823ceb52e8e8a3e4 /app/decorators
parent8957ab3e9b28e7548d3a4028308558bec1403c33 (diff)
downloadchouette-core-5e41dbed021522331532eb0151ac441553be2d13.tar.bz2
RoutingConstraintZoneDecorator: Convert action links to new interface
Refs #5586
Diffstat (limited to 'app/decorators')
-rw-r--r--app/decorators/routing_constraint_zone_decorator.rb59
1 files changed, 37 insertions, 22 deletions
diff --git a/app/decorators/routing_constraint_zone_decorator.rb b/app/decorators/routing_constraint_zone_decorator.rb
index 0b438a554..657065310 100644
--- a/app/decorators/routing_constraint_zone_decorator.rb
+++ b/app/decorators/routing_constraint_zone_decorator.rb
@@ -1,42 +1,57 @@
-class RoutingConstraintZoneDecorator < Draper::Decorator
+class RoutingConstraintZoneDecorator < AF83::Decorator
decorates Chouette::RoutingConstraintZone
- delegate_all
-
- # Requires:
+ # Action links require:
# context: {
# referential: ,
# line:
# }
- def action_links
- links = []
- if h.policy(object).update?
- links << Link.new(
- content: h.t('actions.edit'),
- href: h.edit_referential_line_routing_constraint_zone_path(
+ create_action_link(
+ if: ->() {
+ h.policy(Chouette::RoutingConstraintZone).create? &&
+ context[:referential].organisation == h.current_organisation
+ }
+ ) do |l|
+ l.href do
+ h.new_referential_line_routing_constraint_zone_path(
+ context[:referential],
+ context[:line]
+ )
+ end
+ l.class 'btn btn-primary'
+ end
+
+ with_instance_decorator do |instance_decorator|
+ instance_decorator.show_action_link do |l|
+ l.href do
+ h.referential_line_routing_constraint_zone_path(
context[:referential],
context[:line],
object
)
- )
+ end
end
- if h.policy(object).destroy?
- links << Link.new(
- content: h.destroy_link_content,
- href: h.referential_line_routing_constraint_zone_path(
+ instance_decorator.edit_action_link do |l|
+ l.href do
+ h.edit_referential_line_routing_constraint_zone_path(
context[:referential],
context[:line],
object
- ),
- method: :delete,
- data: {
- confirm: h.t('routing_constraint_zones.actions.destroy_confirm')
- }
- )
+ )
+ end
end
- links
+ instance_decorator.destroy_action_link do |l|
+ l.href do
+ h.referential_line_routing_constraint_zone_path(
+ context[:referential],
+ context[:line],
+ object
+ )
+ end
+ l.data confirm: h.t('routing_constraint_zones.actions.destroy_confirm')
+ end
end
end