ncbo/bioportal_web_ui

View on GitHub
app/views/submissions/_form.html.haml

Summary

Maintainability
Test Coverage
- unless @errors.nil?
  %div.form-group.row
    %div.col-sm-10.offset-sm-2.enable-lists{style: "color:red;"}
      %strong Errors On Form
      %ul
        - for error in @errors
          - if error.is_a? Array
            %ul
              - error[1].each do |key, message|
                %li
                  = message
          - else
            %li
              = error

= hidden_field :submission, :ontology, value: @ontology.id

-# Description
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: "submission_description"}
    Description
    %span.asterik *
  %div.col-sm-10
    = text_area(:submission, :description, rows: 5, value: @submission.description, required: true,
                class: "form-control")

-# Format
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: "submission_hasOntologyLanguage"}
    Format
    %span.asterik *
  %div.col-sm-10
    - ont_formats = ["OBO", "OWL", "UMLS", "SKOS"].sort
    - selected = @submission.hasOntologyLanguage ? @submission.hasOntologyLanguage : "OWL"
    -# TODO: Add/remove aria-describedby attribute for SKOS help text display
    = select("submission", "hasOntologyLanguage", options_for_select(ont_formats, selected), {},
             {class: 'form-control'})
    %div.form-text#helpSkosFormat
      SKOS vocabularies submitted to BioPortal must contain a minimum of one concept scheme and top concept |
      assertion. Please refer to the NCBO wiki for a more |
      <a href="https://www.bioontology.org/wiki/index.php/SKOSSupport", target="_blank">detailed explanation</a> |
      with examples. |

%div.row.mb-3
  %div.col-sm-10.offset-sm-2
    = tag.button('Show advanced OWL options', id: 'collapseOWLOptions', class: 'btn btn-outline-secondary',
                 type: 'button', 'data-bs-toggle': 'collapse', 'data-bs-target': '#owl-options',
                 'aria-expanded': 'false', 'aria-controls': 'owl-options')

-# Optional property overrides for OWL ontologies
%div#owl-options.collapse
  %div.row
    %div.col-sm-10.offset-sm-2
      %p.lead Customize default property settings

  -# Preferred name
  %div.row.mb-2
    %label{for: "submission_prefLabelProperty", class: 'col-sm-2 offset-sm-2 col-form-label-sm'} Preferred name
    %div.col-sm-10.offset-sm-2
      = text_field(:submission, :prefLabelProperty, value: @submission.prefLabelProperty,
                   class: "form-control form-control-sm", aria: {describedBy: "preferredNameHelpBlock"})
      %div{id: 'preferredNameHelpBlock', class: 'form-text'}
        Enter a property ID, or leave blank to use the default setting:
        = link_to(nil, 'https://www.w3.org/2004/02/skos/core#prefLabel', target: '_blank')

  -# Synonym
  %div.row.mb-2
    %label{for: "submission_synonymProperty", class: 'col-sm-2 offset-sm-2 col-form-label-sm'} Synonym
    %div.col-sm-10.offset-sm-2
      = text_field(:submission, :synonymProperty, value: @submission.synonymProperty,
                   class: "form-control form-control-sm", aria: {describedBy: "synonymHelpBlock"})
      %div{id: 'synonymHelpBlock', class: 'form-text'}
        Enter a property ID, or leave blank to use the default setting:
        = link_to(nil, 'https://www.w3.org/2004/02/skos/core#altLabel', target: '_blank')

  -# Definition
  %div.row.mb-2
    %label{for: "submission_definitionProperty", class: 'col-sm-2 offset-sm-2 col-form-label-sm'} Definition
    %div.col-sm-10.offset-sm-2
      = text_field(:submission, :definitionProperty, value: @submission.definitionProperty,
                   class: "form-control form-control-sm", aria: {describedBy: "definitionHelpBlock"})
      %div{id: 'definitionHelpBlock', class: 'form-text'}
        Enter a property ID, or leave blank to use the default setting:
        = link_to(nil, 'https://www.w3.org/2004/02/skos/core#definition', target: '_blank')

  -# Author
  %div.row.mb-3
    %label{for: "submission_authorProperty", class: 'col-sm-2 offset-sm-2 col-form-label-sm'} Author
    %div.col-sm-10.offset-sm-2
      = text_field(:submission, :authorProperty, value: @submission.authorProperty,
                   class: "form-control form-control-sm", aria: {describedBy: "authorHelpBlock"})
      %div{id: 'authorHelpBlock', class: 'form-text'}
        Enter a property ID, or leave blank to use the default setting:
        = link_to(nil, 'https://purl.org/dc/elements/1.1/creator', target: '_blank')

  -# Obsolete classes
  %div.row
    %div.col-sm-10.offset-sm-2
      %p.lead Identify obsolete classes

  -# Obsolete property
  %div.row.mb-2
    %label{for: "submission_obsoleteProperty", class: 'col-sm-2 offset-sm-2 col-form-label-sm'} Obsolete property
    %div.col-sm-10.offset-sm-2
      = text_field(:submission, :obsoleteProperty, value: @submission.obsoleteProperty,
                   class: "form-control form-control-sm", aria: {describedBy: "obsoleteHelpBlock"})
      %div{id: 'obsoleteHelpBlock', class: 'form-text'}
        Optionally enter a property ID that indicates obsolete status for ontology classes |
        (the property value must be set to "true"). Note that by default, #{$SITE} checks for existence |
        of the owl:deprecated property. |

  -# Obsolete branch root
  %div.row.mb-3
    %label{for: "submission_obsoleteParent", class: 'col-sm-2 offset-sm-2 col-form-label-sm'} Obsolete branch root
    %div.col-sm-10.offset-sm-2
      = text_field(:submission, :obsoleteParent, value: @submission.obsoleteParent,
                   class: "form-control form-control-sm", aria: {describedBy: "obsoleteRootHelpBlock"})
      %div{id: 'obsoleteRootHelpBlock', class: 'form-text'}
        Optionally enter a class ID for the root of an obsolete branch. All classes in the branch will be marked as |
        obsolete, with the exception of the root class. |

