From a0211c5f22e78117e44f79c4752e8759f2f471e1 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Mon, 18 Nov 2024 10:18:19 +0100 Subject: [PATCH] add a star for the required fields in the upload form (#852) --- app/helpers/submission_inputs_helper.rb | 21 ++++++++++++------- .../_submission_location_form.html.haml | 2 +- app/views/ontologies/new.html.haml | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/helpers/submission_inputs_helper.rb b/app/helpers/submission_inputs_helper.rb index 06ecee5b39..2636fdc68e 100644 --- a/app/helpers/submission_inputs_helper.rb +++ b/app/helpers/submission_inputs_helper.rb @@ -108,12 +108,12 @@ def attribute_input(attr_key, long_text: false, label: nil, show_tooltip: true, end - def ontology_name_input(ontology = @ontology) - text_input(name: 'ontology[name]', value: ontology.name) + def ontology_name_input(ontology = @ontology, label: 'Name') + text_input(name: 'ontology[name]', value: ontology.name, label: label_required(label)) end - def ontology_acronym_input(ontology = @ontology, update: @is_update_ontology) - out = text_input(name: 'ontology[acronym]', value: ontology.acronym, disabled: update) + def ontology_acronym_input(ontology = @ontology, update: @is_update_ontology, label: 'Acronym') + out = text_input(name: 'ontology[acronym]', value: ontology.acronym, disabled: update, label: label_required(label)) out += hidden_field_tag('ontology[acronym]', ontology.acronym) if update out end @@ -123,7 +123,7 @@ def ontology_administered_by_input(ontology = @ontology, users_list = @user_sele users_list = LinkedData::Client::Models::User.all(include: "username").map { |u| [u.username, u.id] } users_list.sort! { |a, b| a[1].downcase <=> b[1].downcase } end - select_input(label: t('submission_inputs.administrators'), name: "ontology[administeredBy]", values: users_list, selected: ontology.administeredBy || session[:user].id, multiple: true) + select_input(label: label_required(t('submission_inputs.administrators')), name: "ontology[administeredBy]", values: users_list, selected: ontology.administeredBy || session[:user].id, multiple: true) end def ontology_categories_input(ontology = @ontology, categories = @categories) @@ -213,7 +213,7 @@ def ontology_visibility_input(ontology = @ontology) render(Layout::RevealComponent.new(possible_values: %w[private public], selected: ontology.viewingRestriction)) do |c| c.button do - select_input(label: t('submission_inputs.visibility'), name: "ontology[viewingRestriction]", required: true, + select_input(label: label_required(t('submission_inputs.visibility')), name: "ontology[viewingRestriction]", required: true, values: %w[public private], selected: ontology.viewingRestriction) end @@ -248,7 +248,7 @@ def contact_input(label: '', name: t('submission_inputs.contact'), show_help: tr render NestedFormInputsComponent.new(object_name: 'contact', default_empty_row: true) do |c| c.header do - content_tag(:div, name.blank? ? '' : t('submission_inputs.contact_name', name: name), class: 'w-50') + content_tag(:div, name.blank? ? '' : t('submission_inputs.contact_email', name: name), class: 'w-50') + content_tag(:div, name.blank? ? '' : label_required(t('submission_inputs.contact_name', name: name)), class: 'w-50') + content_tag(:div, name.blank? ? '' : label_required(t('submission_inputs.contact_email', name: name)), class: 'w-50') end c.template do @@ -531,4 +531,11 @@ def attribute_help_text(attr) help_text end end + + def label_required(label) + content_tag(:div) do + label.html_safe + + content_tag(:span, '*', style: 'color: var(--error-color);') + end + end end diff --git a/app/views/ontologies/_submission_location_form.html.haml b/app/views/ontologies/_submission_location_form.html.haml index f26f07009d..201c2eae8d 100644 --- a/app/views/ontologies/_submission_location_form.html.haml +++ b/app/views/ontologies/_submission_location_form.html.haml @@ -1,4 +1,4 @@ -= render Input::InputFieldComponent.new(label: t("ontologies.location"), name: '') do += render Input::InputFieldComponent.new(label: label_required(t("ontologies.location")), name: '') do .location-choice %input{type: "radio", name: "submission[isRemote]", value: "3", checked: summary_only?, id: "metadata_only", onchange: "displayMetadataOnlyForm()"} %label.title{for: "metadata_only"} diff --git a/app/views/ontologies/new.html.haml b/app/views/ontologies/new.html.haml index 67a9163866..281ae26167 100644 --- a/app/views/ontologies/new.html.haml +++ b/app/views/ontologies/new.html.haml @@ -39,7 +39,7 @@ .upload-ontology-field-container - @submission.valid = nil unless @submission.status&.eql?('retired') = attribute_input("valid") - .upload-ontology-field-container + .upload-ontology-field-container.mt-3 = render partial: 'ontologies/submission_location_form' - c.page do