From 9de20c519a60443157ed277a1c68b46f00229598 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 19 Jun 2017 17:29:32 +0200 Subject: TimeTables#show: Render header buttons from #action_links This enables us to reuse these links in other parts of the application. Get the links from `TimeTableDecorator#action_links`. Refs #3479 --- app/controllers/time_tables_controller.rb | 4 ++++ app/views/time_tables/show.html.slim | 21 ++++++--------------- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'app') diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 5c4552afb..3704f2885 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -14,6 +14,10 @@ class TimeTablesController < ChouetteController @year = params[:year] ? params[:year].to_i : Date.today.cwyear @time_table_combination = TimeTableCombination.new show! do + @time_table = @time_table.decorate(context: { + referential: @referential + }) + build_breadcrumb :show end end diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 2e71ebb9e..f596fd480 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -10,21 +10,12 @@ / Below is secundary actions & optional contents (filters, ...) .row.mb-sm .col-lg-12.text-right - / - if policy(@time_table).create? && @referential.organisation == current_organisation - / = link_to t('time_tables.actions.new'), new_referential_time_table_path(@referential), class: 'btn btn-primary' - - if @time_table.calendar - = link_to t('actions.actualize'), actualize_referential_time_table_path(@referential, @time_table), method: :post, class: 'btn btn-primary' - - /- if policy(@time_table).create? && @referential.organisation == current_organisation - = link_to t('actions.combine'), new_referential_time_table_time_table_combination_path(@referential, @time_table), class: 'btn btn-primary' - - - if policy(@time_table).duplicate? - = link_to t('actions.duplicate'), duplicate_referential_time_table_path(@referential, @time_table), class: 'btn btn-primary' - - - if policy(@time_table).destroy? - = link_to referential_time_table_path(@referential, @time_table), method: :delete, data: {confirm: t('time_tables.actions.destroy_confirm')}, class: 'btn btn-primary' do - span.fa.fa-trash - span = t('actions.destroy') + - @time_table.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