genome/dgi-db

View on GitHub
app/views/drugs/_drug_summary_tab.html.haml

Summary

Maintainability
Test Coverage
/ takes in variable for type of summary (drug or drug)
/ displays lists of aliases, drug/drug info, publications

%div(class="item-title")
  %div(class="item-name")
    %h3(class="item-source")
      %span
        = drug.name
      %span{style: "font-size: 15px; color: grey; margin-right: 5px"}
        = drug.concept_id
      %span{style: "float: right;"}
        = drug.flag_icons
%div(class="item-content")
  %div{class: "cell category", style: "float: right; width: 50%;"}
    %div{class: "item-panel"}
      %h4
        Alternate Names:
      %div{style: "height: 489px; overflow-y: scroll; margin-bottom: 5px;"}
        %table{class: "table table-condensed table-striped", id: "table_aliases"}
          %tbody
            -drug.drug_aliases.each do |alt_name| ######
              %tr
                %td
                  =alt_name.alias

  %div{class: "cell category", style: "float: left; width: 50%" }
    %div{class: "item-panel", style: "margin-bottom: 11px;"}
      %h4
        Drug Info:
      %div{style: "height: 200px; overflow-y: scroll; margin-bottom: 5px;"}  
        %table{class: "table table-condensed table-striped", id:"table_info"}
          %tbody
            -drug.drug_attributes.each do |attribute| #######
              %tr
                %td=attribute.name
                %td=attribute.value
      %div#linkouts
        - drug.drug_claims[0..3].each do |dc|
          %button{class: "button", type: "button", style:"background-color: #e7e7e7; border: none; margin-bottom: 4px", onclick:"location.href='#{dc.original_data_source_url}';"}
            = dc.source.source_db_name
        %a#more{style: "display: inline-block; margin-left: 5px; cursor: pointer"}
          - num_left = (drug.drug_claims.count - 4 > 0 ? drug.drug_claims.count - 4 : 0)
          = "(#{num_left} More Sources)"
    %div{class: "item-panel"}
      %h4
        Publications:
      %div{style: "height: 200px; overflow-y: scroll; margin-bottom: 5px;"}
        %table{class: "table table-condensed table-striped", id:"table_publications"}
          -drug.publications.each do |publication| ########
            %tr
              %td
                %a{href: PMID.pubmed_url(publication.pmid)}
                  = publication.citation

:javascript

  $("a#more").click(function () {
    $('a[href="' + "#" + "claims" + '"]').trigger('click');
    return true;
  }); 

:css
  div button:hover {
      background-color: #330066!important;
      color: white;
  }
  .flag_icon {
    margin-right: 5px;
  }