diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index f316d9b65..0e7555211 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -19,6 +19,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll def update if @process.update(process_params) + set_tag_list + link = legislation_process_path(@process).html_safe redirect_to :back, notice: t('admin.legislation.processes.update.notice', link: link) else @@ -56,7 +58,13 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll :draft_publication_enabled, :result_publication_enabled, :published, - :proposals_description + :proposals_description, + :custom_list ) end + + def set_tag_list + @process.set_tag_list_on(:customs, process_params[:custom_list]) + @process.save + end end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index eb34a64f2..b31f3167f 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -24,6 +24,8 @@ module TagsHelper proposal_path(taggable) when 'budget/investment' budget_investment_path(taggable.budget_id, taggable) + when 'legislation/proposal' + legislation_process_proposal_path(@process, taggable) else '#' end diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index 7e1e884cb..d6eed62db 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -1,6 +1,9 @@ class Legislation::Process < ActiveRecord::Base - acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases + include Taggable + + acts_as_paranoid column: :hidden_at + acts_as_taggable_on :customs PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze diff --git a/app/views/admin/legislation/proposals/_form.html.erb b/app/views/admin/legislation/proposals/_form.html.erb index 30f7f4950..343164587 100644 --- a/app/views/admin/legislation/proposals/_form.html.erb +++ b/app/views/admin/legislation/proposals/_form.html.erb @@ -28,6 +28,20 @@ +
+
+ <%= label_tag t('admin.legislation.proposals.form.header_information') %> + <%= t('admin.legislation.proposals.form.header_information_description') %> +
+
+ <%= f.text_field :custom_list, value: @process.tag_list_on(:customs).to_s, + label: false, + placeholder: t("proposals.form.tags_placeholder"), + class: 'js-tag-list', + aria: {describedby: "tag-list-help-text"} %> +
+
+
<%= f.submit(class: "button expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %> diff --git a/app/views/legislation/proposals/_form.html.erb b/app/views/legislation/proposals/_form.html.erb index dec8e56d2..798266ba1 100644 --- a/app/views/legislation/proposals/_form.html.erb +++ b/app/views/legislation/proposals/_form.html.erb @@ -63,8 +63,8 @@
<%= f.label :category_tag_list, t("proposals.form.tag_category_label") %> - <% @categories.each do |tag| %> - <%= tag.name %> + <% @process.tag_list_on(:customs).each do |tag| %> + <%= tag %> <% end %>
diff --git a/db/migrate/20170922101247_add_legislation_processes_count_to_tags.rb b/db/migrate/20170922101247_add_legislation_processes_count_to_tags.rb new file mode 100644 index 000000000..698a66af6 --- /dev/null +++ b/db/migrate/20170922101247_add_legislation_processes_count_to_tags.rb @@ -0,0 +1,6 @@ +class AddLegislationProcessesCountToTags < ActiveRecord::Migration + def change + add_column :tags, "legislation/processes_count", :integer, default: 0 + add_index :tags, "legislation/processes_count" + end +end diff --git a/db/schema.rb b/db/schema.rb index acacbf347..df544e28a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170918231410) do +ActiveRecord::Schema.define(version: 20170922101247) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -936,9 +936,11 @@ ActiveRecord::Schema.define(version: 20170918231410) do t.string "kind" t.integer "budget/investments_count", default: 0 t.integer "legislation/proposals_count", default: 0 + t.integer "legislation/processes_count", default: 0 end add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree + add_index "tags", ["legislation/processes_count"], name: "index_tags_on_legislation/processes_count", using: :btree add_index "tags", ["legislation/proposals_count"], name: "index_tags_on_legislation/proposals_count", using: :btree add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree