ncbo/bioportal_web_ui

View on GitHub
app/views/notes/_list.html.haml

Summary

Maintainability
Test Coverage
- require 'cgi'
- # Check to see if we have notes, if not then try to get them
- @note_link = "/ontologies/#{@ontology.acronym}/notes/"
.notes_list_container
  .add_comment{style: "float: left; margin-right: 1em;"}
    - if session[:user].nil?
      = link_to "Add comment", login_index_path, class: "link_button", style: "font-size: .9em;"
    - else
      = link_to "Add comment", "javascript:void(0);", class: "add_comment link_button", style: "font-size: .9em;", data: { parent_id: "#{@concept.id}", parent_type: "class" }
  .add_proposal{style: "float: left; margin-right: 1em;"}
    - if session[:user].nil?
      = link_to "Add proposal", login_index_path, class: "link_button", style: "font-size: .9em"
    - else
      = link_to "Add proposal", "javascript:void(0);", class: "add_proposal link_button", style: "font-size: .9em;", data: { parent_id: "#{@concept.id}", parent_type: "class" }
  .subscribe_to_notes.link_button{:style => "float: left;"}
    = subscribe_button(@ontology.acronym)
  .notes_delete{:style => "float: left; margin-left: 1em;"}
    / TODO_REV: Enable notes deletion
    / delete_button
  %div.create_note_form{style: "display: none; clear: both; padding-top: 1em;"}

  .concept_notes_table_container{:style => "clear: both; padding-top: 2em;"}
    %table.zebra.notes_concept_list_table{:class => "concept_notes_list", :style => "width: 100%; clear: both;", :width => "100%"}
      %thead
        %tr
          %th.notes_delete
            Delete
          %th
            Subject
          %th
            Author
          %th
            Type
          %th
            Created
      %tbody
        - if @notes.nil? || @notes.empty?
          %tr#concept_no_notes
            %td No notes to display
            %td
            %td
            %td
        - else
          - @notes.each do |note|
            %tr{:class => "#{note.id}_tr", :id => "#{note.id}_tr"}
              %td.notes_delete
                - if note.deletable?(session[:user])
                  / TODO_REV: Handle notes deletion
                  / %input.delete_note_checkbox{"data-applies_to" => note.appliesTo['id'], "data-note_id" => note.id, :id => "delete_#{note.id}", :type => "checkbox"}/
              %td
                = link_to note.subject, "#{@note_link}#{CGI.escape(note.id)}", :id => "row_#{note.id}", :class => "concept_notes_list_link notes_list_link"
                   
                %span{:id => "#{note.id}_row_archived", :style => "font-size: x-small; color: grey;"}
                  - if note.archived
                    archived
              %td
                = get_username(note.creator)
              %td
                = note.proposal ? get_note_type_text(note.proposal.type) : "Comment"
              %td
                = DateTime.parse(note.created).strftime("%Y-%m-%d")