aboutsummaryrefslogtreecommitdiff
path: root/uploader/templates/phenotypes/add-phenotypes-base.html
blob: a7aaeb01322b211d11d318186ef62ab7866624b1 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{%extends "phenotypes/base.html"%}
{%from "flash_messages.html" import flash_all_messages%}
{%from "macro-table-pagination.html" import table_pagination%}
{%from "phenotypes/macro-display-pheno-dataset-card.html" import display_pheno_dataset_card%}

{%block title%}Phenotypes{%endblock%}

{%block pagetitle%}Phenotypes{%endblock%}

{%block lvl4_breadcrumbs%}
<li {%if activelink=="add-phenotypes"%}
    class="breadcrumb-item active"
    {%else%}
    class="breadcrumb-item"
    {%endif%}>
  <a href="{{url_for('species.populations.phenotypes.add_phenotypes',
           species_id=species.SpeciesId,
           population_id=population.Id,
           dataset_id=dataset.Id)}}">Add Phenotypes</a>
</li>
{%endblock%}

{%block contents%}
{{flash_all_messages()}}

<div class="row">
  <form id="frm-add-phenotypes"
        method="POST"
        enctype="multipart/form-data"
        action="{{url_for('species.populations.phenotypes.add_phenotypes',
                species_id=species.SpeciesId,
                population_id=population.Id,
                dataset_id=dataset.Id,
                use_bundle=use_bundle)}}"
        data-resumable-target="{{url_for('files.resumable_upload_post')}}">
    <legend>Add New Phenotypes</legend>

    <div class="form-text help-block">
      {%block frm_add_phenotypes_documentation%}{%endblock%}
      <p><strong class="text-warning">This will not update any existing phenotypes!</strong></p>
    </div>

    {%block frm_add_phenotypes_elements%}{%endblock%}

    <fieldset id="fldset-publication-info">
      <legend>Publication Information</legend>
      <input type="hidden" name="publication-id" id="txt-publication-id" />
      <span class="form-text text-muted">
        Select a publication for your data. <br />
        Can't find a publication you can use? Go ahead and
        <a href="{{url_for(
                 'publications.create_publication',
                 return_to='species.populations.phenotypes.add_phenotypes',
                 species_id=species.SpeciesId,
                 population_id=population.Id,
                 dataset_id=dataset.Id)}}">create a new publication</a>.</span>
      <table id="tbl-select-publication" class="table compact stripe">
        <thead>
          <tr>
            <th>#</th>
            <th>PubMed ID</th>
            <th>Title</th>
            <th>Authors</th>
          </tr>
        </thead>

        <tbody></tbody>
      </table>
    </fieldset>

    <div class="form-group">
      <input type="submit"
             value="upload phenotypes"
             class="btn btn-primary" />
    </div>
  </form>
</div>

<div class="row">
  {%block page_documentation%}{%endblock%}
</div>

{%endblock%}


{%block javascript%}
<script type="text/javascript">
  $(function() {
      var publicationsDataTable = buildDataTable(
          "#tbl-select-publication",
          [],
          [
              {data: "index"},
              {
                  data: (pub) => {
                  if(pub.PubMed_ID) {
                      return `<a href="https://pubmed.ncbi.nlm.nih.gov/` +
                          `${pub.PubMed_ID}/" target="_blank" ` +
                          `title="Link to publication on NCBI.">` +
                          `${pub.PubMed_ID}</a>`;
                  }
                  return "";
                  }
              },
              {
                  data: (pub) => {
                  var title = "⸻";
                  if(pub.Title) {
                      title = pub.Title
                  }
                  return `<a href="/publications/view/${pub.Id}" ` +
                          `target="_blank" ` +
                          `title="Link to view publication details">` +
                          `${title}</a>`;
                  }
              },
              {
                  data: (pub) => {
                  authors = pub.Authors.split(",").map(
                      (item) => {return item.trim();});
                  if(authors.length > 1) {
                      return authors[0] + ", et. al.";
                  }
                  return authors[0];
                  }
              }
          ],
          {
              ajax: {
                  url: "/publications/list",
                  dataSrc: "publications"
              },
              select: "single",
              scrollY: 700,
              paging: false,
              deferRender: true,
              layout: {
                  topStart: "info",
                  topEnd: "search"
              }
          });
      publicationsDataTable.on("select", (event, datatable, type, indexes) => {
          indexes.forEach((element, index, thearray) => {
              let row = datatable.row(element).node();
              console.debug(datatable.row(element).data());
              $("#frm-add-phenotypes #txt-publication-id").val(
                  datatable.row(element).data().Id);
          });
      });
      publicationsDataTable.on("deselect", (event, datatable, type, indexes) => {
          indexes.forEach((element, index, thearray) => {
              let row = datatable.row(element).node();
              $("#frm-add-phenotypes #txt-publication-id").val(null);
          });
      });
  });
</script>

{%block more_javascript%}{%endblock%}
{%endblock%}