-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mandatory categories for proposals (#29)
* Mandatory categories for proposals * Ignore missing
- Loading branch information
Showing
5 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
app/forms/concerns/decidim/proposals/proposal_form_override.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
92 changes: 92 additions & 0 deletions
92
app/views/decidim/proposals/proposals/_edit_form_fields.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<%= form_required_explanation %> | ||
|
||
<div class="field hashtags__container"> | ||
<%= form.text_field :title, class: "js-hashtags", value: form_presenter.title %> | ||
</div> | ||
|
||
<div class="field hashtags__container"> | ||
<%= text_editor_for_proposal_body(form) %> | ||
</div> | ||
|
||
<% if @form.component_automatic_hashtags.any? %> | ||
<div class="field"> | ||
<%= form.label :automatic_hashtags %> | ||
<div class="checkboxes hashtags"> | ||
<% @form.component_automatic_hashtags.each do |hashtag| %> | ||
<label> | ||
<%= check_box_tag "", "", { checked: true }, { disabled: true } %>#<%= hashtag %> | ||
</label> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<% if @form.component_suggested_hashtags.any? %> | ||
<div class="field"> | ||
<%= form.label :suggested_hashtags, nil, for: nil %> | ||
<div class="checkboxes hashtags"> | ||
<%= 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 %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<% if @form.geocoding_enabled? %> | ||
<div class="field"> | ||
<%= form.check_box :has_address, checked: form_has_address? %> | ||
</div> | ||
|
||
<div class="field" id="address_input"> | ||
<%= form.geocoding_field :address, placeholder: t("decidim.proposals.proposals.placeholder.address") %> | ||
<div class="map" id="address_map"> | ||
<%= render partial: "dynamic_map_instructions" %> | ||
<%= dynamic_map_for proposal_preview_data_for_map(@proposal) %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<% if @form.categories&.any? %> | ||
<div class="field"> | ||
<%= form.categories_select :category_id, @form.categories, { include_blank: t("decidim.proposals.proposals.edit.select_a_category") }, { required: true } %> | ||
</div> | ||
<% end %> | ||
|
||
<% if current_component.has_subscopes? %> | ||
<div class="field"> | ||
<%= scopes_picker_field form, :scope_id, root: current_component.scope %> | ||
</div> | ||
<% end %> | ||
|
||
<% if current_organization.user_groups_enabled? && Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.any? %> | ||
<div class="field"> | ||
<%= user_group_select_field form, :user_group_id %> | ||
</div> | ||
<% end %> | ||
|
||
<% if component_settings.attachments_allowed? && @proposal %> | ||
<fieldset class="gallery__container photos_container"> | ||
<legend><%= t("gallery_legend", scope: "decidim.proposals.proposals.edit") %></legend> | ||
<div class="row column"> | ||
<%= form.attachment :photos, | ||
multiple: false, | ||
label: t("decidim.proposals.proposals.edit.add_image"), | ||
button_label: t("decidim.proposals.proposals.edit.add_image"), | ||
button_edit_label: t("decidim.proposals.proposals.edit.edit_image"), | ||
help_i18n_scope: "decidim.forms.file_help.image", | ||
extension_allowlist: Decidim::OrganizationSettings.for(current_organization).upload_allowed_file_extensions_image %> | ||
</div> | ||
</fieldset> | ||
|
||
<fieldset class="attachments_container gallery__container documents_container"> | ||
<legend><%= t("attachment_legend", scope: "decidim.proposals.proposals.edit") %></legend> | ||
<div class="row column"> | ||
<%= form.attachment :documents, | ||
multiple: true, | ||
label: t("decidim.proposals.proposals.edit.add_documents"), | ||
button_label: t("decidim.proposals.proposals.edit.add_documents"), | ||
button_edit_label: t("decidim.proposals.proposals.edit.edit_documents"), | ||
help_i18n_scope: "decidim.forms.file_help.file" %> | ||
</div> | ||
</fieldset> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters