From ee2f970e03f91c8e53b31e4af38202ac54bc2931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 10 Jan 2019 15:05:04 +0100 Subject: [PATCH] Fix sorting links for non-English languages We were assuming the translation and the column name were related. --- app/helpers/budget_investments_helper.rb | 9 ++++----- app/views/admin/budget_investments/_investments.html.erb | 6 +++--- config/locales/en/admin.yml | 5 ----- config/locales/es/admin.yml | 5 ----- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/helpers/budget_investments_helper.rb b/app/helpers/budget_investments_helper.rb index e81931c43..810856057 100644 --- a/app/helpers/budget_investments_helper.rb +++ b/app/helpers/budget_investments_helper.rb @@ -4,23 +4,22 @@ module BudgetInvestmentsHelper end def link_to_investments_sorted_by(column) - sort_by = column.downcase current_direction = params[:direction].downcase if params[:direction] direction = set_direction(current_direction) - icon = set_sorting_icon(direction, sort_by) + icon = set_sorting_icon(direction, column) - translation = t("admin.budget_investments.index.sort_by.#{sort_by}") + translation = t("admin.budget_investments.index.list.#{column}") link_to( "#{translation} ".html_safe, - admin_budget_budget_investments_path(sort_by: sort_by, direction: direction) + admin_budget_budget_investments_path(sort_by: column, direction: direction) ) end def set_sorting_icon(direction, sort_by) icon = direction == "desc" ? "icon-arrow-top" : "icon-arrow-down" - icon = sort_by == params[:sort_by] ? icon : "" + icon = sort_by.to_s == params[:sort_by] ? icon : "" end def set_direction(current_direction) diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index f7aea9c33..1bae41ee1 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -26,9 +26,9 @@ - - - + + +
<%= link_to_investments_sorted_by t("admin.budget_investments.index.list.id") %><%= link_to_investments_sorted_by t("admin.budget_investments.index.list.title") %><%= link_to_investments_sorted_by t("admin.budget_investments.index.list.supports") %><%= link_to_investments_sorted_by :id %><%= link_to_investments_sorted_by :title %><%= link_to_investments_sorted_by :supports %> <%= t("admin.budget_investments.index.list.admin") %> <%= t("admin.budget_investments.index.list.valuation_group") %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index edff8acf7..c7f6fb984 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -176,11 +176,6 @@ en: tags_filter_all: All tags advanced_filters: Advanced filters placeholder: Search projects - sort_by: - placeholder: Sort by - id: ID - title: Title - supports: Supports filters: all: All without_admin: Without assigned admin diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index c099bce58..ad829b724 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -176,11 +176,6 @@ es: tags_filter_all: Todas las etiquetas advanced_filters: Filtros avanzados placeholder: Buscar proyectos - sort_by: - placeholder: Ordenar por - id: ID - title: Título - supports: Apoyos filters: all: Todos without_admin: Sin administrador