diff --git a/app/javascript/controllers/autocompleter_controller.js b/app/javascript/controllers/autocompleter_controller.js index ee5da7b10d..fdf36438d6 100644 --- a/app/javascript/controllers/autocompleter_controller.js +++ b/app/javascript/controllers/autocompleter_controller.js @@ -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'); diff --git a/app/views/controllers/locations/form/_north_south_east_west_alt_fields.erb b/app/views/controllers/locations/form/_bounds_fields.erb similarity index 100% rename from app/views/controllers/locations/form/_north_south_east_west_alt_fields.erb rename to app/views/controllers/locations/form/_bounds_fields.erb diff --git a/app/views/controllers/locations/form/_bounds_hidden_fields.erb b/app/views/controllers/locations/form/_bounds_hidden_fields.erb new file mode 100644 index 0000000000..79a26adf3e --- /dev/null +++ b/app/views/controllers/locations/form/_bounds_hidden_fields.erb @@ -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 %> diff --git a/app/views/controllers/locations/form/_fields.erb b/app/views/controllers/locations/form/_fields.erb index fb0901a06a..92bb8ffbc9 100644 --- a/app/views/controllers/locations/form/_fields.erb +++ b/app/views/controllers/locations/form/_fields.erb @@ -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", diff --git a/app/views/controllers/observations/form/_details.html.erb b/app/views/controllers/observations/form/_details.html.erb index c58c4b5b70..348ba95272 100644 --- a/app/views/controllers/observations/form/_details.html.erb +++ b/app/views/controllers/observations/form/_details.html.erb @@ -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 }) %>