Skip to content

Commit

Permalink
add a star for the required fields in the upload form (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal authored Nov 18, 2024
1 parent dc2bb13 commit a0211c5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions app/helpers/submission_inputs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/ontologies/_submission_location_form.html.haml
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down
2 changes: 1 addition & 1 deletion app/views/ontologies/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a0211c5

Please sign in to comment.