about summary refs log tree commit diff
path: root/uploader/templates/publications/index.html
blob: 54d3fc04669cd96966b3ec0a14af4a1fafa1c1d9 (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
{%extends "publications/base.html"%}
{%from "flash_messages.html" import flash_all_messages%}

{%block title%}Publications{%endblock%}


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

<div class="row" style="padding-bottom: 1em;">
  <div class="col">
    <a href="{{url_for('publications.create_publication')}}"
       class="btn btn-primary"
       title="Create a new publication.">
      add new publication</a>
  </div>
</div>

<div class="row">
  <p>Click on title to view more details and to edit details for that
    publication.</p>
</div>

<div class="row">
  <table id="tbl-list-publications" class="table compact stripe">
    <thead>
      <tr>
        <th>#</th>
        <th>PubMed ID</th>
        <th>Title</th>
        <th>Authors</th>
      </tr>
    </thead>

    <tbody></tbody>
  </table>
</div>
{%endblock%}


{%block javascript%}
<script type="text/javascript" src="/static/js/urls.js"></script>

<script type="text/javascript">
  $(function() {
      var publicationsDataTable = buildDataTable(
          "#tbl-list-publications",
          [],
          [
              {data: "index"},
              {
                  searchable: true,
                  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 "";
                  }
              },
              {
                  searchable: true,
                  data: (pub) => {
                      var title = "⸻";
                      if(pub.Title) {
                          title = pub.Title
                      }
                      url=buildURLFromCurrentURL(
                          `/publications/view/${pub.Id}`);
                      return `<a href="${url}" target="_blank" ` +
                          `title="Link to view publication details">` +
                          `${title}</a>`;
                  }
              },
              {
                  searchable: true,
                  data: (pub) => {
                      authors = pub.Authors.split(",").map(
                          (item) => {return item.trim();});
                      if(authors.length > 1) {
                          return authors[0] + ", et. al.";
                      }
                      return authors[0];
                  }
              }
          ],
          {
              serverSide: true,
              ajax: {
                  url: "/publications/list",
                  dataSrc: "publications"
              },
              scrollY: 700,
              scroller: true,
              scrollCollapse: true,
              paging: true,
              deferRender: true,
              layout: {
                  topStart: "info",
                  topEnd: "search",
                  bottomStart: "pageLength",
                  bottomEnd: false
              }
          });
  });
</script>
{%endblock%}