Skip to content

Commit

Permalink
change new proposal form
Browse files Browse the repository at this point in the history
  • Loading branch information
antopalidi committed Apr 16, 2024
1 parent b6226f7 commit 6a3b7fc
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ def file_field(object_name, options = {})

unless @template.snippets.any?(:reporting_proposals_camera_scripts) || @template.snippets.any?(:reporting_proposals_camera_styles)
@template.snippets.add(:reporting_proposals_camera_scripts, @template.prepend_javascript_pack_tag("decidim_reporting_proposals_camera"))
@template.snippets.add(:reporting_proposals_camera_styles, @template.stylesheet_pack_tag("decidim_reporting_proposals_camera"))
@template.snippets.add(:reporting_proposals_camera_styles, @template.append_stylesheet_pack_tag("decidim_reporting_proposals_camera"))

# This will display the snippets in the <head> part of the page.
@template.snippets.add(:head, @template.snippets.for(:reporting_proposals_camera_styles))
@template.snippets.add(:foot, @template.snippets.for(:reporting_proposals_camera_scripts))
end

content_tag(:div, class: "input-group") do
content_tag(:div, class: "input-group flex justify-between mb-4") do
super(object_name, options) +
content_tag(:div, class: "input-group-button") do
content_tag(:button, class: "button secondary user-device-camera", type: "button", data: { input: object_name }) do
content_tag(:button, class: "button button__secondary flex-none whitespace-nowrap w-auto p-4 mt-2 user-device-camera", type: "button", data: { input: object_name }) do
icon("camera-line", role: "img", "aria-hidden": true) + " #{I18n.t("use_my_camera", scope: "decidim.reporting_proposals.forms")}"
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def geocoding_field(object_name, method, options = {})

unless template.snippets.any?(:reporting_proposals_geocoding_scripts) || template.snippets.any?(:reporting_proposals_geocoding_styles)
template.snippets.add(:reporting_proposals_geocoding_scripts, template.prepend_javascript_pack_tag("decidim_reporting_proposals_geocoding"))
template.snippets.add(:reporting_proposals_geocoding_styles, template.stylesheet_pack_tag("decidim_reporting_proposals_geocoding"))
template.snippets.add(:reporting_proposals_geocoding_styles, template.append_stylesheet_pack_tag("decidim_reporting_proposals_geocoding"))

# This will display the snippets in the <head> part of the page.
template.snippets.add(:head, template.snippets.for(:reporting_proposals_geocoding_styles))
Expand All @@ -28,22 +28,22 @@ def geocoding_field(object_name, method, options = {})
options[:autocomplete] ||= "off"
options[:class] ||= "input-group-field"

