diff --git a/app/forms/concerns/decidim/proposals/proposal_form_override.rb b/app/forms/concerns/decidim/proposals/proposal_form_override.rb new file mode 100644 index 0000000..937973f --- /dev/null +++ b/app/forms/concerns/decidim/proposals/proposal_form_override.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "active_support/concern" + +module Decidim + module Proposals + module ProposalFormOverride + extend ActiveSupport::Concern + + included do + validates :category, presence: true + end + end + end +end diff --git a/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb b/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb new file mode 100644 index 0000000..3c8d872 --- /dev/null +++ b/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb @@ -0,0 +1,92 @@ +<%= form_required_explanation %> + +
+ <%= form.text_field :title, class: "js-hashtags", value: form_presenter.title %> +
+ +
+ <%= text_editor_for_proposal_body(form) %> +
+ +<% if @form.component_automatic_hashtags.any? %> +
+ <%= form.label :automatic_hashtags %> +
+ <% @form.component_automatic_hashtags.each do |hashtag| %> + + <% end %> +
+
+<% end %> + +<% if @form.component_suggested_hashtags.any? %> +
+ <%= form.label :suggested_hashtags, nil, for: nil %> +
+ <%= form.collection_check_boxes :suggested_hashtags, @form.component_suggested_hashtags.map { |hashtag| [hashtag.downcase, "##{hashtag}"] }, :first, :last do |option| + option.label { option.check_box(checked: @form.suggested_hashtag_checked?(option.value)) + option.text } + end %> +
+
+<% end %> + +<% if @form.geocoding_enabled? %> +
+ <%= form.check_box :has_address, checked: form_has_address? %> +
+ +
+ <%= form.geocoding_field :address, placeholder: t("decidim.proposals.proposals.placeholder.address") %> +
+ <%= render partial: "dynamic_map_instructions" %> + <%= dynamic_map_for proposal_preview_data_for_map(@proposal) %> +
+
+<% end %> + +<% if @form.categories&.any? %> +
+ <%= form.categories_select :category_id, @form.categories, { include_blank: t("decidim.proposals.proposals.edit.select_a_category") }, { required: true } %> +
+<% end %> + +<% if current_component.has_subscopes? %> +
+ <%= scopes_picker_field form, :scope_id, root: current_component.scope %> +
+<% end %> + +<% if current_organization.user_groups_enabled? && Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.any? %> +
+ <%= user_group_select_field form, :user_group_id %> +
+<% end %> + +<% if component_settings.attachments_allowed? && @proposal %> + + + +<% end %> diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index a6bc30c..a67c9ef 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -9,7 +9,15 @@ ignore_missing: - decidim.proposals.participatory_text_proposal.buttons.amend - decidim.proposals.participatory_text_proposal.buttons.comment - decidim.proposals.participatory_text_proposal.buttons.comments + - decidim.proposals.proposals.edit.add_documents + - decidim.proposals.proposals.edit.add_image + - decidim.proposals.proposals.edit.attachment_legend + - decidim.proposals.proposals.edit.edit_documents + - decidim.proposals.proposals.edit.edit_image + - decidim.proposals.proposals.edit.gallery_legend + - decidim.proposals.proposals.edit.select_a_category - decidim.proposals.proposals.participatory_texts.index.document_index + - decidim.proposals.proposals.placeholder.address - layouts.decidim.footer.cc_by_license - layouts.decidim.footer.decidim_logo - layouts.decidim.footer.made_with_open_source diff --git a/config/initializers/decidim_overrides.rb b/config/initializers/decidim_overrides.rb index 2e757fd..84b982f 100644 --- a/config/initializers/decidim_overrides.rb +++ b/config/initializers/decidim_overrides.rb @@ -4,4 +4,5 @@ Decidim::RegistrationForm.include(Decidim::AccountFormOverride) Decidim::OmniauthRegistrationForm.include(Decidim::AccountFormOverride) Decidim::AccountForm.include(Decidim::AccountFormOverride) + Decidim::Proposals::ProposalForm.include(Decidim::Proposals::ProposalFormOverride) end diff --git a/spec/lib/overrides_spec.rb b/spec/lib/overrides_spec.rb index 6bf1006..f1fcb1a 100644 --- a/spec/lib/overrides_spec.rb +++ b/spec/lib/overrides_spec.rb @@ -31,6 +31,8 @@ "/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb" => "0810f2a8eebf476b67632227a5c73ff2", "/app/cells/decidim/proposals/participatory_text_proposal/show.erb" => "a6fd0029e01e712314f555a9397485f8", "/app/forms/decidim/proposals/admin/participatory_text_proposal_form.rb" => "00d3e80982cc65d51c0fd9a85445526d", + "/app/forms/decidim/proposals/proposal_form.rb" => "5fbf98057d0e60a7beae161a37fdd31c", + "/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb" => "3cf530a07e4498195dab8d94b7df19d1", "/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb" => "6d3666c3c116689bae657da537d9deef" } }