Extract methods to get map location in form components

This way changing them will be easier.
This commit is contained in:
Javi Martín
2025-11-17 02:11:14 +01:00
parent 8b3ac5ac97
commit 67e00654bd
4 changed files with 10 additions and 2 deletions

View File

@@ -46,7 +46,7 @@
<%= render "map_locations/form_fields",
form: f,
map_location: investment.map_location || MapLocation.new,
map_location: map_location,
label: t("budgets.investments.form.map_location"),
help: t("budgets.investments.form.map_location_instructions") %>

View File

@@ -19,4 +19,8 @@ class Budgets::Investments::FormComponent < ApplicationComponent
def categories
Tag.category.order(:name)
end
def map_location
investment.map_location || MapLocation.new
end
end

View File

@@ -54,7 +54,7 @@
<%= render "map_locations/form_fields",
form: f,
map_location: proposal.map_location || MapLocation.new,
map_location: map_location,
label: t("proposals.form.map_location"),
help: t("proposals.form.map_location_instructions") %>

View File

@@ -15,4 +15,8 @@ class Proposals::FormComponent < ApplicationComponent
def categories
Tag.category.order(:name)
end
def map_location
proposal.map_location || MapLocation.new
end
end