-# Version
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: "submission_version"} Version
  %div.col-sm-10
    = text_field(:submission, :version, value: @submission.version, class: 'form-control')

-# Natural language
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label'} Language
  %div.col-sm-10
    = natural_language_selector(@submission)
    %div{id: 'languageHelpBlock', class: 'form-text'}
      Enter the language of the content of the ontology, i.e., English, French, etc.

-# Status
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: "submission_status"}
    Status
    %span.asterik *
  %div.col-sm-10
    - selected_status = @submission.status ? @submission.status : "alpha"
    - status_options = ["alpha", "beta", "production", "retired"]
    = select(:submission, :status, status_options, {selected: selected_status, required: true}, class: 'form-control')

-# Release date
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: 'datepicker'}
    Release date
    %span.asterik *
  %div.col-sm-10
    %div.input-group
      - release_date = @submission.released ? Date.parse(@submission.released) : Date.today
      = text_field(:submission, :released, id: 'datepicker', value: "#{l(release_date, format: :month_day_year)}",
                   required: true, class: 'form-control', readonly: 'readonly')
      %span.input-group-text
        %i{class: 'fas fa-calendar-alt fa-lg', 'aria-hidden': 'true'}

-# Location
%div.fieldset{id: '#submissionLocation', class: 'row mb-3'}
  %legend{class: 'col-form-label col-sm-2 pt-0'}
    Location
    %span.asterik *
  %div.col-sm-10
    - if !@masterFileOptions
      %div.form-check
        - checked = @ontology.summaryOnly
        = radio_button(:submission, :isRemote, 3, :onclick=>"$('.hidden_field').hide();", checked: checked,
                       aria: {describedBy: "metadataHelpBlock"}, class: "form-check-input")
        %label.form-check-label{for: "submission_isRemote_3"}
          Metadata only
        %div{id: 'metadataHelpBlock', class: 'form-text'}
          Allow users to view and search your ontology metadata, but not its classes and properties.
      %div.form-check
        - checked = !(@submission.pullLocation.nil? || @submission.pullLocation.empty?)
        = radio_button(:submission, :isRemote, 1, :onclick=>"location_toggle('remote');", checked: checked,
                       aria: {describedBy: "loadFromURLHelpBlock"}, class: "form-check-input")
        %label.form-check-label{for: "submission_isRemote_1"}
          Load from URL
        %div{id: 'loadFromURLHelpBlock', class: 'form-text'}
          New versions loaded on a nightly basis
        - display = (checked and "" or "display:none;")
        %div{id: 'remote', class: 'hidden_field mt-2', style: display}
          = text_field(:submission, :pullLocation, value: @submission.pullLocation,
                       aria: {describedBy: "enterURLHelpBlock"}, class: "form-control")
          %div{id: 'enterURLHelpBlock', class: 'form-text'}
            Enter a URL, including the name of your ontology source file, e.g., http://www.example.com/my_ontology.owl.
      %div.form-check
        - checked = (!@ontology.summaryOnly) && @submission.pullLocation.nil?
        = radio_button(:submission, :isRemote, 0, :onclick=>"location_toggle('upload');", checked: checked,
                       class: "form-check-input")
        %label.form-check-label{for: "submission_isRemote_0"}
          Upload local file
        - display = (checked and "" or "display:none;")
        %div.hidden_field#upload{style: display}
          = f.file_field(:filePath, class: "mt-2")
    - else
      -# TODO: Has this section of code actually been tested?
      = radio_button :submission, :isRemote, 0, :onclick=>"location_toggle('upload');", checked: true
      Upload Local File
      %br/
      %span{:style => "font-size:11px;"} (choose a file on your local file system to upload)
      - display = (checked and "" or "display:none;")
      %div#upload{style: display}
        = f.file_field :filePath, required: true
        = f.select("masterFileName", @masterFileOptions, { include_blank: "Select primary file from zip contents", required: true}, {style: "border-color: red;"})

