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
|
def update
|
||||||
if @process.update(process_params)
|
if @process.update(process_params)
|
||||||
|
set_tag_list
|
||||||
|
|
||||||
link = legislation_process_path(@process).html_safe
|
link = legislation_process_path(@process).html_safe
|
||||||
redirect_to :back, notice: t('admin.legislation.processes.update.notice', link: link)
|
redirect_to :back, notice: t('admin.legislation.processes.update.notice', link: link)
|
||||||
else
|
else
|
||||||
@@ -56,7 +58,13 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
|||||||
:draft_publication_enabled,
|
:draft_publication_enabled,
|
||||||
:result_publication_enabled,
|
:result_publication_enabled,
|
||||||
:published,
|
:published,
|
||||||
:proposals_description
|
:proposals_description,
|
||||||
|
:custom_list
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_tag_list
|
||||||
|
@process.set_tag_list_on(:customs, process_params[:custom_list])
|
||||||
|
@process.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ module TagsHelper
|
|||||||
proposal_path(taggable)
|
proposal_path(taggable)
|
||||||
when 'budget/investment'
|
when 'budget/investment'
|
||||||
budget_investment_path(taggable.budget_id, taggable)
|
budget_investment_path(taggable.budget_id, taggable)
|
||||||
|
when 'legislation/proposal'
|
||||||
|
legislation_process_proposal_path(@process, taggable)
|
||||||
else
|
else
|
||||||
'#'
|
'#'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
class Legislation::Process < ActiveRecord::Base
|
class Legislation::Process < ActiveRecord::Base
|
||||||
acts_as_paranoid column: :hidden_at
|
|
||||||
include ActsAsParanoidAliases
|
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
|
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</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="row">
|
||||||
<div class="actions small-12 medium-3 column legislation-process-save">
|
<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")) %>
|
<%= 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">
|
<div id="category_tags" class="tags">
|
||||||
<%= f.label :category_tag_list, t("proposals.form.tag_category_label") %>
|
<%= f.label :category_tag_list, t("proposals.form.tag_category_label") %>
|
||||||
<% @categories.each do |tag| %>
|
<% @process.tag_list_on(:customs).each do |tag| %>
|
||||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
<a class="js-add-tag-link"><%= tag %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -936,9 +936,11 @@ ActiveRecord::Schema.define(version: 20170918231410) do
|
|||||||
t.string "kind"
|
t.string "kind"
|
||||||
t.integer "budget/investments_count", default: 0
|
t.integer "budget/investments_count", default: 0
|
||||||
t.integer "legislation/proposals_count", default: 0
|
t.integer "legislation/proposals_count", default: 0
|
||||||
|
t.integer "legislation/processes_count", default: 0
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree
|
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", ["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", ["name"], name: "index_tags_on_name", unique: true, using: :btree
|
||||||
add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree
|
add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree
|
||||||
|
|||||||
Reference in New Issue
Block a user