From d77355de0d74ef8b8a4a8377abb46583841774d1 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:23:14 +0200 Subject: [PATCH] Add population field to admin Budget Heading form and headings list table --- app/views/admin/budgets/_group.html.erb | 15 ++++++++++++++- ...621180611_add_population_to_budget_headings.rb | 2 +- db/schema.rb | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb index 6193fe287..8537fa477 100644 --- a/app/views/admin/budgets/_group.html.erb +++ b/app/views/admin/budgets/_group.html.erb @@ -1,7 +1,7 @@ - @@ -21,6 +21,7 @@ + @@ -45,6 +46,15 @@ placeholder: t("admin.budgets.form.amount") %> +
+
+ + <%= f.text_field :population, + label: false, + maxlength: 8, + placeholder: t("admin.budgets.form.population") %> +
+
<%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %> <% end %> @@ -60,6 +70,9 @@ + <% end %> diff --git a/db/migrate/20170621180611_add_population_to_budget_headings.rb b/db/migrate/20170621180611_add_population_to_budget_headings.rb index b17673397..fe723bc98 100644 --- a/db/migrate/20170621180611_add_population_to_budget_headings.rb +++ b/db/migrate/20170621180611_add_population_to_budget_headings.rb @@ -1,5 +1,5 @@ class AddPopulationToBudgetHeadings < ActiveRecord::Migration def change - add_column :budget_headings, :population, :integer, default: 0 + add_column :budget_headings, :population, :integer, default: nil end end diff --git a/db/schema.rb b/db/schema.rb index 64b81a350..dbdcc318d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -110,7 +110,7 @@ ActiveRecord::Schema.define(version: 20170621180611) do t.integer "group_id" t.string "name", limit: 50 t.integer "price", limit: 8 - t.integer "population", default: 0 + t.integer "population" end add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree
+ <%= group.name %> <%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %>
<%= t("admin.budgets.form.table_heading") %> <%= t("admin.budgets.form.table_amount") %><%= t("admin.budgets.form.table_population") %>
<%= heading.price %> + <%= heading.population %> +