aboutsummaryrefslogtreecommitdiffstats
path: root/app/decorators
diff options
context:
space:
mode:
authorTeddy Wing2018-01-24 13:25:28 +0100
committerZog2018-01-25 17:18:01 +0100
commit8957ab3e9b28e7548d3a4028308558bec1403c33 (patch)
treeaa7aa34c6c905c3817c34ede8aa59c5db3a75901 /app/decorators
parent766dd36e253cfe00f0cec96e7fa55687428b0f2a (diff)
downloadchouette-core-8957ab3e9b28e7548d3a4028308558bec1403c33.tar.bz2
ReferentialLineDecorator: Convert action links to new interface
Refs #5586
Diffstat (limited to 'app/decorators')
-rw-r--r--app/decorators/referential_line_decorator.rb53
1 files changed, 28 insertions, 25 deletions
diff --git a/app/decorators/referential_line_decorator.rb b/app/decorators/referential_line_decorator.rb
index dceb3e2a9..8f884a8e0 100644
--- a/app/decorators/referential_line_decorator.rb
+++ b/app/decorators/referential_line_decorator.rb
@@ -1,40 +1,43 @@
-class ReferentialLineDecorator < Draper::Decorator
+class ReferentialLineDecorator < AF83::Decorator
decorates Chouette::Line
- delegate_all
-
- # Requires:
+ # Action links require:
# context: {
# referential: ,
# current_organisation:
# }
- def action_links
- links = []
- links << Link.new(
- content: Chouette::Line.human_attribute_name(:footnotes),
- href: h.referential_line_footnotes_path(context[:referential], object)
- )
+ with_instance_decorator do |instance_decorator|
+ instance_decorator.show_action_link do |l|
+ l.href { h.referential_line_path(context[:referential], object) }
+ end
- links << Link.new(
- content: h.t('routing_constraint_zones.index.title'),
- href: h.referential_line_routing_constraint_zones_path(
- context[:referential],
- object
- )
- )
+ instance_decorator.action_link secondary: true do |l|
+ l.content Chouette::Line.human_attribute_name(:footnotes)
+ l.href { h.referential_line_footnotes_path(context[:referential], object) }
+ end
- if !object.hub_restricted? ||
- (object.hub_restricted? && object.routes.size < 2)
- if h.policy(Chouette::Route).create? &&
- context[:referential].organisation == context[:current_organisation]
- links << Link.new(
- content: h.t('routes.actions.new'),
- href: h.new_referential_line_route_path(context[:referential], object)
+ instance_decorator.action_link secondary: true do |l|
+ l.content h.t('routing_constraint_zones.index.title')
+ l.href do
+ h.referential_line_routing_constraint_zones_path(
+ context[:referential],
+ object
)
end
end
- links
+ instance_decorator.action_link(
+ if: ->() {
+ (!object.hub_restricted? ||
+ (object.hub_restricted? && object.routes.size < 2)) &&
+ (h.policy(Chouette::Route).create? &&
+ context[:referential].organisation == context[:current_organisation])
+ },
+ secondary: true
+ ) do |l|
+ l.content h.t('routes.actions.new')
+ l.href { h.new_referential_line_route_path(context[:referential], object) }
+ end
end
end