From dd268c18d7d21f07b38b08c5176721521df9e133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 11 Jan 2017 13:01:49 +0100 Subject: [PATCH 1/3] adds back_link_to helper --- app/helpers/application_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1f52f0eea..208ed3d3d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -40,4 +40,11 @@ module ApplicationHelper return false if authorable.blank? || user.blank? authorable.author_id == user.id end + + def back_link_to(destination_path) + destination = destination_path || :back + link_to destination, class: "back" do + "".html_safe + t("shared.back") + end + end end From b4b8e4f787ff46eedd740fde4a58cb2e74229795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 11 Jan 2017 13:02:46 +0100 Subject: [PATCH 2/3] fixes investment back link to avoid pointing to /new action --- app/views/budgets/investments/_investment_show.html.erb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index b4ba679e5..12f23fe87 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -2,10 +2,7 @@
- <%= link_to :back, class: "back" do %> - - <%= t("shared.back") %> - <% end %> + <%= back_link_to budget_investments_path(investment.budget) %>

<%= investment.title %>

@@ -35,7 +32,7 @@

<% end %> - <%= render 'shared/tags', taggable: @investment %> + <%= render 'shared/tags', taggable: investment %> <%= safe_html_with_links investment.description.html_safe %> From bdb55805a1066bbbcc48d28f8d901366cdb4261b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 11 Jan 2017 13:03:12 +0100 Subject: [PATCH 3/3] uses back_link_helper all around --- app/views/admin/budgets/edit.html.erb | 5 +---- app/views/admin/budgets/show.html.erb | 5 +---- app/views/budgets/groups/show.html.erb | 6 +----- app/views/budgets/investments/_header.html.erb | 10 ++-------- app/views/budgets/show.html.erb | 5 +---- app/views/valuation/budget_investments/show.html.erb | 5 +---- 6 files changed, 7 insertions(+), 29 deletions(-) diff --git a/app/views/admin/budgets/edit.html.erb b/app/views/admin/budgets/edit.html.erb index 34672bf7a..94da65a31 100644 --- a/app/views/admin/budgets/edit.html.erb +++ b/app/views/admin/budgets/edit.html.erb @@ -1,7 +1,4 @@ -<%= link_to admin_budgets_path do %> - - <%= t('shared.back') %> -<% end %> +<%= back_link_to admin_budgets_path %>
diff --git a/app/views/admin/budgets/show.html.erb b/app/views/admin/budgets/show.html.erb index 1f3292019..6c133ab9f 100644 --- a/app/views/admin/budgets/show.html.erb +++ b/app/views/admin/budgets/show.html.erb @@ -1,7 +1,4 @@ -<%= link_to admin_budgets_path do %> - - <%= t('shared.back') %> -<% end %> +<%= back_link_to admin_budgets_path %>

<%= @budget.name %>

diff --git a/app/views/budgets/groups/show.html.erb b/app/views/budgets/groups/show.html.erb index 6c2cf8e18..8bfbc21a1 100644 --- a/app/views/budgets/groups/show.html.erb +++ b/app/views/budgets/groups/show.html.erb @@ -1,11 +1,7 @@
- <%= link_to budget_path(@budget), class: "back" do %> - - <%= t('shared.back') %> - <% end %> - + <%= back_link_to budget_path(@budget) %>

<%= t("budgets.groups.show.title") %>

diff --git a/app/views/budgets/investments/_header.html.erb b/app/views/budgets/investments/_header.html.erb index 780370ac3..b58eea03c 100644 --- a/app/views/budgets/investments/_header.html.erb +++ b/app/views/budgets/investments/_header.html.erb @@ -4,10 +4,7 @@
- <%= link_to budget_group_path(@budget, @heading.group), class: "back" do %> - - <%= t("shared.back") %> - <% end %> + <%= back_link_to budget_group_path(@budget, @heading.group) %> <% if can? :show, @ballot %> <%= link_to t("budgets.investments.header.check_ballot"), @@ -52,10 +49,7 @@
- <%= link_to budget_path(@budget), class: "back" do %> - - <%= t("shared.back") %> - <% end %> + <%= back_link_to budget_path(@budget) %>

<%= t('budgets.investments.index.title') %>

diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index c43684363..499b7eb58 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -1,10 +1,7 @@
- <%= link_to budgets_path, class: "back" do %> - - <%= t('shared.back') %> - <% end %> + <%= back_link_to budgets_path %>

<%= @budget.name %>

diff --git a/app/views/valuation/budget_investments/show.html.erb b/app/views/valuation/budget_investments/show.html.erb index f0eaed2c8..c48cd52de 100644 --- a/app/views/valuation/budget_investments/show.html.erb +++ b/app/views/valuation/budget_investments/show.html.erb @@ -1,7 +1,4 @@ -<%= link_to valuation_budget_budget_investments_path do %> - - <%= t('shared.back') %> -<% end %> +<%= back_link_to valuation_budget_budget_investments_path %>

<%= t("valuation.budget_investments.show.title") %> <%= @investment.id %>

<%= @investment.title %>