template.content_tag(:div, class: "input-group") do
template.content_tag(:div, class: "flex mb-4") do
template.text_field(
object_name,
method,
options.merge("data-decidim-geocoding" => view_options.to_json)
) +
template.content_tag(:div, class: "input-group-button user-device-location") do
template.content_tag(:button, class: "button secondary", type: "button", data: {
template.content_tag(:button, class: "button button__secondary flex-none whitespace-nowrap w-auto p-4 mt-2", type: "button", data: {
input: "#{object_name}_#{method}",
latitude: "#{object_name}_latitude",
longitude: "#{object_name}_longitude",
error_no_location: I18n.t("errors.no_device_location", scope: "decidim.reporting_proposals.forms"),
error_unsupported: I18n.t("errors.device_not_supported", scope: "decidim.reporting_proposals.forms"),
url: Decidim::ReportingProposals::Engine.routes.url_helpers.locate_path
}) do
icon("location", role: "img", "aria-hidden": true) + " #{I18n.t("use_my_location", scope: "decidim.reporting_proposals.forms")}"
icon("map-pin-line", role: "img", "aria-hidden": true) + " #{I18n.t("use_my_location", scope: "decidim.reporting_proposals.forms")}"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- insert_before "erb[silent]:contains(':js_content')" -->

<% if reporting_proposal? %>
<%= stylesheet_pack_tag "decidim_reporting_proposals" %>
<%= append_stylesheet_pack_tag "decidim_reporting_proposals" %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- replace "erb[loud]:contains('javascript_pack_tag')" -->

<% if reporting_proposal? %>
<%= javascript_pack_tag "decidim_reporting_proposals" %>
<%= prepend_javascript_pack_tag "decidim_reporting_proposals" %>
<% else %>
<%= javascript_pack_tag "decidim_proposals" %>
<%= prepend_javascript_pack_tag "decidim_proposals" %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- insert_before "erb[silent]:contains(':js_content')" -->

<% if reporting_proposal? %>
<%= stylesheet_pack_tag "decidim_reporting_proposals" %>
<%= append_stylesheet_pack_tag "decidim_reporting_proposals" %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- replace "erb[loud]:contains('javascript_pack_tag')" -->

<% if reporting_proposal? %>
<%= javascript_pack_tag "decidim_reporting_proposals" %>
<%= stylesheet_pack_tag "decidim_reporting_proposals" %>
<%= prepend_javascript_pack_tag "decidim_reporting_proposals" %>
<%= append_stylesheet_pack_tag "decidim_reporting_proposals" %>
<% else %>
<%= javascript_pack_tag "decidim_proposals" %>
<%= prepend_javascript_pack_tag "decidim_proposals" %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- insert_before "erb[silent]:contains(':js_content')" -->

<% if reporting_proposal? %>
<%= stylesheet_pack_tag "decidim_reporting_proposals" %>
<%= append_stylesheet_pack_tag "decidim_reporting_proposals" %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- remove "erb[loud]:contains('text_editor_for_proposal_body(form)')" -->
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- remove ".hashtags__container" -->
<!-- remove "erb[loud]:contains(':title')" -->
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.user-device-location {
button {
max-height: 3rem;
margin-top: 1rem;

&.loading-spinner {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ button.user-device-camera {
text-align: right;
}

#proposal_add_photos {
display: block;
margin-top: 1rem;
}

@media only screen and (max-width: 596px) {
.gallery__container .input-group .input-group-button {
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@
button_edit_label: t(".edit_images"),
button_class: "button button__sm button__transparent-secondary mr-2",
attachments: proposal.photos,
extension_allowlist: Decidim::OrganizationSettings.for(current_organization).upload_allowed_file_extensions_image,
help_i18n_scope: "decidim.forms.file_help.image" %>
<%= f.hidden_field :photos, multiple: true, accept: "image/*", capture: "camera", id: "camera-input", style: "display: none;" %>

<button id="use-camera-button" class="button button__sm button__transparent-secondary mt-2 user-device-camera" type="button">
<%= icon("camera-line", role: "img", "aria-hidden" => true) %> <%= t("use_my_camera", scope: "decidim.reporting_proposals.forms") %>
</button>
</div>
</fieldset>
<div>
<%= f.submit t(".action"), class: "button button__sm button__secondary mt-2" %>
</div>
<% end %>
<!--add assets if snippets need to be removed -->
<%# append_javascript_pack_tag("decidim_reporting_proposals_camera") %>
<%# append_stylesheet_pack_tag("decidim_reporting_proposals_camera") %>
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@
<% end %>
<% if @form.geocoding_enabled? %>
<div class="field" id="address_input">
<div id="address_input">
<div class="address-fill">
<%= form.geocoding_field :address, placeholder: t("decidim.proposals.proposals.placeholder.address") %>
<%= form.geocoding_field :address, placeholder: t("decidim.proposals.proposals.placeholder.address"), required: true %>
</div>
<div class="has_no_address">
<%= form.check_box :has_no_address %>
<%= form.hidden_field :has_address, value: "1" %>
</div>
<div class="map address-fill" id="address_map">
<%= render partial: "dynamic_map_instructions" %>
<div id="address_map" class="proposal__container">
<p class="help-text">
<%= t("instructions", scope: "decidim.proposals.proposals.dynamic_map_instructions") %> <%= t("description", scope: "decidim.proposals.proposals.dynamic_map_instructions") %>
</p>
<%= dynamic_map_for proposal_preview_data_for_map(@form.to_h) %>
</div>
</div>
</div>
<% end %>

<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>
<%= text_editor_for_proposal_body(form) %>
<% if @form.component_automatic_hashtags.any? %>
<div class="field">
Expand All @@ -82,20 +82,19 @@
<% end %>
<% if current_component.has_subscopes? %>
<div class="field">
<%= scopes_picker_field form, :scope_id, root: current_component.scope %>
</div>
<%= scopes_select_field form, :scope_id, root: current_component.scope %>
<% end %>
<% if component_settings.attachments_allowed? && !component_settings.only_photo_attachments? %>
<fieldset class="attachments_container gallery__container documents_container">
<legend><%= t("attachment_legend", scope: "decidim.proposals.proposals.edit") %></legend>
<div class="row column">
<div>
<%= 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"),
button_class: "button button__lg button__transparent-secondary w-full",
help_i18n_scope: "decidim.forms.file_help.file" %>
</div>
</fieldset>
Expand Down

0 comments on commit 6a3b7fc

Please sign in to comment.