-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
app/overrides/forms/decidim/initiatives/admin/initiative_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,12 @@ | ||
Decidim::Initiatives::Admin::InitiativeForm.class_eval do | ||
def signature_type_options | ||
Decidim::Initiative.signature_types.keys.map do |type| | ||
[ | ||
I18n.t( | ||
type, | ||
scope: %w(activemodel attributes initiative signature_type_values) | ||
), type | ||
] | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
app/overrides/forms/decidim/initiatives/initiative_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,12 @@ | ||
Decidim::Initiatives::InitiativeForm.class_eval do | ||
def signature_type_options | ||
Decidim::Initiative.signature_types.keys.map do |type| | ||
[ | ||
I18n.t( | ||
type, | ||
scope: %w(activemodel attributes initiative signature_type_values) | ||
), type | ||
] | ||
end | ||
end | ||
end |
122 changes: 122 additions & 0 deletions
122
app/views/decidim/initiatives/admin/initiatives/_form.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,122 @@ | ||
<div class="card"> | ||
<div class="card-divider"> | ||
<h2 class="card-title"><%= t ".title" %></h2> | ||
</div> | ||
|
||
<div class="card-section"> | ||
<div class="row column"> | ||
<%= form.translated :text_field, :title, autofocus: true, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %> | ||
</div> | ||
|
||
<div class="row column"> | ||
<%= form.translated :editor, :description, toolbar: :full, lines: 8, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %> | ||
</div> | ||
|
||
<div class="row column"> | ||
<div class="columns xlarge-6"> | ||
<%= form.text_field :hashtag, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="card"> | ||
<div class="card-divider"> | ||
<h2 class="card-title"><%= t ".settings" %></h2> | ||
</div> | ||
|
||
<div class="card-section"> | ||
<div class="row"> | ||
<div class="columns xlarge-6"> | ||
<%= form.select :state, | ||
Decidim::Initiative.states.keys.map { |state| [I18n.t(state, scope: "decidim.initiatives.admin_states"), state] }, | ||
{}, | ||
{ disabled: !@form.state_updatable? } %> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<% unless single_initiative_type? %> | ||
<div class="columns xlarge-6"> | ||
<%= form.select :type_id, | ||
initiative_type_options, | ||
{}, | ||
{ | ||
disabled: !@form.signature_type_updatable?, | ||
"data-scope-selector": "initiative_decidim_scope_id", | ||
"data-scope-id": form.object.decidim_scope_id.to_s, | ||
"data-scope-search-url": decidim_initiatives.initiative_type_scopes_search_url, | ||
"data-signature-types-selector": "initiative_signature_type", | ||
"data-signature-type": current_initiative.signature_type, | ||
"data-signature-types-search-url": decidim_initiatives.initiative_type_signature_types_search_url | ||
} %> | ||
</div> | ||
<% end %> | ||
<div class="columns xlarge-6"> | ||
<%= form.select :decidim_scope_id, [], {}, { disabled: !@form.signature_type_updatable? } %> | ||
</div> | ||
</div> | ||
|
||
<% if current_initiative.published? && current_user.admin? %> | ||
<div class="row"> | ||
<div class="columns xlarge-6"> | ||
<%= form.date_field :signature_start_date %> | ||
</div> | ||
|
||
<div class="columns xlarge-6"> | ||
<%= form.date_field :signature_end_date %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<% if can_edit_custom_signature_end_date?(current_initiative) %> | ||
<div class="row column"> | ||
<%= form.date_field :signature_end_date, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %> | ||
</div> | ||
<% end %> | ||
|
||
<% if current_initiative.area_enabled? %> | ||
<div class="field"> | ||
<%= form.areas_select :area_id, | ||
areas_for_select(current_organization), | ||
{ | ||
selected: current_initiative.decidim_area_id, | ||
include_blank: current_initiative.decidim_area_id.blank? || current_initiative.created? | ||
}, | ||
disabled: !@form.area_updatable? %> | ||
</div> | ||
<% end %> | ||
|
||
<div class="row"> | ||
<div class="columns xlarge-6"> | ||
<%= form.select :signature_type, form.object.signature_type_options, {}, { disabled: !@form.signature_type_updatable? } %> | ||
</div> | ||
</div> | ||
|
||
<% if current_initiative.accepts_offline_votes? && current_user.admin? %> | ||
<div class="row"> | ||
<div class="columns xlarge-6"> | ||
<% @form.offline_votes.each do |scope_id, (votes, scope_name)| %> | ||
<%= label_tag "initiative_offline_votes_#{scope_id}", t("activemodel.attributes.initiative.offline_votes_for_scope", scope_name: translated_attribute(scope_name)) %> | ||
<%= number_field_tag "initiative[offline_votes][#{scope_id}]", votes, min: 0, id: "initiative_offline_votes_#{scope_id}" %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<div class="card"> | ||
<div class="card-divider"> | ||
<h2 class="card-title"><%= t ".attachments" %></h2> | ||
</div> | ||
|
||
<div class="card-section"> | ||
<div class="row"> | ||
<% if allowed_to?(:read, :attachment, initiative: current_participatory_space) %> | ||
<%= render partial: "initiative_attachments", locals: { current_initiative: current_initiative, current_participatory_space: current_participatory_space } %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%= javascript_include_tag "decidim/initiatives/scoped_type" %> |
112 changes: 112 additions & 0 deletions
112
app/views/decidim/initiatives/initiatives/_form.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,112 @@ | ||
<%= form_required_explanation %> | ||
|
||
<div class="field"> | ||
<%= form.text_field :title, autofocus: true, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative), value: translated_attribute(@form.title) %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.editor :description, toolbar: :full, lines: 8, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative), value: translated_attribute(@form.description) %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.text_field :hashtag, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.select :state, | ||
Decidim::Initiative.states.keys.map { |state| [I18n.t(state, scope: "decidim.initiatives.admin_states"), state] }, | ||
{}, | ||
{ disabled: !@form.state_updatable? } %> | ||
</div> | ||
|
||
<% unless single_initiative_type? %> | ||
<div class="field"> | ||
<%= form.select :type_id, | ||
initiative_type_options, | ||
{}, | ||
{ | ||
disabled: !@form.signature_type_updatable?, | ||
"data-scope-selector": "initiative_decidim_scope_id", | ||
"data-scope-id": form.object.scope_id.to_s, | ||
"data-scope-search-url": decidim_initiatives.initiative_type_scopes_search_url, | ||
"data-signature-types-selector": "initiative_signature_type", | ||
"data-signature-type": current_initiative.signature_type, | ||
"data-signature-types-search-url": decidim_initiatives.initiative_type_signature_types_search_url | ||
} %> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.select :scope_id, | ||
@form.available_scopes.map { |scope| [translated_attribute(scope.scope_name), scope&.scope&.id] }, | ||
{ disabled: !@form.state_updatable? } %> | ||
</div> | ||
|
||
<% if can_edit_custom_signature_end_date?(current_initiative) %> | ||
<div class="row column"> | ||
<%= form.date_field :signature_end_date, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %> | ||
</div> | ||
<% end %> | ||
|
||
<% if current_initiative.area_enabled? %> | ||
<div class="field"> | ||
<%= form.areas_select :area_id, | ||
areas_for_select(current_organization), | ||
{ | ||
selected: current_initiative.decidim_area_id, | ||
include_blank: current_initiative.decidim_area_id.blank? || current_initiative.created? | ||
}, | ||
disabled: !@form.area_updatable? %> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.select :signature_type, form.object.signature_type_options, {}, { disabled: !@form.signature_type_updatable? } %> | ||
</div> | ||
<% if current_initiative.type.attachments_enabled? %> | ||
<fieldset> | ||
<legend><%= t("attachment_legend", scope: "decidim.initiatives.form") %></legend> | ||
|
||
<% if @form.photos.any? %> | ||
<% @form.photos.each do |photo| %> | ||
<div class="callout gallery__item" data-closable> | ||
<%= image_tag photo.thumbnail_url, class: "thumbnail", alt: photo.file.file.filename %> | ||
<%= form.hidden_field :photos, multiple: true, value: photo.id, id: "photo-#{photo.id}" %> | ||
<button class="close-button" | ||
aria-label="<%= t("delete_attachment", scope: "decidim.initiatives.form") %>" | ||
title="<%= t("delete_attachment", scope: "decidim.initiatives.form") %>" | ||
type="button" | ||
data-close> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
|
||
<% if @form.documents.any? %> | ||
<% @form.documents.each do |document| %> | ||
<div class="callout" data-closable> | ||
<%= link_to translated_attribute(document.title), document.url %> | ||
<small><%= document.file_type %> <%= number_to_human_size(document.file_size) %></small> | ||
<%= form.hidden_field :documents, multiple: true, value: document.id, id: "document-#{document.id}" %> | ||
<button class="close-button" | ||
aria-label="<%= t("delete_attachment", scope: "decidim.initiatives.form") %>" | ||
title="<%= t("delete_attachment", scope: "decidim.initiatives.form") %>" | ||
type="button" data-close> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="row column"> | ||
<%= form.file_field :add_documents, multiple: true, label: t("add_attachments", scope: "decidim.initiatives.form") %> | ||
</div> | ||
</fieldset> | ||
<% end %> | ||
|
||
<% if current_initiative.type.promoting_committee_enabled? %> | ||
<%= render partial: "committee_members" %> | ||
<% end %> | ||
|
||
<%= javascript_include_tag "decidim/initiatives/scoped_type" %> |