Remove duplication rendering map location fields

We're going to move the partial to a component, and this makes it
easier.
This commit is contained in:
Javi Martín
2025-11-16 23:53:26 +01:00
parent 0ec7c65b9b
commit 2d85bd5351
3 changed files with 21 additions and 25 deletions

View File

@@ -44,15 +44,11 @@
<%= render Documents::NestedComponent.new(f) %>
<% end %>
<% if feature?(:map) %>
<div>
<%= render "map_locations/form_fields",
form: f,
map_location: investment.map_location || MapLocation.new,
label: t("budgets.investments.form.map_location"),
help: t("budgets.investments.form.map_location_instructions") %>
</div>
<% end %>
<%= render "map_locations/form_fields",
form: f,
map_location: investment.map_location || MapLocation.new,
label: t("budgets.investments.form.map_location"),
help: t("budgets.investments.form.map_location_instructions") %>
<div>
<%= f.text_field :location %>

View File

@@ -52,15 +52,11 @@
</div>
<% end %>
<% if feature?(:map) %>
<div>
<%= render "map_locations/form_fields",
form: f,
map_location: proposal.map_location || MapLocation.new,
label: t("proposals.form.map_location"),
help: t("proposals.form.map_location_instructions") %>
</div>
<% end %>
<%= render "map_locations/form_fields",
form: f,
map_location: proposal.map_location || MapLocation.new,
label: t("proposals.form.map_location"),
help: t("proposals.form.map_location_instructions") %>
<div>
<%= f.label :tag_list, t("proposals.form.tags_label") %>

View File

@@ -1,10 +1,14 @@
<%= form.label :map_location, label %>
<p class="help-text" id="tag-list-help-text"><%= help %></p>
<% if feature?(:map) %>
<div>
<%= form.label :map_location, label %>
<p class="help-text" id="tag-list-help-text"><%= help %></p>
<%= form.fields_for :map_location, map_location do |m_l_fields| %>
<%= render_map(map_location, form: m_l_fields) %>
<%= form.fields_for :map_location, map_location do |m_l_fields| %>
<%= render_map(map_location, form: m_l_fields) %>
<%= m_l_fields.hidden_field :latitude %>
<%= m_l_fields.hidden_field :longitude %>
<%= m_l_fields.hidden_field :zoom %>
<%= m_l_fields.hidden_field :latitude %>
<%= m_l_fields.hidden_field :longitude %>
<%= m_l_fields.hidden_field :zoom %>
<% end %>
</div>
<% end %>