genome/dgi-db

View on GitHub
app/views/interaction_claims/_interactions_search_panel.html.haml

Summary

Maintainability
Test Coverage
- if @search_mode == "genes" 
  - entity = GenePresenter.new(entity)
- else
  - entity = DrugPresenter.new(entity)

%div(class="item-title")
  %div(class="item-name")
    %h3(class="item-source")
      %span
        = "Search Term: " + "\"" + term + "\""
      %span{class: "glyphicon glyphicon-play", "aria-hidden" => "true", style: "margin-left: 10px; margin-right: -8px"}
      &nbsp
      - if @search_mode == "genes"
        %a{href: "/genes/#{entity.name}#_interactions"}
          = entity.name
      - else
        %a{href: "/drugs/#{entity.name}#_interactions"}
          = entity.name

%div(class="item-content")
  %div(class="cell category")
    %div{class: "item-panel"}
      %h4{style: "display: inline-block;"}
      - interactions = filtered_interactions.sort_by { |i| -scores[i.id] }.map{|i| InteractionPresenter.new(i)}
      - if interactions.count > 0
        %table{class: "search_panel table table-condensed table-striped", style: "width: 100%; margin-top: -20px;", id: "#{term}-#{entity.name}"}
          %tr
            %th
              - if @search_mode == "genes"
                Drug
              - else
                Gene
            %th
              %a{href: "/interaction_types"}
                Interaction Type & Directionality
            %th
              Sources
            %th
              PMIDs
            %th
              %a{href: "/score"}
                Query Score
            %th
              %a{href: "/score"}
                Interaction Score
          %tbody
          - interactions.each do |interaction|
            %tr{onclick: "location.href='/interactions/#{interaction.id}';"}
              %td
                - if @search_mode == "genes"
                  %a{href: "/drugs/#{interaction.drug.name}"}
                    = interaction.drug.name
                - else
                  %a{href: "/genes/#{interaction.gene.name}"}
                    = interaction.gene.name
              %td
                = interaction.na_or_types.map{|t| t[:directionality].nil? ? t[:type] : "#{t[:type]} (#{t[:directionality]})"}.join(", ")
              %td
                = interaction.sources.map{|source| TrustLevelPresenter.source_link_green(@view_context, source)}.join(' ').html_safe
              %td
                - if (pub_count = interaction.publications.size) > 0
                  = interaction.publications.map{|pub| pubmed_link_blue(pub.pmid)}.join(" ").html_safe
                - else
                  %i
                    None found
              %td
                = scores[interaction.id]
              %td
                = interaction.interaction_score(known_drug_partners_per_gene, known_gene_partners_per_drug).round(2)
        %button{class: "show-all", style: "margin-top: 5px", value: "#{term}-#{entity.name}"}
          Show All
        %button{class: "show-more", style: "margin-top: 5px", value: "#{term}-#{entity.name}"}
          Show More
        %button{class: "show-less", style: "margin-top: 5px", value: "#{term}-#{entity.name}"}
          Show Less
        %span{style: "display: inline-block; margin-top: 5px; margin-left: 5px"}
          Showing
          %span#nrows
            = [10, interactions.length].min
          %span
            = "out of #{interactions.length} Interactions"
      - else
        No interactions found.

:css
  tr:hover td{
    background-color:rgba(220, 220, 220, 1);
    cursor: pointer;
  }
  td .label {
    display: inline-block;
    margin-bottom: 3px;
  }