single.html 5.77 KB
Newer Older
1
2
{{ define "main" }}

3
{{ $projects := slice }}
4
{{ $topic_calls := slice }}
5
{{ range $index, $project := $.Site.Data.c19dpes_research_projects.research_projects }}
6
7
8
{{ $correct_type := true }}
{{ $has_data := true }}
  {{ if and $has_data $correct_type }}
9
10
    {{ $projects = $projects | append $project }}
    {{ range $index, $topic := $project.topic_call }}
11
12
13
14
15
16
17
      {{ if in $topic_calls $topic}}
      {{ else }}
        {{ if ne $topic "" }}
          {{ $topic_calls = $topic_calls | append $topic }}
        {{ end }}
      {{ end }}
    {{ end }}
18
19
  {{ end }}
{{ end }}
20
{{ $topic_calls = sort $topic_calls }}
21
22

<main class="container">
23
  <h1>{{ .Title }}</h1>
24
  <article>{{ .Content }}</article>
25
  <div class="d-flex">
26
    {{ partial "last-update.html" (dict "context" . "last_update" (substr $.Site.Data.c19dpes_research_projects.timestamp 0 10)) }}
27
  </div>
28
29
30
31
32
33
34
35
36
37
38
  <div class="row">
    <section class="col-md-2">
      <h5>{{ i18n "organisation" }}</h5>
      <div class="form-check mb-2 ml-3">
        <div class="row">
          <input type="checkbox" class="form-check-input" name="uni_or_multi" value="Unicentric">
          <span>{{ i18n "unicentric" }}</span>
        </div>
        <div class="row">
          <input type="checkbox" class="form-check-input" name="uni_or_multi" value="Multicentric">
          <span>{{ i18n "multicentric" }}</span>
39
40
        </div>
      </div>
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
      <h5>{{ i18n "clinical_trial" }}</h5>
      <div class="form-check mb-2 ml-3">
        <div class="row">
          <input type="checkbox" class="form-check-input" name="clinical_trial" value="Yes">
          <span>{{ i18n "yes" }}</span>
        </div>
        <div class="row">
          <input type="checkbox" class="form-check-input" name="clinical_trial" value="No">
          <span>{{ i18n "no" }}</span>
        </div>
      </div>
      <h5>{{ i18n "topic_call" }}</h5>
      <div class="form-check mb-2 ml-3">
        {{ range $index, $topic := $topic_calls }}
        <div class="row">
          <input type="checkbox" class="form-check-input" name="topic_call" value="{{ $topic }}">
          <span>{{ $topic }}</span>
        </div>
        {{ end }}
      </div>
    </section>
62
    <div class="col-md-10">
63
      <a id="downloadButton" class="btn btn-primary d-inline-block" target="_blank" href="http://eu-isciii.es/wp-content/uploads/2020/06/Excel-COVID19-Funded-Spain-Projects-v.04.06.2020.xlsx">
64
65
        {{ i18n "download_csv" }}
      </a>
66
      <table class="table table-responsive" id="projects-table">
67
68
        <thead class="thead-light">
          <tr>
69
70
            <th scope="col">{{ i18n "project" }}</th>
            <th scope="col">{{ i18n "reference_id" }}</th>
71
72

            <!-- This columns are not visible by DataTables but they are necessary for filtering and CSV downloading -->
73
74
75
            <th scope="col">{{ i18n "center" }}</th>
            <th scope="col">{{ i18n "trial" }}</th>
            <th scope="col">{{ i18n "organisation" }}</th>
76
            <th scope="col">{{ i18n "topic_call" }}</th>
77
78
79
          </tr>
        </thead>
        <tbody>
80
          {{ range $index, $project := $projects }}
81
            <tr>
82
              <td>
83
84
85
                <b>{{ .title }}{{ if .acronym }} ({{ .acronym }}){{ end }} </b><br>
                <span class="text-muted">{{ .pi }}</span><br>
                <i>{{ .center }}</i><br>
86
                <!-- <small>Project ID: {{ .isciii_reference }}</small><br> -->
87
88
89
                <small>{{ .uni_multi_centric }}</small><br>
                <small>Clinical trial: {{ .clinical_trial }}</small><br>
                <small>Topic call: {{ delimit .topic_call ", " }}</small><br>
90
                <!-- <a class="btn btn-primary btn-link badge badge-primary" data-toggle="collapse" href="#description-{{ $index }}" role="button" aria-expanded="false" aria-controls="description-{{ $index }}">
91
92
93
94
95
                  {{ i18n "project_description" }} <i class="bi bi-caret-down-fill"></i></a>
                <div class="collapse" id="description-{{ $index }}">
                    <p>{{ .description }}</p>
                    <p>{{ .more_information }}</p>
                </div> -->
96
              </td>
97
              <td>{{ .isciii_reference }}</td>
98
99
100
              <!-- <td>{{ .resolution_date }}</td> -->

              <!-- This columns are not visible by DataTables but they are necessary for filtering and CSV downloading -->
101
              <td>{{ .center }}</td>
102
103
104
              <td>{{ .clinical_trial }}</td>
              <td>{{ .uni_multi_centric }}</td>
              <td>{{ delimit .topic_call ", " }}</td>
105
106
107
108
            </tr>
          {{ end }}
        </tbody>
      </table>
109
110
111
112
    </div>
  </div>
</main>

113
<script src="/js/dp-table-filters.js"></script>
114
115
<script>
  $(document).ready(function() {
116
    const table = $('#projects-table').DataTable({
117
118
      dom: `
        <".container-fluid"
119
          <".row my-2"
120
            <".mr-auto"i>
121
            <"#search.mr-2"f>
122
123
124
125
126
127
128
129
          >
          <".row"t>
          <".row"
            <".mr-auto"l>
            <".ml-auto"p>
          >
        >
      `,
130
131
132
133
      // processing: true,
      order: [[ 1, "desc" ]],
      columnDefs: [

134
        // Hide columns that are present for filtering and for downloading the table as usable CSV.
135
136
137
138
        { visible: false, targets: [2, 3, 4, 5] },

        // Remove ordering for first mega-column (sorting alphabetically by title makes no sense).
        { orderable: false, targets: 0 },
139
      ],
140
141
142
    });

    // Move download buttons next to filter search box.
143
    const downloadButton = document.querySelector('#downloadButton');
144
    const search = document.querySelector('#search');
145
    search.insertAdjacentElement('afterend', downloadButton);
146

147
148
149
150
151
152
153
    // Define column indices and apply checkbox filters.
    const columnIndices = {
      clinical_trial: 3,
      uni_or_multi: 4,
      topic_call: 5,
    };
    applyFilters(table, columnIndices);
154
});
155
</script>
156

157
{{ end }}