From 26d0fe8a9cbc371296db38771c08b101343d3bc9 Mon Sep 17 00:00:00 2001 From: Antti Hukkanen Date: Tue, 7 May 2024 09:50:36 +0300 Subject: [PATCH] Add the fields for error messages --- app/commands/decidim/plans/admin/update_sections.rb | 1 + app/forms/decidim/plans/admin/section_form.rb | 1 + app/views/decidim/plans/admin/sections/_section.html.erb | 9 +++++++++ config/locales/en.yml | 1 + config/locales/fi.yml | 1 + config/locales/sv.yml | 1 + .../20240502083422_add_error_text_to_plan_sections.rb | 7 +++++++ 7 files changed, 21 insertions(+) create mode 100644 db/migrate/20240502083422_add_error_text_to_plan_sections.rb diff --git a/app/commands/decidim/plans/admin/update_sections.rb b/app/commands/decidim/plans/admin/update_sections.rb index 8b89013a..3012b77f 100644 --- a/app/commands/decidim/plans/admin/update_sections.rb +++ b/app/commands/decidim/plans/admin/update_sections.rb @@ -40,6 +40,7 @@ def update_sections handle: form_section.handle, body: form_section.body_text, help: form_section.help, + error_text: form_section.error_text, information_label: form_section.information_label, information: form_section.information, mandatory: form_section.mandatory, diff --git a/app/forms/decidim/plans/admin/section_form.rb b/app/forms/decidim/plans/admin/section_form.rb index a8d93a86..eb471cf9 100644 --- a/app/forms/decidim/plans/admin/section_form.rb +++ b/app/forms/decidim/plans/admin/section_form.rb @@ -14,6 +14,7 @@ class SectionForm < Decidim::Form translatable_attribute :body, String translatable_attribute :body_rich, String translatable_attribute :help, String + translatable_attribute :error_text, String translatable_attribute :information_label, String translatable_attribute :information, String attribute :visible_form, Boolean, default: true diff --git a/app/views/decidim/plans/admin/sections/_section.html.erb b/app/views/decidim/plans/admin/sections/_section.html.erb index 4c179738..73704cc8 100644 --- a/app/views/decidim/plans/admin/sections/_section.html.erb +++ b/app/views/decidim/plans/admin/sections/_section.html.erb @@ -91,6 +91,15 @@ ) %> +
+ <%= form.translated( + :text_field, + :error_text, + tabs_id: id, + label: t(".error_text") + ) %> +
+
<%= form.translated( :text_field, diff --git a/config/locales/en.yml b/config/locales/en.yml index aa69ba90..d84cbf1c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -170,6 +170,7 @@ en: attachments_input_type: Attachments input type body: Body down: Down + error_text: Text for invalid input handle: Handle help: Help information: Information diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 4eef1541..4735bb11 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -170,6 +170,7 @@ fi: attachments_input_type: Liitteiden syöttökentän tyyppi body: Runkoteksti down: Alas + error_text: Virheellisen syötteen teksti handle: Tunniste help: Ohjeteksti information: Tietoa-osio diff --git a/config/locales/sv.yml b/config/locales/sv.yml index a5c440e8..add8f6fb 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -170,6 +170,7 @@ sv: attachments_input_type: Inmatningsfält typ av bilaga body: Brödtext down: Ner + error_text: Text för ogiltig inmatning handle: Identifierare help: Hjälp information: Information diff --git a/db/migrate/20240502083422_add_error_text_to_plan_sections.rb b/db/migrate/20240502083422_add_error_text_to_plan_sections.rb new file mode 100644 index 00000000..4d7a2bc1 --- /dev/null +++ b/db/migrate/20240502083422_add_error_text_to_plan_sections.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddErrorTextToPlanSections < ActiveRecord::Migration[6.1] + def change + add_column :decidim_plans_sections, :error_text, :jsonb + end +end