diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss
index e5070af3b..a8d81a12d 100644
--- a/app/assets/stylesheets/admin.scss
+++ b/app/assets/stylesheets/admin.scss
@@ -1165,6 +1165,17 @@ table {
}
}
+.max-headings-label {
+ color: $text-medium;
+ font-size: $small-font-size;
+ margin-left: $line-height / 2;
+}
+
+.current-of-max-headings {
+ color: #000;
+ font-weight: bold;
+}
+
// 11. Newsletters
// -----------------
diff --git a/app/views/admin/budget_groups/update.js.erb b/app/views/admin/budget_groups/update.js.erb
index 5a5a244df..c4f9774ba 100644
--- a/app/views/admin/budget_groups/update.js.erb
+++ b/app/views/admin/budget_groups/update.js.erb
@@ -2,5 +2,6 @@
$("#group-form-<%= @group.id %>").html('<%= j render("admin/budgets/group_form", group: @group, budget: @group.budget, button_title: t("admin.budgets.form.submit"), id: "group-form-#{@group.id}", css_class: "group-toggle-#{@group.id}" ) %>');
<% else %>
$("#group-name-<%= @group.id %>").html('<%= @group.name %>')
+ $("#max-heading-label-<%=@group.id%>").html('<%= j render("admin/budgets/max_headings_label", current: @group.max_votable_headings, max: @group.headings.count, group: @group) %>')
$(".group-toggle-<%= @group.id %>").toggle()
<% end %>
diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb
index 360fd75a7..f38d34a9d 100644
--- a/app/views/admin/budgets/_group.html.erb
+++ b/app/views/admin/budgets/_group.html.erb
@@ -3,6 +3,9 @@
|
<%= content_tag(:span, group.name, class:"group-toggle-#{group.id}", id:"group-name-#{group.id}") %>
+
+ <%= content_tag(:span, (render 'admin/budgets/max_headings_label', current: group.max_votable_headings, max: group.headings.count, group: group if group.max_votable_headings), class:"max-headings-label group-toggle-#{group.id}", id:"max-heading-label-#{group.id}") %>
+
<%= render 'admin/budgets/group_form', budget: @budget, group: group, id: "group-form-#{group.id}", button_title: t("admin.budgets.form.submit"), css_class: "group-toggle-#{group.id}" %>
<%= link_to t("admin.budgets.form.edit_group"), "#", class: "button float-right js-toggle-link hollow", data: { "toggle-selector" => ".group-toggle-#{group.id}" } %>
<%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %>
diff --git a/app/views/admin/budgets/_max_headings_label.html.erb b/app/views/admin/budgets/_max_headings_label.html.erb
new file mode 100644
index 000000000..61bf98dc7
--- /dev/null
+++ b/app/views/admin/budgets/_max_headings_label.html.erb
@@ -0,0 +1,5 @@
+<%= t("admin.budgets.form.max_votable_headings")%>
+<%= content_tag(:strong,
+ t('admin.budgets.form.current_of_max_headings', current: current, max: max ),
+ class:"current-of-max-headings") %>
+
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index 34baa743b..ac23897df 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -127,7 +127,8 @@ en:
table_amount: Amount
table_population: Population
population_info: "Budget Heading population field is used for Statistic purposes at the end of the Budget to show for each Heading that represents an area with population what percentage voted. The field is optional so you can leave it empty if it doesn't apply."
- max_votable_headings: "Maxium number of headings in which a user can vote"
+ max_votable_headings: "Maximum number of headings in which a user can vote"
+ current_of_max_headings: "%{current} of %{max}"
winners:
calculate: Calculate Winner Investments
calculated: Winners being calculated, it may take a minute.
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index e5a4b125c..8929f9e3b 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -128,6 +128,7 @@ es:
table_population: Población
population_info: "El campo población de las partidas presupuestarias se usa con fines estadísticos únicamente, con el objetivo de mostrar el porcentaje de votos habidos en cada partida que represente un área con población. Es un campo opcional, así que puedes dejarlo en blanco si no aplica."
max_votable_headings: "Máximo número de partidas en que un usuario puede votar"
+ current_of_max_headings: "%{current} de %{max}"
winners:
calculate: Calcular propuestas ganadoras
calculated: Calculando ganadoras, puede tardar un minuto.
diff --git a/spec/features/admin/budget_groups_spec.rb b/spec/features/admin/budget_groups_spec.rb
index 3c58a462e..d69867b8c 100644
--- a/spec/features/admin/budget_groups_spec.rb
+++ b/spec/features/admin/budget_groups_spec.rb
@@ -49,6 +49,8 @@ feature 'Admin can change the groups name' do
scenario "Defaults to 1 heading per group", :js do
visit admin_budget_path(group.budget)
+ expect(page).to have_content('Maximum number of headings in which a user can vote 1 of 3')
+
within("#budget_group_#{group.id}") do
click_link 'Edit group'
@@ -66,7 +68,7 @@ feature 'Admin can change the groups name' do
click_button 'Save group'
end
- visit admin_budget_path(group.budget)
+ expect(page).to have_content('Maximum number of headings in which a user can vote 2 of 3')
within("#budget_group_#{group.id}") do
click_link 'Edit group'
@@ -75,13 +77,13 @@ feature 'Admin can change the groups name' do
end
end
- scenario "Do not display maxium votable headings' select in new form", :js do
+ scenario "Do not display maximum votable headings' select in new form", :js do
visit admin_budget_path(group.budget)
click_link 'Add new group'
expect(page).to have_field('budget_group_name')
- expect(page).to_not have_field('budget_group_max_votable_headings')
+ expect(page).not_to have_field('budget_group_max_votable_headings')
end
end
|