Add map locations. Each map location can belongs to proposal or budget investment.
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
data-tiles-provider="//{s}.tile.osm.org/{z}/{x}/{y}.png"
|
||||
data-latitude-input-selector="#latitude"
|
||||
data-longitude-input-selector="#longitude"
|
||||
data-zoom-input-selector="#zoom"
|
||||
data-marker-selector="#admin-map-marker">
|
||||
data-zoom-input-selector="#zoom">
|
||||
</div>
|
||||
<div id="admin-map-attribution" class="map-attributtion">
|
||||
© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors
|
||||
|
||||
@@ -29,6 +29,19 @@
|
||||
<%= render 'documents/nested_documents', documentable: @investment, f: f %>
|
||||
</div>
|
||||
|
||||
<% if feature?(:map) %>
|
||||
<div class="small-12 column">
|
||||
|
||||
<%= render 'map_locations/form_fields',
|
||||
form: f,
|
||||
map_location: @investment.map_location || MapLocation.new,
|
||||
label: t("proposals.form.map_location"),
|
||||
help: t("proposals.form.map_location_instructions"),
|
||||
parent_class: "budget_investment" %>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :location %>
|
||||
</div>
|
||||
|
||||
25
app/views/map_locations/_form_fields.html.erb
Normal file
25
app/views/map_locations/_form_fields.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<%= form.label :map_location, label %>
|
||||
<p class="help-text" id="tag-list-help-text"><%= help %></p>
|
||||
<div id="location-map" class="map" data-map
|
||||
data-latitude="<%= map_location.present? && map_location.latitude.present? ? map_location.latitude : Setting["map.latitude"] %>"
|
||||
data-longitude="<%= map_location.present? && map_location.longitude.present? ? map_location.longitude : Setting["map.longitude"] %>"
|
||||
data-zoom="<%= map_location.present? && map_location.zoom.present? ? map_location.zoom : Setting["map.zoom"] %>"
|
||||
data-tiles-attribution-selector="#map-location-attribution"
|
||||
data-tiles-provider="//{s}.tile.osm.org/{z}/{x}/{y}.png"
|
||||
data-latitude-input-selector="#<%= parent_class %>_map_location_attributes_latitude"
|
||||
data-longitude-input-selector="#<%= parent_class %>_map_location_attributes_longitude"
|
||||
data-zoom-input-selector="#<%= parent_class %>_map_location_attributes_zoom"
|
||||
data-remove-marker-selector=".location-map-remove-marker-button">
|
||||
</div>
|
||||
|
||||
<div id="map-location-attribution" class="map-attributtion">
|
||||
© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors
|
||||
</div>
|
||||
|
||||
<a class="location-map-remove-marker-button" href="#">Remove marker</a>
|
||||
|
||||
<%= form.fields_for :map_location, map_location do |map_location_fields| %>
|
||||
<%= map_location_fields.hidden_field :latitude, value: map_location.latitude, id: "#{parent_class}_map_location_attributes_latitude" %>
|
||||
<%= map_location_fields.hidden_field :longitude, value: map_location.longitude, id: "#{parent_class}_map_location_attributes_longitude" %>
|
||||
<%= map_location_fields.hidden_field :zoom, value: map_location.zoom, id: "#{parent_class}_map_location_attributes_zoom" %>
|
||||
<% end %>
|
||||
@@ -59,6 +59,19 @@
|
||||
<%= f.select :geozone_id, geozone_select_options, {include_blank: t("geozones.none"), label: false} %>
|
||||
</div>
|
||||
|
||||
<% if feature?(:map) %>
|
||||
<div class="small-12 column">
|
||||
|
||||
<%= 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"),
|
||||
parent_class: "proposal" %>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :tag_list, t("proposals.form.tags_label") %>
|
||||
<p class="help-text" id="tag-list-help-text"><%= t("proposals.form.tags_instructions") %></p>
|
||||
|
||||
Reference in New Issue
Block a user