diff options
author | Teddy Wing | 2017-06-19 17:24:15 +0200 |
---|---|---|
committer | Teddy Wing | 2017-06-19 17:42:05 +0200 |
commit | d4de52d63f400f30dabb7034e14202f5c9bd0192 (patch) | |
tree | 11beeb11734c8019404e22001bb5ae45ffafcd9a | |
parent | 7d45b2f803d4f14f1aa0d713b0c43ed9f41a41e7 (diff) | |
download | chouette-core-d4de52d63f400f30dabb7034e14202f5c9bd0192.tar.bz2 |
Lines#show: Render header links from #action_links
Get the header links from the decorator so we can reuse them instead of
defining them directly in the template.
Add an option to the `destroy_link_content` Rails helper method to allow
us to specify alternate translation keys, giving us different text in
the button label. Added this because the template in question uses a
different label than the others (usually it's `actions.destroy`).
Refs #3479
-rw-r--r-- | app/controllers/lines_controller.rb | 4 | ||||
-rw-r--r-- | app/decorators/line_decorator.rb | 4 | ||||
-rw-r--r-- | app/helpers/links_helper.rb | 4 | ||||
-rw-r--r-- | app/views/lines/show.html.slim | 17 |
4 files changed, 13 insertions, 16 deletions
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 7eedaeb05..c3378208b 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -25,6 +25,10 @@ class LinesController < BreadcrumbController def show @group_of_lines = resource.group_of_lines show! do + @line = @line.decorate(context: { + line_referential: @line_referential + }) + build_breadcrumb :show end end diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb index 84f6cba91..53053ed2c 100644 --- a/app/decorators/line_decorator.rb +++ b/app/decorators/line_decorator.rb @@ -35,9 +35,7 @@ class LineDecorator < Draper::Decorator if h.policy(object).destroy? links << Link.new( -# TODO: this translation is different! -span = t('lines.actions.destroy') - content: h.destroy_link_content, + content: h.destroy_link_content('lines.actions.destroy_confirm'), href: h.line_referential_line_path(context[:line_referential], object), method: :delete, data: { confirm: h.t('lines.actions.destroy_confirm') } diff --git a/app/helpers/links_helper.rb b/app/helpers/links_helper.rb index b9923db2f..683b66a52 100644 --- a/app/helpers/links_helper.rb +++ b/app/helpers/links_helper.rb @@ -1,5 +1,5 @@ module LinksHelper - def destroy_link_content - content_tag(:span, nil, class: 'fa fa-trash') + t('actions.destroy') + def destroy_link_content(translation_key = 'actions.destroy') + content_tag(:span, nil, class: 'fa fa-trash') + t(translation_key) end end diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index dbc019e72..6f75432e1 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -7,17 +7,12 @@ / Below is secundary actions & optional contents .row .col-lg-12.text-right.mb-sm - = link_to t('lines.actions.show_network'), [@line_referential, @line.network], class: 'btn btn-primary' - = link_to t('lines.actions.show_company'), [@line_referential, @line.company], class: 'btn btn-primary' - - - if policy(Chouette::Line).create? && @line_referential.organisations.include?(current_organisation) - = link_to t('lines.actions.new'), new_line_referential_line_path(@line_referential), class: 'btn btn-primary' - - if false && policy(@line).update? - = link_to t('lines.actions.edit'), edit_line_referential_line_path(@line_referential, @line), class: 'btn btn-primary' - - if policy(@line).destroy? - = link_to line_referential_line_path(@line_referential, @line), method: :delete, data: {confirm: t('lines.actions.destroy_confirm')}, class: 'btn btn-primary' do - span.fa.fa-trash - span = t('lines.actions.destroy') + - @line.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 |