Custom tags for Legislation Process available
Custom tags for Legislation Processes, editable in the admin section.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -28,6 +28,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= label_tag t('admin.legislation.proposals.form.header_information') %>
|
||||
<small><%= t('admin.legislation.proposals.form.header_information_description') %></small>
|
||||
</div>
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= 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"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="actions small-12 medium-3 column legislation-process-save">
|
||||
<%= f.submit(class: "button expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
|
||||
|
||||
@@ -63,8 +63,8 @@
|
||||
|
||||
<div id="category_tags" class="tags">
|
||||
<%= f.label :category_tag_list, t("proposals.form.tag_category_label") %>
|
||||
<% @categories.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% @process.tag_list_on(:customs).each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user