Allow enable 'hide_money' check on admin budget form
Add new 'hide_money' field to admin budget form. Only display new field 'hide_money' when voting style is 'approval'
This commit is contained in:
@@ -110,6 +110,7 @@
|
|||||||
//= require cookies
|
//= require cookies
|
||||||
//= require columns_selector
|
//= require columns_selector
|
||||||
//= require budget_edit_associations
|
//= require budget_edit_associations
|
||||||
|
//= require budget_hide_money
|
||||||
//= require datepicker
|
//= require datepicker
|
||||||
//= require_tree ./admin
|
//= require_tree ./admin
|
||||||
//= require_tree ./sdg
|
//= require_tree ./sdg
|
||||||
@@ -166,6 +167,7 @@ var initialize_modules = function() {
|
|||||||
App.AdminBudgetsWizardCreationStep.initialize();
|
App.AdminBudgetsWizardCreationStep.initialize();
|
||||||
App.AdminMachineLearningScripts.initialize();
|
App.AdminMachineLearningScripts.initialize();
|
||||||
App.BudgetEditAssociations.initialize();
|
App.BudgetEditAssociations.initialize();
|
||||||
|
App.BudgetHideMoney.initialize();
|
||||||
App.Datepicker.initialize();
|
App.Datepicker.initialize();
|
||||||
App.SDGRelatedListSelector.initialize();
|
App.SDGRelatedListSelector.initialize();
|
||||||
App.SDGManagementRelationSearch.initialize();
|
App.SDGManagementRelationSearch.initialize();
|
||||||
|
|||||||
17
app/assets/javascripts/budget_hide_money.js
Normal file
17
app/assets/javascripts/budget_hide_money.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
(function() {
|
||||||
|
"use strict";
|
||||||
|
App.BudgetHideMoney = {
|
||||||
|
initialize: function() {
|
||||||
|
$("#budget_voting_style").on({
|
||||||
|
change: function() {
|
||||||
|
if ($(this).val() === "approval") {
|
||||||
|
$("#hide_money").removeClass("hide");
|
||||||
|
} else {
|
||||||
|
$("#budget_hide_money").prop("checked", false);
|
||||||
|
$("#hide_money").addClass("hide");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}).call(this);
|
||||||
@@ -39,6 +39,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="hide_money" class="row expanded <%= hide_money_style %>">
|
||||||
|
<div class="small-12 column">
|
||||||
|
<p class="form-label"><%= t("admin.budgets.edit.hide_money") %></p>
|
||||||
|
<p class="help-text"><%= t("admin.budgets.edit.hide_money_help_text") %></p>
|
||||||
|
<%= f.check_box :hide_money %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% unless wizard? %>
|
<% unless wizard? %>
|
||||||
<div class="small-12 medium-6 column">
|
<div class="small-12 medium-6 column">
|
||||||
<%= f.select :phase, phases_select_options %>
|
<%= f.select :phase, phases_select_options %>
|
||||||
|
|||||||
@@ -34,4 +34,8 @@ class Admin::Budgets::FormComponent < ApplicationComponent
|
|||||||
def valuators
|
def valuators
|
||||||
@valuators ||= Valuator.includes(:user).order(description: :asc).order("users.email ASC")
|
@valuators ||= Valuator.includes(:user).order(description: :asc).order("users.email ASC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hide_money_style
|
||||||
|
"hide" if budget.voting_style == "knapsack"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class Admin::BudgetsController < Admin::BaseController
|
|||||||
valid_attributes = [:phase,
|
valid_attributes = [:phase,
|
||||||
:currency_symbol,
|
:currency_symbol,
|
||||||
:voting_style,
|
:voting_style,
|
||||||
|
:hide_money,
|
||||||
administrator_ids: [],
|
administrator_ids: [],
|
||||||
valuator_ids: [],
|
valuator_ids: [],
|
||||||
image_attributes: image_attributes
|
image_attributes: image_attributes
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Admin::BudgetsWizard::BudgetsController < Admin::BudgetsWizard::BaseContro
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allowed_params
|
def allowed_params
|
||||||
valid_attributes = [:currency_symbol, :voting_style, administrator_ids: [],
|
valid_attributes = [:currency_symbol, :voting_style, :hide_money, administrator_ids: [],
|
||||||
valuator_ids: [], image_attributes: image_attributes]
|
valuator_ids: [], image_attributes: image_attributes]
|
||||||
|
|
||||||
valid_attributes + [translation_params(Budget)]
|
valid_attributes + [translation_params(Budget)]
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ en:
|
|||||||
voting_style: "Final voting style"
|
voting_style: "Final voting style"
|
||||||
voting_style_knapsack: "Knapsack"
|
voting_style_knapsack: "Knapsack"
|
||||||
voting_style_approval: "Approval"
|
voting_style_approval: "Approval"
|
||||||
|
hide_money: "Hide money amount for this budget"
|
||||||
budget/translation:
|
budget/translation:
|
||||||
main_link_text: "Text on the link"
|
main_link_text: "Text on the link"
|
||||||
main_link_url: "The link takes you to (add a link)"
|
main_link_url: "The link takes you to (add a link)"
|
||||||
|
|||||||
@@ -136,6 +136,8 @@ en:
|
|||||||
info:
|
info:
|
||||||
budget_settings: "General participatory budget settings"
|
budget_settings: "General participatory budget settings"
|
||||||
staff_settings: "Administrators and Valuators assigned to the budget"
|
staff_settings: "Administrators and Valuators assigned to the budget"
|
||||||
|
hide_money: "Hide money"
|
||||||
|
hide_money_help_text: "If this option is checked, all fields showing the amount of money will be hidden throughout the process."
|
||||||
destroy:
|
destroy:
|
||||||
success_notice: Budget deleted successfully
|
success_notice: Budget deleted successfully
|
||||||
unable_notice: You cannot delete a budget that has associated investments
|
unable_notice: You cannot delete a budget that has associated investments
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ es:
|
|||||||
voting_style: "Estilo de la votación final"
|
voting_style: "Estilo de la votación final"
|
||||||
voting_style_knapsack: Bolsa de dinero
|
voting_style_knapsack: Bolsa de dinero
|
||||||
voting_style_approval: Por aprobación
|
voting_style_approval: Por aprobación
|
||||||
|
hide_money: "Ocultar la cantidad de dinero para este presupuesto"
|
||||||
budget/translation:
|
budget/translation:
|
||||||
main_link_text: "Texto del enlace"
|
main_link_text: "Texto del enlace"
|
||||||
main_link_url: "El enlace te lleva a (añade un enlace)"
|
main_link_url: "El enlace te lleva a (añade un enlace)"
|
||||||
|
|||||||
@@ -136,6 +136,8 @@ es:
|
|||||||
info:
|
info:
|
||||||
budget_settings: "Configuración genérica del presupuesto participativo"
|
budget_settings: "Configuración genérica del presupuesto participativo"
|
||||||
staff_settings: "Administradores y Evaluadores asigandos al presupuesto"
|
staff_settings: "Administradores y Evaluadores asigandos al presupuesto"
|
||||||
|
hide_money: "Ocultar dinero"
|
||||||
|
hide_money_help_text: "Si esta opción está marcada, todos los campos que muestran la cantidad de dinero se ocultarán durante todo el proceso."
|
||||||
destroy:
|
destroy:
|
||||||
success_notice: Presupuesto eliminado correctamente
|
success_notice: Presupuesto eliminado correctamente
|
||||||
unable_notice: No se puede eliminar un presupuesto con proyectos asociados
|
unable_notice: No se puede eliminar un presupuesto con proyectos asociados
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ FactoryBot.define do
|
|||||||
trait :with_winner do
|
trait :with_winner do
|
||||||
after(:create) { |budget| create(:budget_investment, :winner, budget: budget) }
|
after(:create) { |budget| create(:budget_investment, :winner, budget: budget) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :hide_money do
|
||||||
|
hide_money { true }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :budget_group, class: "Budget::Group" do
|
factory :budget_group, class: "Budget::Group" do
|
||||||
|
|||||||
@@ -94,6 +94,76 @@ describe "Admin budgets", :admin do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "Create" do
|
||||||
|
scenario "Create budget - Approval voting with hide money" do
|
||||||
|
visit admin_budgets_path
|
||||||
|
click_button "Create new budget"
|
||||||
|
click_link "Create multiple headings budget"
|
||||||
|
|
||||||
|
expect(page).to have_select("Final voting style", selected: "Knapsack")
|
||||||
|
expect(page).not_to have_selector("#budget_hide_money")
|
||||||
|
|
||||||
|
fill_in "Name", with: "Budget hide money"
|
||||||
|
select "Approval", from: "Final voting style"
|
||||||
|
check "Hide money amount for this budget"
|
||||||
|
click_button "Continue to groups"
|
||||||
|
|
||||||
|
expect(page).to have_content "New participatory budget created successfully!"
|
||||||
|
expect(page).to have_content "Budget hide money"
|
||||||
|
|
||||||
|
click_link "Go back to edit budget"
|
||||||
|
|
||||||
|
expect(page).to have_select("Final voting style", selected: "Approval")
|
||||||
|
expect(page).to have_field "Hide money amount for this budget", checked: true
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Create a budget with hide money by steps" do
|
||||||
|
visit admin_budgets_path
|
||||||
|
click_button "Create new budget"
|
||||||
|
click_link "Create multiple headings budget"
|
||||||
|
|
||||||
|
fill_in "Name", with: "Multiple headings budget with hide money"
|
||||||
|
select "Approval", from: "Final voting style"
|
||||||
|
check "Hide money amount for this budget"
|
||||||
|
click_button "Continue to groups"
|
||||||
|
|
||||||
|
expect(page).to have_content "New participatory budget created successfully!"
|
||||||
|
expect(page).to have_content "There are no groups."
|
||||||
|
|
||||||
|
click_button "Add new group"
|
||||||
|
fill_in "Group name", with: "All city"
|
||||||
|
click_button "Create new group"
|
||||||
|
|
||||||
|
expect(page).to have_content "Group created successfully!"
|
||||||
|
|
||||||
|
click_button "Add new group"
|
||||||
|
fill_in "Group name", with: "District A"
|
||||||
|
click_button "Create new group"
|
||||||
|
|
||||||
|
expect(page).to have_content "Group created successfully!"
|
||||||
|
|
||||||
|
within("table") do
|
||||||
|
expect(page).to have_content "All city"
|
||||||
|
expect(page).to have_content "District A"
|
||||||
|
end
|
||||||
|
expect(page).not_to have_content "There are no groups."
|
||||||
|
|
||||||
|
click_link "Continue to headings"
|
||||||
|
|
||||||
|
expect(page).to have_content "Showing headings from the All city group."
|
||||||
|
expect(page).to have_link "Manage headings from the District A group."
|
||||||
|
|
||||||
|
click_button "Add new heading"
|
||||||
|
fill_in "Heading name", with: "All city"
|
||||||
|
click_button "Create new heading"
|
||||||
|
|
||||||
|
expect(page).to have_content "Heading created successfully!"
|
||||||
|
expect(page).to have_content "All city"
|
||||||
|
expect(page).to have_link "Continue to phases"
|
||||||
|
expect(page).not_to have_content "There are no headings."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "Publish" do
|
context "Publish" do
|
||||||
let(:budget) { create(:budget, :drafting) }
|
let(:budget) { create(:budget, :drafting) }
|
||||||
|
|
||||||
@@ -260,6 +330,76 @@ describe "Admin budgets", :admin do
|
|||||||
|
|
||||||
expect(page).to have_content "New English Name"
|
expect(page).to have_content "New English Name"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Hide money active" do
|
||||||
|
budget_hide_money = create(:budget, :approval, :hide_money)
|
||||||
|
group = create(:budget_group, budget: budget_hide_money)
|
||||||
|
heading = create(:budget_heading, group: group)
|
||||||
|
heading_2 = create(:budget_heading, group: group)
|
||||||
|
|
||||||
|
visit admin_budget_path(budget_hide_money)
|
||||||
|
|
||||||
|
expect(page).to have_content heading.name
|
||||||
|
expect(page).to have_content heading_2.name
|
||||||
|
|
||||||
|
visit edit_admin_budget_path(budget_hide_money)
|
||||||
|
|
||||||
|
expect(page).to have_field "Hide money amount for this budget", checked: true
|
||||||
|
expect(page).to have_select("Final voting style", selected: "Approval")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Change voting style uncheck hide money" do
|
||||||
|
budget_hide_money = create(:budget, :approval, :hide_money)
|
||||||
|
hide_money_help_text = "If this option is checked, all fields showing the amount of money "\
|
||||||
|
"will be hidden throughout the process."
|
||||||
|
|
||||||
|
visit edit_admin_budget_path(budget_hide_money)
|
||||||
|
|
||||||
|
expect(page).to have_field "Hide money amount for this budget", checked: true
|
||||||
|
expect(page).to have_content hide_money_help_text
|
||||||
|
|
||||||
|
select "Knapsack", from: "Final voting style"
|
||||||
|
|
||||||
|
expect(page).not_to have_field "Hide money amount for this budget"
|
||||||
|
expect(page).not_to have_content hide_money_help_text
|
||||||
|
|
||||||
|
select "Approval", from: "Final voting style"
|
||||||
|
|
||||||
|
expect(page).to have_field "Hide money amount for this budget", checked: false
|
||||||
|
expect(page).to have_content hide_money_help_text
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Edit knapsack budget do not show hide money info" do
|
||||||
|
budget = create(:budget, :knapsack)
|
||||||
|
hide_money_help_text = "If this option is checked, all fields showing the amount of money "\
|
||||||
|
"will be hidden throughout the process."
|
||||||
|
|
||||||
|
visit edit_admin_budget_path(budget)
|
||||||
|
|
||||||
|
expect(page).not_to have_field "Hide money amount for this budget"
|
||||||
|
expect(page).not_to have_content hide_money_help_text
|
||||||
|
|
||||||
|
select "Approval", from: "Final voting style"
|
||||||
|
|
||||||
|
expect(page).to have_field "Hide money amount for this budget", checked: false
|
||||||
|
expect(page).to have_content hide_money_help_text
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Edit approval budget show hide money info" do
|
||||||
|
budget = create(:budget, :approval)
|
||||||
|
hide_money_help_text = "If this option is checked, all fields showing the amount of money "\
|
||||||
|
"will be hidden throughout the process."
|
||||||
|
|
||||||
|
visit edit_admin_budget_path(budget)
|
||||||
|
|
||||||
|
expect(page).to have_field "Hide money amount for this budget", checked: false
|
||||||
|
expect(page).to have_content hide_money_help_text
|
||||||
|
|
||||||
|
select "Knapsack", from: "Final voting style"
|
||||||
|
|
||||||
|
expect(page).not_to have_field "Hide money amount for this budget"
|
||||||
|
expect(page).not_to have_content hide_money_help_text
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Update" do
|
context "Update" do
|
||||||
|
|||||||
Reference in New Issue
Block a user