Skip to content

Commit

Permalink
Prevent error from locations map in case map provider faulty or missing
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Apr 11, 2024
1 parent 444652f commit c7f744a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
<%= form.translated :editor, :description %>
</div>

<div class="row column">
<%= cell("decidim/locations/locations", @result, form: form, coords: [current_component.settings.default_latitude, current_component.settings.default_longitude], checkbox: true) %>
</div>
<% if Decidim::Map.autocomplete(organization: current_organization).present? %>
<div class="row column">
<%= cell("decidim/locations/locations", @result, form: form, coords: [current_component.settings.default_latitude, current_component.settings.default_longitude], checkbox: true) %>
</div>
<% end %>

<% if @form.parent_id %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@
<% end %>
</div>

<% begin %>
<%= javascript_pack_tag "decidim_forms_admin", defer: false %>

<% if questionnaire.questions_editable? %>
<script>
window.Decidim.createEditableForm()
</script>
<% end %>

<% if Decidim::Map.autocomplete(organization: current_organization).present? %>
<div id="answer-option-map-selector" data-reveal class="reveal answer_option_map">
<%= cell(
"decidim/locations/locations",
Expand All @@ -132,13 +140,4 @@
select_location: true
) %>
</div>
<% rescue StandardError => error %>
<% end %>

<%= javascript_pack_tag "decidim_forms_admin", defer: false %>

<% if questionnaire.questions_editable? %>
<script>
window.Decidim.createEditableForm()
</script>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
</div>

<div class="field" data-meeting-type="in_person">
<%= cell("decidim/locations/locations", @meeting, form: form, coords: [current_component.settings.default_latitude, current_component.settings.default_longitude], checkbox: false) %>
<% if Decidim::Map.autocomplete(organization: current_organization).present? %>
<%= cell("decidim/locations/locations", @meeting, form: form, coords: [current_component.settings.default_latitude, current_component.settings.default_longitude], checkbox: false) %>
<% else %>
<%= form.geocoding_field :address %>
<% end %>
<p class="help-text"><%= t(".address_help") %></p>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</div>

<div class="field" data-meeting-type="in_person">
<% begin %>
<% if Decidim::Map.autocomplete(organization: current_organization).present? %>
<%= cell("decidim/locations/locations", meeting, form: form, coords: [current_component.settings.default_latitude, current_component.settings.default_longitude], checkbox: false) %>
<% rescue StandardError => error %>
<% else %>
<%= form.geocoding_field :address, input_html: { required: false } %>
<% end %>
<p class="help-text"><%= t(".address_help") %></p>
Expand Down

0 comments on commit c7f744a

Please sign in to comment.