From 6f1fa09dd12979933bef8bb97cdc6ae4ff10a9f0 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 19 Jun 2017 15:58:02 +0200 Subject: RoutingConstraintZones#show: Render header links from #action_links Use the `RoutingConstraintZonesDecorator` to render the header links instead of constructing them in the view. This allows us to reuse the links. To be honest, I haven't actually tested this for real. Don't know how to set up an Interdiction de Traffic Local. Refs #3479 --- app/controllers/routing_constraint_zones_controller.rb | 4 ++++ app/views/routing_constraint_zones/show.html.slim | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index 7707427b0..9d2fd712c 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -16,6 +16,10 @@ class RoutingConstraintZonesController < ChouetteController def show @routing_constraint_zone = collection.find(params[:id]) + @routing_constraint_zone = @routing_constraint_zone.decorate(context: { + referential: @referential, + line: @line + }) end protected diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index f0c244387..1dad4f561 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -7,13 +7,12 @@ / Below is secundary actions & optional contents .row .col-lg-12.text-right.mb-sm - - if policy(@routing_constraint_zone).update? - = link_to t('actions.edit'), edit_referential_line_routing_constraint_zone_path(@referential, @line, @routing_constraint_zone), class: 'btn btn-primary' - - - if policy(@routing_constraint_zone).destroy? - = link_to referential_line_routing_constraint_zone_path(@referential, @line, @routing_constraint_zone), method: :delete, data: {confirm: t('routing_constraint_zones.actions.destroy_confirm')}, class: 'btn btn-primary' do - span.fa.fa-trash - span = t('actions.destroy') + - @routing_constraint_zone.action_links.each do |link| + = link_to link.href, + method: link.method, + data: link.data, + class: 'btn btn-primary' do + = link.content / PageContent .page_content -- cgit v1.2.3