Merge pull request #2761 from wairbut-m2c/backport_1384-add-max-heading-number-budget-group-list

Backport 1384 add max heading number budget group list
This commit is contained in:
Alberto
2018-07-20 13:17:38 +02:00
committed by GitHub
7 changed files with 28 additions and 4 deletions

View File

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

View File

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

View File

@@ -3,6 +3,9 @@
<tr>
<th colspan="4" class="with-button">
<%= 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" } %>

View File

@@ -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") %>

View File

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

View File

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

View File

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