From 10d7a1d89bf3a930c3f979d0d311bac94171dbf0 Mon Sep 17 00:00:00 2001 From: Manuel Ortega Date: Tue, 17 Oct 2017 14:37:27 +0200 Subject: [PATCH 1/3] Added investment's user generated tags to admin show and sort to the valuation tags --- .../admin/budget_investments/_written_by_author.html.erb | 5 +++++ app/views/admin/budget_investments/show.html.erb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/admin/budget_investments/_written_by_author.html.erb b/app/views/admin/budget_investments/_written_by_author.html.erb index a913aff00..467d81481 100644 --- a/app/views/admin/budget_investments/_written_by_author.html.erb +++ b/app/views/admin/budget_investments/_written_by_author.html.erb @@ -56,3 +56,8 @@ <% end %> <%= safe_html_with_links @investment.description %> + +

+ <%= t("admin.budget_investments.show.tags") %> del usuario: + <%= @investment.tag_list.sort.join(', ') %> +

diff --git a/app/views/admin/budget_investments/show.html.erb b/app/views/admin/budget_investments/show.html.erb index f220c0955..5fa35a1fa 100644 --- a/app/views/admin/budget_investments/show.html.erb +++ b/app/views/admin/budget_investments/show.html.erb @@ -19,7 +19,7 @@

<%= t("admin.budget_investments.show.tags") %>: - <%= @investment.tags_on(:valuation).pluck(:name).join(', ') %> + <%= @investment.tags_on(:valuation).pluck(:name).sort.join(', ') %>

From 12ac758e8ef58742408a2eb9787334e5c19e7f96 Mon Sep 17 00:00:00 2001 From: Manuel Ortega Date: Tue, 17 Oct 2017 18:11:29 +0200 Subject: [PATCH 2/3] Added investment's user generated tags to admin interface form --- .../admin/budget_investments_controller.rb | 2 +- .../admin/budget_investments/edit.html.erb | 9 ++++++- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 1 + .../features/admin/budget_investments_spec.rb | 27 +++++++++++++++---- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb index dd10930fb..4b6bd6b3a 100644 --- a/app/controllers/admin/budget_investments_controller.rb +++ b/app/controllers/admin/budget_investments_controller.rb @@ -51,7 +51,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController def budget_investment_params params.require(:budget_investment) - .permit(:title, :description, :external_url, :heading_id, :administrator_id, :valuation_tag_list, :incompatible, + .permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list, :valuation_tag_list, :incompatible, :selected, valuator_ids: []) end diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index c33039021..ab843cf24 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -18,6 +18,13 @@ <%= f.cktext_area :description, maxlength: Budget::Investment.description_max_length, ckeditor: { language: I18n.locale } %> +

+ <%= f.label :tag_list, t("admin.budget_investments.edit.user_tags") %> + <%= f.text_field :tag_list, + value: @investment.tag_list.sort.join(','), + label: false %> +
+
<%= f.text_field :external_url %>
@@ -39,7 +46,7 @@
- <%= f.label :tag_list, t("admin.budget_investments.edit.tags") %> + <%= f.label :valuation_tag_list, t("admin.budget_investments.edit.tags") %>
<% @tags.each do |tag| %> <%= tag.name %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 87bbb6685..398ce6421 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -181,6 +181,7 @@ en: assigned_valuators: Valuators select_heading: Select heading submit_button: Update + user_tags: User assigned tags tags: Tags tags_placeholder: "Write the tags you want separated by commas (,)" undefined: Undefined diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index d1a24b314..e3a52977d 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -181,6 +181,7 @@ es: assigned_valuators: Evaluadores select_heading: Seleccionar partida submit_button: Actualizar + user_tags: Etiquetas asignadas por el usuario tags: Etiquetas tags_placeholder: "Escribe las etiquetas que desees separadas por comas (,)" undefined: Sin definir diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 7252e2660..1ad89e6aa 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -421,20 +421,37 @@ feature 'Admin budget investments' do end end - scenario "Only displays valuation tags" do + scenario "Changes valuation and user generated tags" do budget_investment = create(:budget_investment, tag_list: 'Park') budget_investment.set_tag_list_on(:valuation, 'Education') budget_investment.save visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment) - expect(page).to have_content "Education" - expect(page).to_not have_content "Park" + within("#user-tags") do + expect(page).to_not have_content "Education" + expect(page).to have_content "Park" + end click_link 'Edit classification' - expect(page).to have_content "Education" - expect(page).to_not have_content "Park" + fill_in 'budget_investment_tag_list', with: 'Park, Trees' + fill_in 'budget_investment_valuation_tag_list', with: 'Education, Environment' + click_button 'Update' + + visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment) + + within("#user-tags") do + expect(page).to_not have_content "Education" + expect(page).to_not have_content "Environment" + expect(page).to have_content "Park, Trees" + end + + within("#tags") do + expect(page).to have_content "Education, Environment" + expect(page).to_not have_content "Park" + expect(page).to_not have_content "Trees" + end end scenario "Maintains user tags" do From 928186045a9623878c3ed3a73871dd07bc4a7a9d Mon Sep 17 00:00:00 2001 From: Manuel Ortega Date: Sun, 22 Oct 2017 14:25:15 +0200 Subject: [PATCH 3/3] Moved 'del usuario' text form view to locale files --- app/views/admin/budget_investments/_written_by_author.html.erb | 2 +- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/admin/budget_investments/_written_by_author.html.erb b/app/views/admin/budget_investments/_written_by_author.html.erb index 467d81481..8cf2eca57 100644 --- a/app/views/admin/budget_investments/_written_by_author.html.erb +++ b/app/views/admin/budget_investments/_written_by_author.html.erb @@ -58,6 +58,6 @@ <%= safe_html_with_links @investment.description %>

- <%= t("admin.budget_investments.show.tags") %> del usuario: + <%= t("admin.budget_investments.show.user_tags") %>: <%= @investment.tag_list.sort.join(', ') %>

diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 398ce6421..38365f777 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -157,6 +157,7 @@ en: dossier: Dossier edit_dossier: Edit dossier tags: Tags + user_tags: User tags undefined: Undefined milestone: Milestone new_milestone: Create new milestone diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index e3a52977d..19563a880 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -157,6 +157,7 @@ es: dossier: Informe edit_dossier: Editar informe tags: Etiquetas + user_tags: Etiquetas del usuario undefined: Sin definir milestone: Seguimiento new_milestone: Crear nuevo hito @@ -181,7 +182,7 @@ es: assigned_valuators: Evaluadores select_heading: Seleccionar partida submit_button: Actualizar - user_tags: Etiquetas asignadas por el usuario + user_tags: Etiquetas asignadas por el usuario tags: Etiquetas tags_placeholder: "Escribe las etiquetas que desees separadas por comas (,)" undefined: Sin definir