diff --git a/app/views/controllers/observations/_form.html.erb b/app/views/controllers/observations/_form.html.erb index 6b2f79fc3b..0c4667eef6 100644 --- a/app/views/controllers/observations/_form.html.erb +++ b/app/views/controllers/observations/_form.html.erb @@ -32,18 +32,6 @@ data = { form_images_target: "form", exif_used: create ? false : true } -naming_locals = if include_naming - { - f: f, - action: action, - button_name: button_name, - show_reasons: false, - unfocused: true, - name_help: :form_naming_name_help_leave_blank.t - } - else - {} - end show_projects = @projects.any? || @error_checked_projects.any? || @suspect_checked_projects.any? show_lists = @lists.any? @@ -65,48 +53,19 @@ show_lists = @lists.any? <%= hidden_field_tag(:field_code, @field_code) %> <% end %> - <%# tab_content do %> - <%= render(partial: "observations/form/record_step", - locals: { f:, button_name:, location: @location, - logging_optional: }) %> - - <%= render(partial: "observations/form/identify_step", - locals: { f:, action:, button_name:, include_naming: }) %> - - <% if projects_lists %> - <%= render(partial: "observations/form/add_to_step", - locals: { f:, button_name: }) %> - <% end %> - <%# end %> - + <% content = [ + render(partial: "observations/form/images", locals: { f: }), + render(partial: "observations/form/details", + locals: { f:, button_name:, location: @location, logging_optional:, + action:, include_naming: }), + ].safe_join %> <%= panel_block( heading: "#{:IMAGES.l} + #{:show_observation_details.l}", - id: "observation_images_details" - ) do %> - <%= render(partial: "observations/form/images", locals: { f: }) %> + id: "observation_images_details", content: + ) %> - <%= render(partial: "observations/form/details", - locals: { f:, button_name:, location:, logging_optional: }) %> - <% end %> - - <%= panel_block( - heading: :IDENTIFICATION.l, - id: "observation_identification", - collapse: "observation_identification_inner", - open: false - ) do - render(partial: "observations/namings/fields", locals: naming_locals) - end %> - - <%= panel_block( - heading: :SPECIMEN.l, - id: "observation_specimen", - collapse: "observation_specimen_inner", - open: false - ) do - render(partial: "observations/form/specimen_section", - locals: { f:, action: }) - end %> + <%= render(partial: "observations/form/identify_specimen", + locals: { f:, action:, button_name:, include_naming: }) %> <%= panel_block( heading: :NOTES.l, @@ -118,6 +77,8 @@ show_lists = @lists.any? locals: { form: f, fields: @observation.form_notes_parts(@user) }) end %> + <%= submit_button(form: f, button: button_name, center: true) %> + <% if show_projects %> <%= panel_block( heading: :PROJECTS.l, diff --git a/app/views/controllers/observations/form/_details.html.erb b/app/views/controllers/observations/form/_details.html.erb index 9471ea8834..dcee14f00d 100644 --- a/app/views/controllers/observations/form/_details.html.erb +++ b/app/views/controllers/observations/form/_details.html.erb @@ -1,13 +1,25 @@ -<%# locals: (f:, button_name:, location:, logging_optional:) -%> +<%# locals: (f:, action:, button_name:, location:, logging_optional:, include_naming: false) -%> <%# When and Where (location) section of create_observation form - including location autocomplete, map, lat/long/alt %> + including location autocomplete, map, lat/long/alt, naming %> <% t_s = { lat: { abbr: :LAT.l, full: :LATITUDE.l, addon: "º" }, lng: { abbr: :LNG.l, full: :LONGITUDE.l, addon: "º" }, alt: { abbr: :ALT.l, full: :ALTITUDE.l, addon: "m" } } +naming_locals = if include_naming + { + f: f, + action: action, + button_name: button_name, + show_reasons: false, + unfocused: true, + name_help: :form_naming_name_help_leave_blank.t + } + else + {} + end %> <%= tag.div(class: "panel-body border-top", id: "observation_details") do %> @@ -21,44 +33,13 @@ t_s = { <%= tag.div(id: "observation_where") do %> - <%= tag.p do - [tag.strong("#{:WHERE_GROUP.l}:"), - collapse_info_trigger("geolocation_help")].safe_join(" ") - end %> - - - <%= tag.div(class: "row no-gutters", - id: "observation_lat_lng_alt") do %> - <% [:lat, :lng, :alt].each do |key| %> - <%= tag.div(class: "col-xs-4") do - text_field_with_label( - form: f, field: key, class: "mb-0", addon: t_s[key][:addon], - label: [ - tag.span("#{t_s[key][:full]}:", class: "d-none d-sm-inline"), - tag.span("#{t_s[key][:abbr]}:", class: "d-inline d-sm-none") - ].safe_join, - data: { map_target: "#{key}Input", action: "map#bufferInputs" } - ) - end %> - <% end %> - <% end %> - - <%= collapse_help_block(nil, id: "geolocation_help") do %> - <%= tag.p(:form_observations_click_point.l) %> - <%= tag.p(:form_observations_lat_long_help.t) %> - <% end %> - - <%= check_box_with_label(form: f, field: :gps_hidden, - label: :form_observations_gps_hidden.l) %> - - <%= render(partial: "shared/form_location_feedback", locals: { button: button_name } ) %> <%= autocompleter_field( - form: f, field: :place_name, type: :location, + form: f, field: :place_name, type: :location, class: "mb-0", label: [tag.span("#{:WHERE.l}:", class: "unconstrained-label"), tag.span("#{:form_observations_locality_contains.l}:", class: "constrained-label"), @@ -85,25 +66,58 @@ t_s = { } ) %> - <%= render(partial: "locations/form/bounds_hidden_fields", - locals: { location: @location, target_controller: :map }) %> - - <%= check_box_with_label( form: f, field: :is_collection_location, label: :form_observations_is_collection_location.l, - help: :form_observations_is_collection_location_help.t + help: :form_observations_is_collection_location_help.t, + class: "ml-5 mb-5" ) %> + <%= render(partial: "locations/form/bounds_hidden_fields", + locals: { location: @location, target_controller: :map }) %> + + + + <%= tag.p do + [tag.strong("#{:GEOLOCATION.l}:"), + collapse_info_trigger("geolocation_help")].safe_join(" ") + end %> + + <%= tag.div(class: "row no-gutters", + id: "observation_lat_lng_alt") do %> + <% [:lat, :lng, :alt].each do |key| %> + <%= tag.div(class: "col-xs-4") do + text_field_with_label( + form: f, field: key, class: "mb-0", addon: t_s[key][:addon], + label: [ + tag.span("#{t_s[key][:full]}:", class: "d-none d-sm-inline"), + tag.span("#{t_s[key][:abbr]}:", class: "d-inline d-sm-none") + ].safe_join, + data: { map_target: "#{key}Input", action: "map#bufferInputs" } + ) + end %> + <% end %> + <% end %> + + <%= collapse_help_block(nil, id: "geolocation_help") do %> + <%= tag.p(:form_observations_click_point.l) %> + <%= tag.p(:form_observations_lat_long_help.t) %> + <% end %> + + <%= check_box_with_label( + form: f, field: :gps_hidden, label: :form_observations_gps_hidden.l, + class: "ml-5 mb-5" + ) %> + + <% if logging_optional %> <%= check_box_with_label( form: f, field: :log_change, checked: "checked", label: :form_observations_log_change.t ) %> <% end %> - <% end %> <% end %> @@ -111,12 +125,11 @@ t_s = { <%= tag.div(class: "col-xs-12 col-md-6", id: "observation_geolocation") do %> <%= render( - partial: "shared/form_location_map", - locals: { id: "observation_form_map", map_type: "observation" } - ) %> + partial: "shared/form_location_map", + locals: { id: "observation_form_map", map_type: "observation" } + ) %> <% end %> - <% end %> <% end %> diff --git a/app/views/controllers/observations/form/_identify_specimen.erb b/app/views/controllers/observations/form/_identify_specimen.erb new file mode 100644 index 0000000000..d02630e453 --- /dev/null +++ b/app/views/controllers/observations/form/_identify_specimen.erb @@ -0,0 +1,29 @@ +<%# locals: (f:, action:, button_name:, include_naming:) -%> + +<%= panel_block( + id: "observation_identification", + heading: "#{:IDENTIFICATION.l} + #{:SPECIMEN.l}", + collapse: "observation_specimen_inner", + open: false +) do %> + <%= tag.div(class: "row mt-3") do %> + <%= tag.div(class: "col-xs-12 col-lg-6") do %> + <% if include_naming + naming_locals = { + f: f, + action: action, + button_name: button_name, + show_reasons: false, + unfocused: true, + name_help: :form_naming_name_help_leave_blank.t + } %> + <%= render(partial: "observations/namings/fields", + locals: naming_locals) %> + <% end %> + <% end %> + <%= tag.div(class: "col-xs-12 col-lg-6") do %> + <%= render(partial: "observations/form/specimen_section", + locals: { f:, action: }) %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/controllers/observations/form/_identify_step.erb b/app/views/controllers/observations/form/_identify_step.erb deleted file mode 100644 index 239d0c5dd6..0000000000 --- a/app/views/controllers/observations/form/_identify_step.erb +++ /dev/null @@ -1,38 +0,0 @@ -<%# locals: (f:, action:, button_name:, include_naming:) -%> - -<%= tab_panel(id: "identify") do %> - <%= panel_block(id: "observation_identification", - heading: "#{:IDENTIFICATION.l} + #{:NOTES.l}") do %> - <%= tag.div(class: "row mt-3") do %> - <%= tag.div(class: "col-xs-12 col-lg-6") do %> - <% if include_naming - naming_locals = { - f: f, - action: action, - button_name: button_name, - show_reasons: false, - unfocused: true, - name_help: :form_naming_name_help_leave_blank.t - } %> - <%= render(partial: "observations/namings/fields", - locals: naming_locals) %> - <% end %> - <%= render(partial: "observations/form/specimen_section", - locals: { f:, action: }) %> - <% end %> - <%= tag.div(class: "col-xs-12 col-lg-6") do %> - <%= render(partial: "shared/notes_fields", - locals: { form: f, - fields: @observation.form_notes_parts(@user) }) %> - <% end %> - <% end %> - - <%= tag.div(class: "row mt-5 text-center", id: "step-nav-2") do - [ - tab_link(:BACK.l, id: "record", button: true), - tab_link(:NEXT.l, id: "add_to", button: true), - submit_button(form: f, button: button_name) - ].safe_join(" ") - end %> - <% end %> -<% end %> diff --git a/app/views/controllers/observations/form/_images.html.erb b/app/views/controllers/observations/form/_images.html.erb index ed2b3db2d1..e7676c021a 100644 --- a/app/views/controllers/observations/form/_images.html.erb +++ b/app/views/controllers/observations/form/_images.html.erb @@ -12,13 +12,6 @@ i.e. not observation[good_image_ids]. It's a top-level field. --%> <%= tag.div(id: "observation_images") do %> - <%= hidden_field_tag(:good_image_ids, - @good_images.map { |img| img.id }.join(" "), - data: { form_images_target: "goodImageIds" }) %> - - <%= f.hidden_field(:thumb_image_id, - data: { form_images_target: "thumbImageId" }) %> - <%= tag.div(class: "panel-body border-bottom") do [ tag.h4(:IMAGES.l, class: "panel-title d-inline-block mr-4"), @@ -32,7 +25,12 @@ i.e. not observation[good_image_ids]. It's a top-level field. --%> data: { action: "change->form-images#addSelectedFiles" } ) ].safe_join - end + end, + hidden_field_tag(:good_image_ids, + @good_images.map { |img| img.id }.join(" "), + data: { form_images_target: "goodImageIds" }), + f.hidden_field(:thumb_image_id, + data: { form_images_target: "thumbImageId" }) ].safe_join end %> diff --git a/app/views/controllers/observations/form/_record_step.erb b/app/views/controllers/observations/form/_record_step.erb index de45d202df..a49bdf2488 100644 --- a/app/views/controllers/observations/form/_record_step.erb +++ b/app/views/controllers/observations/form/_record_step.erb @@ -16,5 +16,11 @@ <%= render(partial: "observations/form/details", locals: { f:, button_name:, location:, logging_optional: }) %> + <%= tag.div(class: "panel-body mt-4") do + tag.div(class: "text-center", id: "step-nav-1") do + tab_link(:NEXT.l, id: "identify", button: true) + end + end %> + <% end %> <% end %> diff --git a/app/views/controllers/observations/namings/_fields.erb b/app/views/controllers/observations/namings/_fields.erb index 3c1ac6ee3c..86a4aa711b 100644 --- a/app/views/controllers/observations/namings/_fields.erb +++ b/app/views/controllers/observations/namings/_fields.erb @@ -23,14 +23,19 @@ confidences = options_for_select(menu, @vote&.value) select_opts = { include_blank: ["new", "create"].include?(action_name) } context ||= "blank" name_help ||= :form_naming_name_help.t +feedback = if @given_name.present? + tag.div do + render(partial: "shared/form_name_feedback", + locals: feedback_locals) + end + else + "" + end %> <%= [ - tag.div do - render(partial: "shared/form_name_feedback", - locals: feedback_locals) if @given_name.present? - end, + feedback, fields_for(:naming) do |f_n| [ autocompleter_field( @@ -49,5 +54,5 @@ name_help ||= :form_naming_name_help.t ].safe_join end, hidden_field_tag(:context, context) -].safe_join +].compact.safe_join %>