Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add a star for the required fields in the upload form #852

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading