Update legislation process translatable fields
This commit is contained in:
@@ -46,10 +46,6 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
|
||||
def allowed_params
|
||||
[
|
||||
:title,
|
||||
:summary,
|
||||
:description,
|
||||
:additional_info,
|
||||
:start_date,
|
||||
:end_date,
|
||||
:debate_start_date,
|
||||
@@ -67,7 +63,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
:result_publication_enabled,
|
||||
:published,
|
||||
:custom_list,
|
||||
*translation_params(::Legislation::Process),
|
||||
translation_params(::Legislation::Process),
|
||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
]
|
||||
end
|
||||
|
||||
@@ -14,6 +14,7 @@ class Legislation::Process < ActiveRecord::Base
|
||||
translates :description, touch: true
|
||||
translates :additional_info, touch: true
|
||||
globalize_accessors
|
||||
accepts_nested_attributes_for :translations, allow_destroy: true
|
||||
|
||||
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase proposals_phase draft_publication result_publication).freeze
|
||||
|
||||
@@ -24,7 +25,10 @@ class Legislation::Process < ActiveRecord::Base
|
||||
has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
has_many :proposals, -> { order(:id) }, class_name: 'Legislation::Proposal', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
|
||||
validates :title, presence: true
|
||||
translation_class.instance_eval do
|
||||
validates :title, presence: true
|
||||
end
|
||||
|
||||
validates :start_date, presence: true
|
||||
validates :end_date, presence: true
|
||||
validates :debate_start_date, presence: true, if: :debate_end_date?
|
||||
|
||||
@@ -173,37 +173,33 @@
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.translatable_text_field :title,
|
||||
placeholder: t("admin.legislation.processes.form.title_placeholder") %>
|
||||
</div>
|
||||
<%= f.translatable_fields do |translations_form| %>
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= translations_form.text_field :title,
|
||||
placeholder: t("admin.legislation.processes.form.title_placeholder") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.label :summary %>
|
||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
||||
<%= f.translatable_text_area :summary,
|
||||
rows: 2,
|
||||
placeholder: t("admin.legislation.processes.form.summary_placeholder"),
|
||||
label: false %>
|
||||
</div>
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= translations_form.text_area :summary,
|
||||
rows: 2,
|
||||
placeholder: t("admin.legislation.processes.form.summary_placeholder"),
|
||||
hint: t("admin.legislation.processes.form.use_markdown") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.label :description %>
|
||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
||||
<%= f.translatable_text_area :description,
|
||||
rows: 5,
|
||||
placeholder: t("admin.legislation.processes.form.description_placeholder"),
|
||||
label: false %>
|
||||
</div>
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= translations_form.text_area :description,
|
||||
rows: 5,
|
||||
placeholder: t("admin.legislation.processes.form.description_placeholder"),
|
||||
hint: t("admin.legislation.processes.form.use_markdown") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= f.label :additional_info %>
|
||||
<span class="help-text"><%= t("admin.legislation.processes.form.use_markdown") %></span>
|
||||
<%= f.translatable_text_area :additional_info,
|
||||
rows: 10,
|
||||
placeholder: t("admin.legislation.processes.form.additional_info_placeholder"),
|
||||
label: false %>
|
||||
</div>
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= translations_form.text_area :additional_info,
|
||||
rows: 10,
|
||||
placeholder: t("admin.legislation.processes.form.additional_info_placeholder"),
|
||||
hint: t("admin.legislation.processes.form.use_markdown") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="small-12 medium-3 column clear end">
|
||||
<%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
|
||||
|
||||
@@ -225,6 +225,11 @@ en:
|
||||
allegations_start_date: Allegations start date
|
||||
allegations_end_date: Allegations end date
|
||||
result_publication_date: Final result publication date
|
||||
legislation/process/translation:
|
||||
title: Process Title
|
||||
summary: Summary
|
||||
description: Description
|
||||
additional_info: Additional info
|
||||
legislation/draft_version:
|
||||
title: Version title
|
||||
body: Text
|
||||
|
||||
@@ -43,9 +43,9 @@ feature 'Admin legislation processes' do
|
||||
|
||||
click_link "New process"
|
||||
|
||||
fill_in 'legislation_process_title_en', with: 'An example legislation process'
|
||||
fill_in 'legislation_process_summary_en', with: 'Summary of the process'
|
||||
fill_in 'legislation_process_description_en', with: 'Describing the process'
|
||||
fill_in 'Process Title', with: 'An example legislation process'
|
||||
fill_in 'Summary', with: 'Summary of the process'
|
||||
fill_in 'Description', with: 'Describing the process'
|
||||
|
||||
base_date = Date.current
|
||||
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
||||
@@ -98,7 +98,7 @@ feature 'Admin legislation processes' do
|
||||
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
|
||||
expect(find("#legislation_process_published")).to be_checked
|
||||
|
||||
fill_in 'legislation_process_summary_en', with: ''
|
||||
fill_in 'Summary', with: ''
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Process updated successfully"
|
||||
|
||||
Reference in New Issue
Block a user