From adcc934a929588e771e53fc7bb436350a16b5e8d Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 07:50:04 -0700 Subject: [PATCH 01/11] Update _notes_form.html.erb --- .../controllers/shared/_notes_form.html.erb | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/controllers/shared/_notes_form.html.erb b/app/views/controllers/shared/_notes_form.html.erb index 1247302353..7e38f4dca5 100644 --- a/app/views/controllers/shared/_notes_form.html.erb +++ b/app/views/controllers/shared/_notes_form.html.erb @@ -1,21 +1,21 @@ <%# Notes section of a form %> -
+<%= tag.div(id: "#{form.object_name}_notes") do %> -

- <%= :NOTES.t %>: -

-
- <% fields.each do |field| %> - <%= form.fields_for(:notes) do |f_n| %> - <%= text_area_with_label( - form: f_n, rows: 1, label: field.label + ": ", - field: field.name, - value: field.value) %> + <%= tag.p do + tag.span("#{:NOTES.t}:", class:"font-weight-bold") + end %> + <%= tag.div(class: "ml-5") do %> + <% form.fields_for(:notes) do |f_n| %> + <% fields.each do |field| %> + <%= text_area_with_label( + form: f_n, rows: 1, label: field.label + ": ", + field: field.name, + value: field.value) %> + <% end # each do field %> <% end # form.fields_for(:notes) %> - <% end # each do field %> -
+ <% end %> -
+<% end %> From 8111c9498ecaed47ab1bd0a52c1411fcd21fb0c2 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 07:50:47 -0700 Subject: [PATCH 02/11] rename notes_form notes_fields --- app/views/controllers/field_slips/_form.html.erb | 2 +- .../shared/{_notes_form.html.erb => _notes_fields.html.erb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename app/views/controllers/shared/{_notes_form.html.erb => _notes_fields.html.erb} (100%) diff --git a/app/views/controllers/field_slips/_form.html.erb b/app/views/controllers/field_slips/_form.html.erb index bab0e45f5e..8f9afb0aea 100644 --- a/app/views/controllers/field_slips/_form.html.erb +++ b/app/views/controllers/field_slips/_form.html.erb @@ -33,7 +33,7 @@ <%= autocompleter_field(form: form, field: :location, label: :LOCATION.t + ":", type: :location) %> - <%= render(partial: "shared/notes_form", + <%= render(partial: "shared/notes_fields", locals: { form:, fields: field_slip.notes_fields }) %> <%= autocompleter_field(form: form, field: :field_slip_id, diff --git a/app/views/controllers/shared/_notes_form.html.erb b/app/views/controllers/shared/_notes_fields.html.erb similarity index 100% rename from app/views/controllers/shared/_notes_form.html.erb rename to app/views/controllers/shared/_notes_fields.html.erb From 4f63d08b99ae3446388481251bb147bea1b196c4 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 09:53:27 -0700 Subject: [PATCH 03/11] Generalize check_for_help_block, use in obs details --- app/helpers/forms_helper.rb | 24 ++++++++++++++++--- .../observations/form/_details.html.erb | 5 +--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/helpers/forms_helper.rb b/app/helpers/forms_helper.rb index a3f0684e99..7c7e8bf89a 100644 --- a/app/helpers/forms_helper.rb +++ b/app/helpers/forms_helper.rb @@ -86,6 +86,7 @@ def js_button(**args, &block) # def check_box_with_label(**args) args = auto_label_if_form_is_account_prefs(args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args) wrap_class = form_group_wrap_class(args, "checkbox") @@ -94,6 +95,9 @@ def check_box_with_label(**args) args[:form].label(args[:field]) do concat(args[:form].check_box(args[:field], opts)) concat(args[:label]) + if args[:between].present? + concat(tag.div(class: "d-inline-block ml-3") { args[:between] }) + end concat(args[:append]) if args[:append].present? end end @@ -116,6 +120,7 @@ def check_button_with_label(**args) # Bootstrap radio: form, field, value, label, class, checked def radio_with_label(**args) args = auto_label_if_form_is_account_prefs(args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args, [:value]) wrap_class = form_group_wrap_class(args, "radio") @@ -124,6 +129,9 @@ def radio_with_label(**args) args[:form].label("#{args[:field]}_#{args[:value]}") do concat(args[:form].radio_button(args[:field], args[:value], opts)) concat(args[:label]) + if args[:between].present? + concat(tag.div(class: "d-inline-block ml-3") { args[:between] }) + end concat(args[:append]) if args[:append].present? end end @@ -147,6 +155,7 @@ def radio_button_with_label(**args) def text_field_with_label(**args) args = auto_label_if_form_is_account_prefs(args) args = check_for_optional_or_required_note(args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args) opts[:class] = "form-control" @@ -274,6 +283,7 @@ def select_with_label(**args) args = auto_label_if_form_is_account_prefs(args) args = select_generate_default_options(args) args = check_for_optional_or_required_note(args) + args = check_for_help_block(args) opts = separate_field_options_from_args( args, [:options, :select_opts, :start_year, :end_year] @@ -311,6 +321,7 @@ def select_generate_default_options(args) # it identifies the wrapping div. (That's also valid HTML.) # https://stackoverflow.com/a/16426122/3357635 def date_select_with_label(**args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args, [:object, :data]) opts[:class] = "form-control" opts[:data] = { controller: "year-input" }.merge(args[:data] || {}) @@ -352,6 +363,7 @@ def date_select_opts(args = {}) # Bootstrap number_field def number_field_with_label(**args) args = auto_label_if_form_is_account_prefs(args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args) opts[:class] = "form-control" opts[:min] ||= 1 @@ -366,6 +378,7 @@ def number_field_with_label(**args) # Bootstrap password_field def password_field_with_label(**args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args) opts[:class] = "form-control" opts[:value] ||= "" @@ -424,6 +437,7 @@ def static_text_with_label(**args) # Bootstrap url_field def url_field_with_label(**args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args) opts[:class] = "form-control" opts[:value] ||= "" @@ -438,6 +452,7 @@ def url_field_with_label(**args) # Bootstrap file input field with client-side size validation. def file_field_with_label(**args) + args = check_for_help_block(args) opts = separate_field_options_from_args(args) input_span_class = "file-field btn btn-default" max_size = MO.image_upload_max_size @@ -555,15 +570,18 @@ def check_for_optional_or_required_note(args) # Adds a help block to the field, with a collapse trigger beside the label. def check_for_help_block(args) - return args unless args[:help].present? && args[:field].present? + unless args[:help].present? && args[:field].present? && args[:form].present? + return args + end + id = "#{args[:form].object_name}_#{args[:field]}_help" args[:between] = capture do - concat(collapse_info_trigger("#{args[:field]}_help")) + concat(collapse_info_trigger(id)) concat(args[:between]) end args[:append] = capture do concat(args[:append]) - concat(collapse_help_block(nil, id: "#{args[:field]}_help") do + concat(collapse_help_block(nil, id:) do concat(args[:help]) end) end diff --git a/app/views/controllers/observations/form/_details.html.erb b/app/views/controllers/observations/form/_details.html.erb index 0909fff37a..907e514b13 100644 --- a/app/views/controllers/observations/form/_details.html.erb +++ b/app/views/controllers/observations/form/_details.html.erb @@ -65,7 +65,7 @@ label: [tag.span("#{:WHERE.l}:", class: "unconstrained-label"), tag.span("#{:form_observations_locality_contains.l}:", class: "constrained-label")].safe_join(" "), - between: collapse_info_trigger("where_help"), + help: observation_location_help, hidden: location&.id, hidden_data: { map_target: "locationId", north: location&.north, south: location&.south, @@ -76,9 +76,6 @@ "form-exif:pointChanged@window->autocompleter#swap" ].join(" ") } ) %> - <%= collapse_help_block(nil, id: "where_help") do - observation_location_help - end %> From 76ba6e86f3f6c491ef5726eab2e9415e002e9dfc Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 09:53:37 -0700 Subject: [PATCH 04/11] Obs identification section --- .../controllers/observations/_form.html.erb | 38 +++++-------- .../form/_collection_number.html.erb | 36 +++++------- .../form/_herbarium_record.html.erb | 49 +++++++--------- .../form/_identification.html.erb | 26 +++++++++ .../observations/form/_notes.html.erb | 56 ++++++++++-------- .../form/_specimen_section.html.erb | 38 ++++++------- .../observations/namings/_fields.erb | 39 ++++--------- .../controllers/shared/_notes_fields.html.erb | 57 ++++++++++++++----- config/locales/en.txt | 2 + 9 files changed, 175 insertions(+), 166 deletions(-) create mode 100644 app/views/controllers/observations/form/_identification.html.erb diff --git a/app/views/controllers/observations/_form.html.erb b/app/views/controllers/observations/_form.html.erb index a022dffaa9..95aa5b2c66 100644 --- a/app/views/controllers/observations/_form.html.erb +++ b/app/views/controllers/observations/_form.html.erb @@ -35,13 +35,13 @@ end <%= form_with( model: @observation, - url: add_query_param(action: action, id: @observation, - approved_name: @given_name, - approved_where: @place_name), - method: method, + url: add_query_param(action:, id: @observation, + approved_name: @given_name, + approved_where: @place_name), + method:, multipart: true, id: "observation_form", - data: data + data: ) do |f| %> <%= if @field_code @@ -53,29 +53,17 @@ end <% if include_images %> <%= render(partial: "observations/form/images", locals: { f: f }) %> - <% end # if include_images %> - - <%= render(partial: "observations/form/details", - locals: { f: f, button_name: button_name, location: @location }) %> + <% end %> - <% if include_naming - # note this is not a separate form! just fields - 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) %> + <% ############################# Details ################################ %> - <% end # if include_naming %> + <%= render(partial: "observations/form/details", + locals: { f:, button_name:, location: @location }) %> - <%= render(partial: "observations/form/specimen_section", - locals: { f: f, button_name: button_name }) %> + <% ########################## Identification ############################ %> - <%= render(partial: "observations/form/notes", locals: { f: f }) %> + <%= render(partial: "observations/form/identification", + locals: { f:, action:, button_name:, include_naming: }) %> <% ####################################################################### %> @@ -85,7 +73,7 @@ end <% if @projects.any? %> <%= render(partial: "observations/form/projects", - locals: { f: f, button_name: button_name }) %> + locals: { f:, button_name: }) %> <% end %> <% if @lists.any? %> diff --git a/app/views/controllers/observations/form/_collection_number.html.erb b/app/views/controllers/observations/form/_collection_number.html.erb index cd39687655..0c3045b15d 100644 --- a/app/views/controllers/observations/form/_collection_number.html.erb +++ b/app/views/controllers/observations/form/_collection_number.html.erb @@ -1,23 +1,17 @@ <%# specimen/collection_number section of create_observation form %> -
- -
- <%= fields_for(:collection_number) do |fcn| %> - <%= text_field_with_label(form: fcn, field: :name, - value: @collectors_name, - label: :collection_number_name.t + ":") %> - <%= text_field_with_label( - form: fcn, field: :number, value: @collectors_number, - label: :collection_number_number.t + ":", - data: { action: "specimen#checkCheckbox" }) %> - <% end # fields_for %> -
- -
- <%= help_block_with_arrow("left", id: "collection_number_help") do %> - <%= :form_observations_collection_number_help.t %> - <% end # help_block_with_arrow do %> -
- -
+<%= tag.div(class: "mt-3") do %> + <% fields_for(:collection_number) do |fcn| %> + <%= text_field_with_label( + form: fcn, field: :name, + value: @collectors_name, + label: :collection_number_name.t + ":", + help: :form_observations_collection_number_help.t + ) %> + <%= text_field_with_label( + form: fcn, field: :number, value: @collectors_number, + label: :collection_number_number.t + ":", + data: { action: "specimen#checkCheckbox" } + ) %> + <% end %> +<% end %> diff --git a/app/views/controllers/observations/form/_herbarium_record.html.erb b/app/views/controllers/observations/form/_herbarium_record.html.erb index 3f40446e29..26bfc0adec 100644 --- a/app/views/controllers/observations/form/_herbarium_record.html.erb +++ b/app/views/controllers/observations/form/_herbarium_record.html.erb @@ -1,32 +1,21 @@ <%# specimen/herbarium_record section of create_observation form %> -
- -
- <%= fields_for(:herbarium_record) do |fhr| %> - - <%= autocompleter_field( - form: fhr, field: :herbarium_name, type: :herbarium, - value: @herbarium_name, hidden: @herbarium_id, - label: "#{:herbarium_record_herbarium_name.t}:", - ) %> - - <%= text_field_with_label( - form: fhr, field: :accession_number, value: @accession_number, - label: "#{:herbarium_record_accession_number.t}:", - data: { action: "specimen#checkCheckbox" } - ) %> - - <%= text_field_with_label(form: fhr, field: :notes, value: "", - label: "#{:herbarium_record_notes.t}:") %> - - <% end # fields_for(:herbarium_record) %> -
- -
- <%= help_block_with_arrow("left", id: "herbarium_record_help") do %> - <%= :form_observations_herbarium_record_help.t %> - <% end # help_block_with_arrow do %> -
- -
+<%= tag.div(class: "mt-3") do %> + <% fields_for(:herbarium_record) do |fhr| %> + <%= autocompleter_field( + form: fhr, field: :herbarium_name, type: :herbarium, + value: @herbarium_name, hidden: @herbarium_id, + label: "#{:herbarium_record_herbarium_name.t}:", + help: :form_observations_herbarium_record_help.t + ) %> + <%= text_field_with_label( + form: fhr, field: :accession_number, value: @accession_number, + label: "#{:herbarium_record_accession_number.t}:", + data: { action: "specimen#checkCheckbox" } + ) %> + <%= text_field_with_label( + form: fhr, field: :notes, value: "", + label: "#{:herbarium_record_notes.t}:" + ) %> + <% end %> +<% end %> diff --git a/app/views/controllers/observations/form/_identification.html.erb b/app/views/controllers/observations/form/_identification.html.erb new file mode 100644 index 0000000000..3d37843571 --- /dev/null +++ b/app/views/controllers/observations/form/_identification.html.erb @@ -0,0 +1,26 @@ +<%= panel_block(id: "observation_identification", + heading: :IDENTIFICATION.l) do %> + <%= tag.div(class: "row mt-3") do %> + <%= tag.div(class: "col-xs-12 col-sm-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:, button_name: }) %> + <% end %> + <%= tag.div(class: "col-xs-12 col-sm-6") do %> + <%= render(partial: "shared/notes_fields", + locals: { form: f, + fields: @observation.form_notes_parts(@user) }) %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/controllers/observations/form/_notes.html.erb b/app/views/controllers/observations/form/_notes.html.erb index f3c74ac78f..d9c9e245d4 100644 --- a/app/views/controllers/observations/form/_notes.html.erb +++ b/app/views/controllers/observations/form/_notes.html.erb @@ -1,4 +1,4 @@ -<%# Notes section of create_observation form %> +<%# Notes section of any form %> <% # Users may have custom notes "parts". This prints a single large textarea and @@ -6,38 +6,44 @@ # smaller textareas and a general textile help link. help = general_help = other = nil -if @observation.form_notes_parts(@user) == [Observation.other_notes_part] +if fields == [Observation.other_notes_part] help = [tag.p(:form_observations_notes_help.t), tag.p(:shared_textile_help.l)].safe_join other = true rows = 10 else general_help = tag.p do - [ - tag.strong("#{:NOTES.t}:", class: "mr-3"), - collapse_info_trigger("notes_help"), - collapse_help_block(nil, :shared_textile_help.l, id: "notes_help") - ].safe_join - end + [ + tag.strong("#{:NOTES.t}:", class: "mr-3"), + collapse_info_trigger("notes_help"), + collapse_help_block(nil, :shared_textile_help.l, id: "notes_help") + ].safe_join + end rows = 1 end +indent = form.object_name == "observation" ? "" : "ml-5" +debugger %> -<%= tag.div(class: "mt-3", id: "observation_notes") do - tag.div(class: "row") do - tag.div(class: "col-xs-12 col-sm-6") do %> - <%= general_help %> - <%= f.fields_for(:notes) do |f_n| %> - <% @observation.form_notes_parts(@user).each do |part| %> - <%= text_area_with_label( - form: f_n, rows:, help:, - label: other ? "#{:NOTES.t}:" : "#{strip_tags(part.tl)}:", - field: @observation.notes_normalized_key(part), - value: @observation.notes_part_value(part) - ) %> - <% end # each do part %> - <% end # f.fields_for(:notes) %> - <% end - end -end %> +<%= tag.div(class: "mt-3", id: "#{form.object_name}_notes") do %> + <%= general_help %> + <%= tag.div(class: indent) do %> + <%= form.fields_for(:notes) do |f_n| %> + <% fields.each do |field| %> + <% if form.object_name == "observation" + field = @observation.notes_normalized_key(field) + value = @observation.notes_part_value(field) + label = other ? "#{:NOTES.t}:" : "#{strip_tags(field.tl)}:" + else + field = field.name + value = field.value + label = field.label + ":" + end %> + <%= text_area_with_label( + form: f_n, rows:, help:, field:, value:, label: + ) %> + <% end %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/controllers/observations/form/_specimen_section.html.erb b/app/views/controllers/observations/form/_specimen_section.html.erb index 4a9ea69d1e..7fc50ecf41 100644 --- a/app/views/controllers/observations/form/_specimen_section.html.erb +++ b/app/views/controllers/observations/form/_specimen_section.html.erb @@ -8,28 +8,22 @@ data: { controller: "specimen", user_pref: (!@user.try(&:hide_specimen_stuff?)) }) do %> -
-
- <%= check_box_with_label( - form: f, field: :specimen, - label: :form_observations_specimen_available.t, - data: { specimen_target: "checkbox", - action: "change->specimen#hideShowFields" } - ) %> - <%= help_block_with_arrow("up") do %> - <%= :form_observations_specimen_available_help.t %> - <% end # help_block_with_arrow do %> - - - <% if button_name == :SAVE_EDITS.l %> - <%= help_block_with_arrow(nil) do - :form_observations_edit_specimens_help.t - end %> - <% end # if button_name %> - - -
-
+ <%= tag.div(class: "mt-3") do %> + <%= check_box_with_label( + form: f, field: :specimen, + label: :form_observations_specimen_available.t, + help: :form_observations_specimen_available_help.t, + data: { specimen_target: "checkbox", + action: "change->specimen#hideShowFields" } + ) %> + + <% if button_name == :SAVE_EDITS.l %> + <%= help_block_with_arrow(nil) do + :form_observations_edit_specimens_help.t + end %> + <% end # if button_name %> + + <% end %> <% if button_name == :CREATE.l %> diff --git a/app/views/controllers/observations/namings/_fields.erb b/app/views/controllers/observations/namings/_fields.erb index 05f7290fcf..3c1ac6ee3c 100644 --- a/app/views/controllers/observations/namings/_fields.erb +++ b/app/views/controllers/observations/namings/_fields.erb @@ -33,35 +33,18 @@ name_help ||= :form_naming_name_help.t end, fields_for(:naming) do |f_n| [ - tag.div(class: "row mt-3") do - [ - tag.div(class: "col-xs-12 col-sm-6") do - autocompleter_field( - form: f_n, field: :name, type: :name, label: "#{:WHAT.t}:", - value: @given_name, autofocus: focus_on_name - ) - end, - tag.div(class: "col-xs-12 col-sm-6") do - help_block_with_arrow("left", id: "naming_name_help") do - tag.p(name_help) - end - end - ].safe_join + autocompleter_field( + form: f_n, field: :name, type: :name, label: "#{:WHAT.t}:", + value: @given_name, autofocus: focus_on_name, help: name_help + ), + f_n.fields_for(:vote) do |f_v| + select_with_label(form: f_v, field: :value, + options: confidences, select_opts: select_opts, + label: :form_naming_confidence.t + ":", + autofocus: focus_on_vote) end, - tag.div(class: "row mt-3") do - tag.div(class: "col-xs-12 col-sm-6") do - [ - f_n.fields_for(:vote) do |f_v| - select_with_label(form: f_v, field: :value, - options: confidences, select_opts: select_opts, - label: :form_naming_confidence.t + ":", - autofocus: focus_on_vote) - end, - f_n.fields_for(:reasons) do |f_r| - naming_form_reasons_fields(f_r, @reasons) - end - ].safe_join - end + f_n.fields_for(:reasons) do |f_r| + naming_form_reasons_fields(f_r, @reasons) end ].safe_join end, diff --git a/app/views/controllers/shared/_notes_fields.html.erb b/app/views/controllers/shared/_notes_fields.html.erb index 7e38f4dca5..baeeb2d1df 100644 --- a/app/views/controllers/shared/_notes_fields.html.erb +++ b/app/views/controllers/shared/_notes_fields.html.erb @@ -1,21 +1,48 @@ -<%# Notes section of a form %> +<%# Notes section of any form %> +<% +# Users may have custom notes "parts". This prints a single large textarea and +# textile help block if there's only one notes part. Otherwise, it prints +# smaller textareas and a general textile help link. + +help = general_help = other = nil +if fields == [Observation.other_notes_part] + help = [tag.p(:form_observations_notes_help.t), + tag.p(:shared_textile_help.l)].safe_join + other = true + rows = 10 +else + general_help = tag.p do + [ + tag.strong("#{:NOTES.t}:", class: "mr-3"), + collapse_info_trigger("notes_help"), + collapse_help_block(nil, :shared_textile_help.l, id: "notes_help") + ].safe_join + end + rows = 1 +end +indent = form.object_name == "observation" ? "" : "ml-5" +%> <%= tag.div(id: "#{form.object_name}_notes") do %> - - <%= tag.p do - tag.span("#{:NOTES.t}:", class:"font-weight-bold") - end %> - <%= tag.div(class: "ml-5") do %> - <% form.fields_for(:notes) do |f_n| %> - <% fields.each do |field| %> + <%= general_help %> + <%= tag.div(class: indent) do %> + <%= form.fields_for(:notes) do |f_n| %> + <% fields.each do |part| %> + <% if form.object_name == "observation" + field = @observation.notes_normalized_key(part) + value = @observation.notes_part_value(part) + label = other ? "#{:NOTES.t}:" : "#{part.to_s.humanize}:" + else + field = part.name + value = part.value + label = part.label + ":" + end %> <%= text_area_with_label( - form: f_n, rows: 1, label: field.label + ": ", - field: field.name, - value: field.value) %> - <% end # each do field %> - <% end # form.fields_for(:notes) %> + form: f_n, rows:, help:, field:, value:, label: + ) %> + <% end %> + <% end %> <% end %> - -<% end %> +<% end %> diff --git a/config/locales/en.txt b/config/locales/en.txt index 04ee35ee6e..794c71dadd 100644 --- a/config/locales/en.txt +++ b/config/locales/en.txt @@ -270,6 +270,8 @@ field_slip: field slip FIELD_SLIPS: Field Slips field_slips: field slips + IDENTIFICATION: Identification + identification: identification IMAGE: Image image: image IMAGES: Images From 15d01ed73816ed587b82f8093dfda1d677a6ea72 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 09:54:00 -0700 Subject: [PATCH 05/11] Delete _notes.html.erb --- .../observations/form/_notes.html.erb | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 app/views/controllers/observations/form/_notes.html.erb diff --git a/app/views/controllers/observations/form/_notes.html.erb b/app/views/controllers/observations/form/_notes.html.erb deleted file mode 100644 index d9c9e245d4..0000000000 --- a/app/views/controllers/observations/form/_notes.html.erb +++ /dev/null @@ -1,49 +0,0 @@ -<%# Notes section of any form %> - -<% -# Users may have custom notes "parts". This prints a single large textarea and -# textile help block if there's only one notes part. Otherwise, it prints -# smaller textareas and a general textile help link. - -help = general_help = other = nil -if fields == [Observation.other_notes_part] - help = [tag.p(:form_observations_notes_help.t), - tag.p(:shared_textile_help.l)].safe_join - other = true - rows = 10 -else - general_help = tag.p do - [ - tag.strong("#{:NOTES.t}:", class: "mr-3"), - collapse_info_trigger("notes_help"), - collapse_help_block(nil, :shared_textile_help.l, id: "notes_help") - ].safe_join - end - rows = 1 -end -indent = form.object_name == "observation" ? "" : "ml-5" -debugger -%> - -<%= tag.div(class: "mt-3", id: "#{form.object_name}_notes") do %> - <%= general_help %> - <%= tag.div(class: indent) do %> - <%= form.fields_for(:notes) do |f_n| %> - <% fields.each do |field| %> - <% if form.object_name == "observation" - field = @observation.notes_normalized_key(field) - value = @observation.notes_part_value(field) - label = other ? "#{:NOTES.t}:" : "#{strip_tags(field.tl)}:" - else - field = field.name - value = field.value - label = field.label + ":" - end %> - <%= text_area_with_label( - form: f_n, rows:, help:, field:, value:, label: - ) %> - <% end %> - <% end %> - <% end %> -<% end %> - From 0318deae8c28ac742708353d8fe7016ada909fdd Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 10:38:44 -0700 Subject: [PATCH 06/11] Update _identification.html.erb --- app/views/controllers/observations/form/_identification.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/controllers/observations/form/_identification.html.erb b/app/views/controllers/observations/form/_identification.html.erb index 3d37843571..dcb90ba16b 100644 --- a/app/views/controllers/observations/form/_identification.html.erb +++ b/app/views/controllers/observations/form/_identification.html.erb @@ -23,4 +23,5 @@ fields: @observation.form_notes_parts(@user) }) %> <% end %> <% end %> + <%= submit_button(form: f, button: button_name, center: true) %> <% end %> From 4446583e9198519cf489a517c22371d676df1f7a Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 10:38:51 -0700 Subject: [PATCH 07/11] Projects and lists --- .../controllers/observations/_form.html.erb | 10 +- .../observations/form/_projects.html.erb | 125 +++++++++--------- .../form/_projects_and_lists.html.erb | 23 ++++ .../observations/form/_species_lists.html.erb | 31 +++-- 4 files changed, 104 insertions(+), 85 deletions(-) create mode 100644 app/views/controllers/observations/form/_projects_and_lists.html.erb diff --git a/app/views/controllers/observations/_form.html.erb b/app/views/controllers/observations/_form.html.erb index 95aa5b2c66..0ccce56202 100644 --- a/app/views/controllers/observations/_form.html.erb +++ b/app/views/controllers/observations/_form.html.erb @@ -68,18 +68,10 @@ end <% ####################################################################### %> <% if @projects.any? || @lists.any? %> - <%= submit_button(form: f, button: button_name, center: true) %> - <% end %> - - <% if @projects.any? %> - <%= render(partial: "observations/form/projects", + <%= render(partial: "observations/form/projects_and_lists", locals: { f:, button_name: }) %> <% end %> - <% if @lists.any? %> - <%= render(partial: "observations/form/species_lists", locals: { f: f }) %> - <% end %> - <%= submit_button(form: f, button: button_name, center: true) %> <% if logging_optional %> diff --git a/app/views/controllers/observations/form/_projects.html.erb b/app/views/controllers/observations/form/_projects.html.erb index 54ad88c557..cec864f6be 100644 --- a/app/views/controllers/observations/form/_projects.html.erb +++ b/app/views/controllers/observations/form/_projects.html.erb @@ -1,71 +1,72 @@ <%# Projects section of create_observation form %> -<%= fields_for(:project) do |f_p| %> -
+<% +error_messages = suspect_messages = nil +if @error_checked_projects.any? + error_messages = { + level: "danger", + list: @error_checked_projects, + help: :form_observations_projects_out_of_range_help.t + } +end +if @suspect_checked_projects.any? + suspect_messages = { + level: "warning", + list: @suspect_checked_projects, + help: :form_observations_projects_out_of_range_help.t + + :form_observations_projects_out_of_range_admin_help.t(button_name:) + } +end +%> - <% if @error_checked_projects.any? %> -
-
- <%= tag.p( - "#{:form_observations_projects_out_of_range.t( - date: @observation.when, - place_name: @observation.place_name - )}:" - ) %> -
    - <% @error_checked_projects.each do |proj| %> - <%= tag.li("#{proj.title} (#{proj.constraints})") %> - <% end %> -
- <%= tag.p( - :form_observations_projects_out_of_range_help.t - )%> -
-
+<%= tag.div(id: "observation_projects") do %> + <%= fields_for(:project) do |f_p| %> + + <% if error_messages.present? || suspect_messages.present? %> + <%= tag.div(id: "project_messages") do + [error_messages, suspect_messages].compact.each do |messages| + tag.div(class: "alert alert-#{messages.level}") do + [ + tag.p( + "#{:form_observations_projects_out_of_range.t( + date: @observation.when, + place_name: @observation.place_name + )}:" + ), + tag.ul do + messages.list.each do |proj| + tag.li("#{proj.title} (#{proj.constraints})") + end + end, + tag.p(messages.help) + ].safe_join + end + end + end %> + <%= check_box_with_label( + form: f_p, field: :ignore_proj_conflicts, + label: :form_observations_projects_ignore_project_constraints.t + ) %> <% end %> - <% if @suspect_checked_projects.any? %> -
-
- <%= tag.p( - "#{:form_observations_projects_out_of_range.t( - date: @observation.when, - place_name: @observation.place_name - )}:" - ) %> -
    - <% @suspect_checked_projects.each do |proj| %> - <%= tag.li("#{proj.title} (#{proj.constraints})") %> - <% end %> -
- <%= tag.p( - :form_observations_projects_out_of_range_help.t + - :form_observations_projects_out_of_range_admin_help.t(button_name: button_name) - )%> - <%= check_box_with_label( - form: f_p, field: :ignore_proj_conflicts, - label: :form_observations_projects_ignore_project_constraints.t - ) %> -
-
+ <%= tag.p do + [ + tag.strong("#{:PROJECTS.l}:", class: "mr-3"), + collapse_info_trigger("project_help"), + collapse_help_block(nil, id: "project_help") do + :form_observations_project_help.t + end + ].safe_join + end %> + + <% @projects.each do |project| %> + <%= check_box_with_label( + form: f_p, field: :"id_#{project.id}", label: project.title, + checked: @project_checks[project.id], + disabled: !project.user_can_add_observation?(@observation, @user) + ) %> <% end %> -
- <%= help_block_with_arrow("left", id: "project_help") do %> - <%= :form_observations_project_help.t %> - <% end %> -
-
- <%= :PROJECTS.t %>: - <% @projects.each do |project| %> - <%= check_box_with_label(form: f_p, field: :"id_#{project.id}", - checked: @project_checks[project.id], - disabled: !project.user_can_add_observation?(@observation, @user), - label: project.title) %> - <% end %> -
-
+ <% end %> <% end %> diff --git a/app/views/controllers/observations/form/_projects_and_lists.html.erb b/app/views/controllers/observations/form/_projects_and_lists.html.erb new file mode 100644 index 0000000000..54ae6c0ac5 --- /dev/null +++ b/app/views/controllers/observations/form/_projects_and_lists.html.erb @@ -0,0 +1,23 @@ +<%# Project and List section of create_observation form %> + +<%= panel_block(id: "observation_projects_and_lists", + heading: "#{:PROJECTS.l}/#{:SPECIES_LISTS.l}") do %> + + <%= tag.div(class: "row mt-3") do %> + <% if @projects.any? %> + <%= tag.div(class: "col-xs-12 col-sm-6") do %> + <%= render(partial: "observations/form/projects", + locals: { f:, button_name: }) %> + <% end %> + <% end %> + <% if @lists.any? %> + <%= tag.div(class: "col-xs-12 col-sm-6") do %> + <%= render(partial: "observations/form/species_lists", + locals: { f: f }) %> + <% end %> + <% end %> + <% end %> + +<% end %> + + diff --git a/app/views/controllers/observations/form/_species_lists.html.erb b/app/views/controllers/observations/form/_species_lists.html.erb index 21d716a315..8c4325d060 100644 --- a/app/views/controllers/observations/form/_species_lists.html.erb +++ b/app/views/controllers/observations/form/_species_lists.html.erb @@ -1,22 +1,25 @@ <%# species_list section of create_observation form %> -
-
- <%= help_block_with_arrow("left", id: "species_lists_help") do %> - <%= :form_observations_list_help.t %> - <% end %> -
-
- <%= :SPECIES_LISTS.t %>: +<%= tag.div(id: "observation_projects") do %> + <%= fields_for(:list) do |f_l| %> + <%= tag.p do + [ + tag.strong("#{:SPECIES_LISTS.l}:", class: "mr-3"), + collapse_info_trigger("species_lists_help"), + collapse_help_block(nil, id: "species_lists_help") do + :form_observations_list_help.t + end + ].safe_join + end %> <%= fields_for(:list) do |f_l| %> <% @lists.each do |list| %> - <%= check_box_with_label(form: f_l, field: :"id_#{list.id}", - checked: @list_checks[list.id], - disabled: !check_permission(list), - label: list.title) %> + <%= check_box_with_label( + form: f_l, field: :"id_#{list.id}", label: list.title, + checked: @list_checks[list.id], disabled: !check_permission(list) + ) %> <% end %> <% end %> -
-
+ <% end %> +<% end %> From 6f973cd08697eb23f2af1d868d32b58ea08926c4 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 10:44:30 -0700 Subject: [PATCH 08/11] Update _details.html.erb redo is_collection_location help --- .../controllers/observations/form/_details.html.erb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/views/controllers/observations/form/_details.html.erb b/app/views/controllers/observations/form/_details.html.erb index 907e514b13..2a1bb8cb0b 100644 --- a/app/views/controllers/observations/form/_details.html.erb +++ b/app/views/controllers/observations/form/_details.html.erb @@ -80,14 +80,10 @@ <%= check_box_with_label( - form: f, field: :is_collection_location, - label: :form_observations_is_collection_location.l, - append: collapse_info_trigger("is_collection_location_help", - class: "ml-3") - ) %> - <%= collapse_help_block(nil, id: "is_collection_location_help") do %> - <%= :form_observations_is_collection_location_help.t %> - <% end %> + form: f, field: :is_collection_location, + label: :form_observations_is_collection_location.l, + help: :form_observations_is_collection_location_help.t + ) %> <% end %> From c6e4055db9c059c4de5f5781b507421d2f412498 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 11:48:56 -0700 Subject: [PATCH 09/11] couple fixes button addon helper location help text obs form system test --- app/helpers/forms_helper.rb | 3 ++- config/locales/en.txt | 8 ++++---- test/system/observation_form_system_test.rb | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/helpers/forms_helper.rb b/app/helpers/forms_helper.rb index 7c7e8bf89a..21fb32cb4b 100644 --- a/app/helpers/forms_helper.rb +++ b/app/helpers/forms_helper.rb @@ -594,7 +594,8 @@ def check_for_help_block(args) def separate_field_options_from_args(args, extras = []) exceptions = [ :form, :field, :label, :class, :width, :inline, :between, :append, - :help, :addon, :optional, :required, :monospace, :type, :wrap_data + :help, :addon, :optional, :required, :monospace, :type, :wrap_data, + :button, :button_data ] + extras args.clone.except(*exceptions) diff --git a/config/locales/en.txt b/config/locales/en.txt index 794c71dadd..cc23143cca 100644 --- a/config/locales/en.txt +++ b/config/locales/en.txt @@ -1578,9 +1578,9 @@ form_locations_notes: "[:Notes]" form_locations_refs: "[:form_names_refs]" form_locations_refs_help: "[:form_names_refs_help]" - form_locations_help: "Help" - form_locations_find_on_map: Find on Map > - form_locations_get_elevation: Get Elevation + form_locations_help: "Here you can define the place where you observed mushrooms, if a matching place doesn't exist in Mushroom Observer already. Please try to define locations that will be reusable by yourself or others. If you have an idea of the location's name, you can start typing and Google will return its best guess of the place you typed, and draw a box of the approximate boundaries on the map. At this point, you can manually edit both the boundaries and the name of the place. More about Locations on MO." + form_locations_find_on_map: Find on Map + form_locations_get_elevation: Get Elevations form_locations_lat_long_help: All values should be in decimal degrees. form_locations_license_help: Select "license":/info/how_to_use#license you want to give for the above text. form_locations_gen_desc_help: Describe the geographical location of this location. @@ -3561,7 +3561,7 @@ # Location help location_help_title: Locations in Mushroom Observer - location_help_intro: "The Mushroom Observer provides two ways to represent the geographic location of an observation. The simplest are latitude and longitude positions associated with the observation. Please keep these accurate to within at least 300 meters (or about 1000 feet). However, the more widely used method is a simple phrase describing the location. For example, \"Beebe Woods, Falmouth, Massachusetts, USA\". The goal of these location names is to provide a consistent, reusable way of talking about where an observation was made without necessarily revealing a precise \"spot\". If you are comfortable provide more precise lat/longs for an observation, the location names are still useful for searches so you are encouraged to provide them as well. The location names should, by default, go from the smallest contained area to the country name. If you prefer to describe your locations as going from the largest (country) down to the smallest contained area, you can change your preference from the default, \"Postal\", to \"Scientific\" on your preference page. There are cases such as \"Great Smoky Mountains National Park, Blount Co., Tennessee, USA\", where the area you are describing overlaps a number of counties, states or even countries. In these cases, the country and other official political boundaries should come at the end as shown in the example.\n\nOriginally, the Mushroom Observer was very loose about these location names, hoping that the users would create a reasonably consistent set of rules and correct each other. After about four years and thousands of location names, we found that there were rules emerging, but they were not applied at all consistently and people were not tending to directly correct each other. Consequently, we have tried to codify these rules and when reasonable to provide warnings if you attempt to create a new location that violates these rules. It is not always possible to correct identify \"bad\" locations, so if you get some warnings, but after reviewing the location decide it should be \"good\", then simply resubmitting the form will force the name into the database. However, all new location names will get reviewed regularly and may get changed to better fit the consensus rules. Below are some examples of \"bad\" and \"good\" location names followed by a more detailed explanation of the current rules. Each example is labeled with the following section that explains the example in more detail. These rules are by no means set it stone and we encourage the discussion and revision of them." + location_help_intro: "The Mushroom Observer provides two ways to represent the geographic location of an observation. The simplest are latitude and longitude positions associated with the observation. Please keep these accurate to within at least 300 meters (or about 1000 feet). However, the more widely used method is a simple phrase describing the location. For example, \"Beebe Woods, Falmouth, Massachusetts, USA\". The goal of these location names is to provide a consistent, reusable way of talking about where an observation was made without necessarily revealing a precise \"spot\". If you are comfortable providing more precise lat/longs for an observation, the location names are still useful for searches so you are encouraged to provide them as well. The location names should, by default, go from the smallest contained area to the country name. If you prefer to describe your locations as going from the largest (country) down to the smallest contained area, you can change your preference from the default, \"Postal\", to \"Scientific\" on your preference page. There are cases such as \"Great Smoky Mountains National Park, Blount Co., Tennessee, USA\", where the area you are describing overlaps a number of counties, states or even countries. In these cases, the country and other official political boundaries should come at the end as shown in the example.\n\nOriginally, the Mushroom Observer was very loose about these location names, hoping that the users would create a reasonably consistent set of rules and correct each other. After about four years and thousands of location names, we found that there were rules emerging, but they were not applied at all consistently and people were not tending to directly correct each other. Consequently, we have tried to codify these rules and when reasonable to provide warnings if you attempt to create a new location that violates these rules. It is not always possible to correct identify \"bad\" locations, so if you get some warnings, but after reviewing the location decide it should be \"good\", then simply resubmitting the form will force the name into the database. However, all new location names will get reviewed regularly and may get changed to better fit the consensus rules. Below are some examples of \"bad\" and \"good\" location names followed by a more detailed explanation of the current rules. Each example is labeled with the following section that explains the example in more detail. These rules are by no means set it stone and we encourage the discussion and revision of them." location_help_example_help: These are cases that are not detected automatically, so no warning would be given. location_help_example_title: Some examples location_help_bad: Bad diff --git a/test/system/observation_form_system_test.rb b/test/system/observation_form_system_test.rb index 14938160a5..3a8cf4e2ad 100644 --- a/test/system/observation_form_system_test.rb +++ b/test/system/observation_form_system_test.rb @@ -18,7 +18,7 @@ def test_create_minimal_observation assert_select("observation_when_2i", text: Time.zone.today.strftime("%B")) # %e is day of month, no leading zero assert_select("observation_when_3i", text: Time.zone.today.strftime("%e")) - assert_selector("#where_help", + assert_selector("#observation_place_name_help", text: "Albion, Mendocino Co., California", visible: :all) fill_in("naming_name", with: "Elfin saddle") # don't wait for the autocompleter - we know it's an elfin saddle! From c29d1b66ac7efd852b4bfb648a9a56451e3b8bcf Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 14:36:05 -0700 Subject: [PATCH 10/11] Make projects/lists overflow-scroll --- app/assets/stylesheets/Admin.scss | 4 ++-- app/assets/stylesheets/Agaricus.scss | 2 +- app/assets/stylesheets/Amanita.scss | 2 +- app/assets/stylesheets/BlackOnWhite.scss | 2 +- app/assets/stylesheets/Cantharellaceae.scss | 4 ++-- app/assets/stylesheets/Hygrocybe.scss | 2 +- app/assets/stylesheets/Sudo.scss | 2 +- app/assets/stylesheets/mo/_form_elements.scss | 5 +++++ .../observations/form/_projects.html.erb | 14 ++++++++------ .../observations/form/_species_lists.html.erb | 3 ++- 10 files changed, 24 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/Admin.scss b/app/assets/stylesheets/Admin.scss index 7a016508b5..0b2d47c247 100644 --- a/app/assets/stylesheets/Admin.scss +++ b/app/assets/stylesheets/Admin.scss @@ -1,6 +1,6 @@ @import "defaults"; -$BODY_BG_COLOR: #DE01DD; // DD00DD +$BODY_BG_COLOR: #DD00DD; $LOGO_BORDER_COLOR: black; $LOGO_BORDER_WIDTH: 2px; // vs 1px in default @@ -9,7 +9,7 @@ $LOGO_BG_COLOR: yellow; $LOGO_HOVER_FG_COLOR: purple; $LOGO_HOVER_BG_COLOR: yellow; -$LEFT_BAR_BORDER_COLOR: gray; +$LEFT_BAR_BORDER_COLOR: #555555; // gray $LEFT_BAR_BORDER_RADIUS: 0px; $LEFT_BAR_HEADER_FG_COLOR: black; $LEFT_BAR_HEADER_BG_COLOR: yellow; diff --git a/app/assets/stylesheets/Agaricus.scss b/app/assets/stylesheets/Agaricus.scss index 0a7c4d7d62..276bed2641 100644 --- a/app/assets/stylesheets/Agaricus.scss +++ b/app/assets/stylesheets/Agaricus.scss @@ -1,6 +1,6 @@ @import "defaults"; -$augustus_cap: #EbCe94; // #ECCF95 +$augustus_cap: #EbCe93; // #ECCF95 $brasiliensis_gills_1: #A06463; $brasiliensis_gills_2: #743931; $campestris_cap: #F6F0F2; diff --git a/app/assets/stylesheets/Amanita.scss b/app/assets/stylesheets/Amanita.scss index f59620f285..e36b9ea90d 100644 --- a/app/assets/stylesheets/Amanita.scss +++ b/app/assets/stylesheets/Amanita.scss @@ -13,7 +13,7 @@ $calyptroderma_middle_cap: #c18346; $muscaria_background: #cc2616; $muscaria_foreground: #fff8c6; $velosa_background: #dd9d5f; -$velosa_light_veil: #fbebd4; // faebd4 +$velosa_light_veil: #fbebd3; // faebd4 $velosa_dark_veil: #f4d5a6; $novinupta_background: #d1afa5; $pachycolea_background: #383138; diff --git a/app/assets/stylesheets/BlackOnWhite.scss b/app/assets/stylesheets/BlackOnWhite.scss index f3c5669956..852c88ef95 100644 --- a/app/assets/stylesheets/BlackOnWhite.scss +++ b/app/assets/stylesheets/BlackOnWhite.scss @@ -3,7 +3,7 @@ @import "defaults"; $LOGO_BORDER_COLOR: #DDDDDD; -$LEFT_BAR_BORDER_COLOR: #DeDfDf; +$LEFT_BAR_BORDER_COLOR: #DfDfDf; $TOP_BAR_BORDER_COLOR: #DDDDDD; $LIST_BORDER_COLOR: #DDDDDD; $BUTTON_HOVER_BORDER_COLOR: #CCCCCC; diff --git a/app/assets/stylesheets/Cantharellaceae.scss b/app/assets/stylesheets/Cantharellaceae.scss index 5077d13187..81250bfe55 100644 --- a/app/assets/stylesheets/Cantharellaceae.scss +++ b/app/assets/stylesheets/Cantharellaceae.scss @@ -1,6 +1,6 @@ @import "defaults"; -$californicus_cap: #f5ad49; // image 557 #f6ae4a +$californicus_cap: #f6ae4a; // image 557 $californicus_stipe: #fae8b8; $cinnabarinus_dark_cap: #c12900; // image 551 $cinnabarinus_light_cap: #ff6524; @@ -11,7 +11,7 @@ $tubaeformis_hymenium: #c2914c; $tubaeformis_bright_stipe: #ffb230; $tubaeformis_dark_stipe: #4b2e0c; $tubaeformis_light_stipe: #e5bb67; -$cornucopioides_dark_hymenium: #10110b; // image 465 +$cornucopioides_dark_hymenium: #11110b; // image 465 #10110b $cornucopioides_light_hymenium: #9b9690; $cornucopioides_dark_cap: #4f4337; $cornucopioides_light_cap: #826c57; diff --git a/app/assets/stylesheets/Hygrocybe.scss b/app/assets/stylesheets/Hygrocybe.scss index 89b5a533df..c76d5c60ca 100644 --- a/app/assets/stylesheets/Hygrocybe.scss +++ b/app/assets/stylesheets/Hygrocybe.scss @@ -1,6 +1,6 @@ @import "defaults"; -$conica_stain: #36362e; // #37372f +$conica_stain: #36362d; // #37372f $conica_cap_red: #a31404; $conica_cap_orange: #dd6226; $conica_cap_yellow: #ffbf01; diff --git a/app/assets/stylesheets/Sudo.scss b/app/assets/stylesheets/Sudo.scss index 33904b3c79..4900ee18d5 100644 --- a/app/assets/stylesheets/Sudo.scss +++ b/app/assets/stylesheets/Sudo.scss @@ -1,6 +1,6 @@ @import "defaults"; -$BODY_BG_COLOR: #DE7700; // #DD7700 +$BODY_BG_COLOR: #DE7600; // #DD7700 $LOGO_BORDER_COLOR: black; $LOGO_BORDER_WIDTH: 2px; // vs 1px in default diff --git a/app/assets/stylesheets/mo/_form_elements.scss b/app/assets/stylesheets/mo/_form_elements.scss index aa4030834f..20ff6d9a2f 100644 --- a/app/assets/stylesheets/mo/_form_elements.scss +++ b/app/assets/stylesheets/mo/_form_elements.scss @@ -175,3 +175,8 @@ form { display: inline-block; } } + +.overflow-scroll-checklist { + max-height: 30rem; + overflow-y: auto; +} diff --git a/app/views/controllers/observations/form/_projects.html.erb b/app/views/controllers/observations/form/_projects.html.erb index cec864f6be..7d6ec0427b 100644 --- a/app/views/controllers/observations/form/_projects.html.erb +++ b/app/views/controllers/observations/form/_projects.html.erb @@ -59,12 +59,14 @@ end ].safe_join end %> - <% @projects.each do |project| %> - <%= check_box_with_label( - form: f_p, field: :"id_#{project.id}", label: project.title, - checked: @project_checks[project.id], - disabled: !project.user_can_add_observation?(@observation, @user) - ) %> + <%= tag.div(class: "overflow-scroll-checklist") do %> + <% @projects.each do |project| %> + <%= check_box_with_label( + form: f_p, field: :"id_#{project.id}", label: project.title, + checked: @project_checks[project.id], + disabled: !project.user_can_add_observation?(@observation, @user) + ) %> + <% end %> <% end %> <% end %> diff --git a/app/views/controllers/observations/form/_species_lists.html.erb b/app/views/controllers/observations/form/_species_lists.html.erb index 8c4325d060..4d6014bc29 100644 --- a/app/views/controllers/observations/form/_species_lists.html.erb +++ b/app/views/controllers/observations/form/_species_lists.html.erb @@ -2,6 +2,7 @@ <%= tag.div(id: "observation_projects") do %> <%= fields_for(:list) do |f_l| %> + <%= tag.p do [ tag.strong("#{:SPECIES_LISTS.l}:", class: "mr-3"), @@ -12,7 +13,7 @@ ].safe_join end %> - <%= fields_for(:list) do |f_l| %> + <%= tag.div(class: "overflow-scroll-checklist") do %> <% @lists.each do |list| %> <%= check_box_with_label( form: f_l, field: :"id_#{list.id}", label: list.title, From b8df189e30899114b1ed9981042f8e1676e7650e Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 24 Jul 2024 14:51:38 -0700 Subject: [PATCH 11/11] Update _projects.html.erb --- .../observations/form/_projects.html.erb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/controllers/observations/form/_projects.html.erb b/app/views/controllers/observations/form/_projects.html.erb index 7d6ec0427b..2c2d9775e9 100644 --- a/app/views/controllers/observations/form/_projects.html.erb +++ b/app/views/controllers/observations/form/_projects.html.erb @@ -23,9 +23,9 @@ end <%= fields_for(:project) do |f_p| %> <% if error_messages.present? || suspect_messages.present? %> - <%= tag.div(id: "project_messages") do - [error_messages, suspect_messages].compact.each do |messages| - tag.div(class: "alert alert-#{messages.level}") do + <%= tag.div(id: "project_messages") do %> + <% [error_messages, suspect_messages].compact.each do |messages| %> + <%= tag.div(class: "alert alert-#{messages[:level]}") do [ tag.p( "#{:form_observations_projects_out_of_range.t( @@ -34,15 +34,15 @@ end )}:" ), tag.ul do - messages.list.each do |proj| - tag.li("#{proj.title} (#{proj.constraints})") + messages[:list].each do |proj| + concat(tag.li("#{proj.title} (#{proj.constraints})")) end end, - tag.p(messages.help) + tag.p(messages[:help]) ].safe_join - end - end - end %> + end %> + <% end %> + <% end %> <%= check_box_with_label( form: f_p, field: :ignore_proj_conflicts, label: :form_observations_projects_ignore_project_constraints.t