Added investment's user generated tags to admin interface form

This commit is contained in:
Manuel Ortega
2017-10-17 18:11:29 +02:00
parent 10d7a1d89b
commit 12ac758e8e
5 changed files with 33 additions and 7 deletions

View File

@@ -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

View File

@@ -18,6 +18,13 @@
<%= f.cktext_area :description, maxlength: Budget::Investment.description_max_length, ckeditor: { language: I18n.locale } %>
</div>
<div class="small-12 column">
<%= f.label :tag_list, t("admin.budget_investments.edit.user_tags") %>
<%= f.text_field :tag_list,
value: @investment.tag_list.sort.join(','),
label: false %>
</div>
<div class="small-12 column">
<%= f.text_field :external_url %>
</div>
@@ -39,7 +46,7 @@
<div class="small-12 column">
<%= f.label :tag_list, t("admin.budget_investments.edit.tags") %>
<%= f.label :valuation_tag_list, t("admin.budget_investments.edit.tags") %>
<div class="tags">
<% @tags.each do |tag| %>
<a class="js-add-tag-link"><%= tag.name %></a>

View File

@@ -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

View File

@@ -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

View File

@@ -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