Skip to content

Commit

Permalink
Merge pull request #2271 from MushroomObserver/location-field-adjustm…
Browse files Browse the repository at this point in the history
…ents

Location field adjustments
  • Loading branch information
nimmolo authored Aug 1, 2024
2 parents e57e46e + e9bba6e commit b6123e0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/javascript/controllers/autocompleter_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export default class extends Controller {

const hiddenId = parseInt(this.hiddenTarget.value);

if (hiddenId !== NaN && hiddenId > 0) {
if (hiddenId !== NaN && hiddenId != 0) {
this.wrapTarget.classList.add('has-id');
} else {
this.wrapTarget.classList.remove('has-id');
Expand Down
10 changes: 10 additions & 0 deletions app/views/controllers/locations/form/_bounds_hidden_fields.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%# locals: (location: nil, target_type: :geocode_target) -%>

<%= fields_for(:location) do |f_l| %>
<% %w[north south east west low high].each do |key| %>
<%= f_l.hidden_field(
:"#{key}", value: location&.send(key) || nil,
data: { "#{target_type}_target".to_sym => "#{key}Input" }
) %>
<% end %>
<% end %>
3 changes: 1 addition & 2 deletions app/views/controllers/locations/form/_fields.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
button_data: { map_target: "showBoxBtn", action: "map#showBox" }
) %>

<%= render(partial: "locations/form/north_south_east_west_alt_fields",
locals: { f: f }) %>
<%= render(partial: "locations/form/bounds_fields", locals: { f: f }) %>

<% if in_admin_mode? %>
<%= check_box_with_label(form: f, field: :locked, class: "mt-3",
Expand Down
8 changes: 2 additions & 6 deletions app/views/controllers/observations/form/_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,8 @@ t_s = {
}
) %>

<%= fields_for(:location) do |f_l| %>
<% %w[north south east west low high].each do |key| %>
<%= f_l.hidden_field(:"#{key}", value: @location&.send(key) || nil,
data: { map_target: "#{key}Input" }) %>
<% end %>
<% end %>
<%= render(partial: "locations/form/bounds_hidden_fields",
locals: { location: @location, target_type: :map }) %>
<!-- /WHERE -->

<!-- IS_COLLECTION_LOCATION -->
Expand Down

0 comments on commit b6123e0

Please sign in to comment.