From af04ac4350588ae08e03035de9530cd935ea082a Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Mon, 26 Feb 2018 21:15:39 +0000 Subject: [PATCH] add cancel button to new/edit log time page --- app/helpers/application_helper.rb | 5 +++++ app/helpers/timelog_helper.rb | 6 ++++++ app/views/timelog/edit.html.erb | 1 + app/views/timelog/new.html.erb | 1 + 4 files changed, 13 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dd152f3..c2d61fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1257,6 +1257,11 @@ module ApplicationHelper hidden_field_tag('back_url', url, :id => nil) unless url.blank? end + def render_cancel_button_tag(fallback_url) + url = back_url.blank? ? fallback_url : back_url + link_to l(:button_cancel), url + end + def check_all_links(form_name) link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + " | ".html_safe + diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 89ed996..7248e8e 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -114,4 +114,10 @@ module TimelogHelper end end end + + def render_cancel_button_tag_for_time_entry(project) + fallback_path = project ? project_time_entries_path(project) : time_entries_path + render_cancel_button_tag(fallback_path) + end + end diff --git a/app/views/timelog/edit.html.erb b/app/views/timelog/edit.html.erb index 89a60b7..f7daa26 100644 --- a/app/views/timelog/edit.html.erb +++ b/app/views/timelog/edit.html.erb @@ -3,4 +3,5 @@ <%= labelled_form_for @time_entry, :url => time_entry_path(@time_entry), :html => {:multipart => true} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <%= submit_tag l(:button_save) %> + <%= render_cancel_button_tag_for_time_entry(@project) %> <% end %> diff --git a/app/views/timelog/new.html.erb b/app/views/timelog/new.html.erb index 593eb2b..719e79d 100644 --- a/app/views/timelog/new.html.erb +++ b/app/views/timelog/new.html.erb @@ -4,4 +4,5 @@ <%= render :partial => 'form', :locals => {:f => f} %> <%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create_and_continue), :name => 'continue' %> + <%= render_cancel_button_tag_for_time_entry(@project) %> <% end %> -- 2.1.4