-# Contact(s)
%div#contacts.row.mb-3
  %label{class: 'col-sm-2 col-form-label'}
    Contact
    %span.asterik *
  - if @submission.contact && @submission.contact.size > 0
    - @submission.contact.each_with_index do |contact, i|
      - if i == 0
        -# Contact div
        %div.col-sm-10.d-flex.align-items-center.contact
          %label Name
          = text_field :submission, :"contact[#{i}][name]", value: contact["name"], class: "form-control flex-grow-1 mx-2"
          %label Email
          = text_field :submission, :"contact[#{i}][email]", value: contact["email"], class: "form-control flex-grow-1 mx-2"
          %button.btn.btn-success.add-contact
            %i{class: "fas fa-plus fa-lg", aria: {hidden: "true"}}
      - else
        -# Secondary contacts need to be offset by 2 columns, and have a delete button.
        %div.col-sm-10.d-flex.align-items-center.offset-sm-2.contact
          %label Name
          = text_field :submission, :"contact[#{i}][name]", value: contact["name"], class: "form-control flex-grow-1 mx-2"
          %label Email
          = text_field :submission, :"contact[#{i}][email]", value: contact["email"], class: "form-control flex-grow-1 mx-2"
          %button.btn.btn-success.add-contact
            %i{class: "fas fa-plus fa-lg", aria: {hidden: "true"}}
          %button.btn.btn-danger.ms-1.remove-contact
            %i{class: "fas fa-minus fa-lg", aria: {hidden: "true"}}
  - else
    -# TODO
    %div.col-sm-10.d-flex.align-items-center.contact
      %label Name:
      = text_field :submission, :"contact[0][name]", class: "form-control flex-grow-1 mx-2"
      %label Email:
      = text_field :submission, :"contact[0][email]", class: "form-control flex-grow-1 mx-2"
      %button.btn.btn-success.add-contact
        %i{class: "fas fa-plus fa-lg", aria: {hidden: "true"}}

-# Home page
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: "submission_homepage"} Homepage
  %div.col-sm-10
    = text_field(:submission, :homepage, value: @submission.homepage, class: "form-control",
                 aria: {describedBy: "homepageHelpBlock"})
    %div{id: 'homepageHelpBlock', class: 'form-text'} Enter a URL for the main page of your ontology

-# Documentation page
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: "submission_documentation"} Documentation
  %div.col-sm-10
    = text_field(:submission, :documentation, value: @submission.documentation, class: "form-control",
                 aria: {describedBy: "docsHelpBlock"})
    %div{id: 'docsHelpBlock', class: 'form-text'} Enter a URL for a page that provides ontology documentation

-# Publications page
%div.row.mb-3
  %label{class: 'col-sm-2 col-form-label', for: "submission_publication"} Publications
  %div.col-sm-10
    = text_field(:submission, :publication, value: @submission.publication, class: "form-control",
                 aria: {describedBy: "pubsHelpBlock"})
    %div{id: 'pubsHelpBlock', class: 'form-text'} Enter a URL for a page that lists publications about your ontology

%div.row.mb-3
  %div.col-sm-10.offset-sm-2
    %label.col-form-label.fst-italic * Fields marked with an asterisk are required.

%div.row.mb-3
  %div.col-sm-10.offset-sm-2
    = submit_tag button_text, class: "btn btn-primary me-1"
    = link_to "Cancel", ontology_path(@ontology.acronym), class: "btn btn-primary"