source: trunk/grails-app/views/study/show.gsp @ 442

Last change on this file since 442 was 442, checked in by roberth, 13 years ago

Updated studies list and added institute and department properties to person affiliations

  • Property svn:keywords set to Date Author Rev
File size: 12.7 KB
Line 
1
2<%@ page import="dbnp.studycapturing.Study" %>
3<html>
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <meta name="layout" content="main" />
7  <g:set var="entityName" value="${message(code: 'study.label', default: 'Study')}" />
8  <title><g:message code="default.show.label" args="[entityName]" /></title>
9  <script type="text/javascript">
10    $(function() {
11            $("#tabs").tabs();
12    });
13  </script>
14
15</head>
16<body>
17
18  <div class="body">
19    <h1><g:message code="default.show.label" args="[entityName]" /></h1>
20    <g:if test="${flash.message}">
21      <div class="message">${flash.message}</div>
22    </g:if>
23    <div class="dialog">
24
25      <div id="tabs">
26        <ul>
27          <li><a href="#study">Study Information</a></li>
28          <li><a href="#subjects">Subjects</a></li>
29          <li><a href="#events">Events</a></li>
30          <li><a href="#event-group">Event Groups</a></li>
31          <li><a href="#assays">Assays</a></li>
32          <li><a href="#persons">Persons</a></li>
33          <li><a href="#publications">Publications</a></li>
34        </ul>
35
36        <div id="study">
37
38          <table>
39            <!-- Show all template and domain fields, if filled -->
40            <g:each in="${studyInstance.giveFields()}" var="field">
41              <g:if test="${studyInstance.getFieldValue(field.name)}">
42                <tr>
43                  <td>${field}</td>
44                  <td>${studyInstance.getFieldValue(field.name)}</td>
45                </tr>
46              </g:if>
47            </g:each>
48
49            <!-- Add some extra fields -->
50            <tr>
51              <td>Events</td>
52              <td>
53                <g:if test="${studyInstance.giveEventTemplates().size()==0}">
54                  -
55                </g:if>
56                <g:else>
57                 ${studyInstance.giveEventTemplates().name.join(", ")}
58                </g:else>
59              </td>
60            </tr>
61            <tr>
62              <td>Sampling events</td>
63              <td>
64                <g:if test="${studyInstance.giveSamplingEventTemplates().size()==0}">
65                  -
66                </g:if>
67                <g:else>
68                 ${studyInstance.giveSamplingEventTemplates().name.join(", ")}
69                </g:else>
70              </td>
71            </tr>
72            <tr>
73              <td>Readers</td>
74              <td>
75                <g:if test="${studyInstance.readers.size()==0}">
76                  -
77                </g:if>
78                <g:else>
79                  <g:each in="${studyInstance.readers}" var="r" status="i">
80                    <g:if test="${i > 0}">, </g:if>
81                    <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link>
82                  </g:each>
83                </g:else>
84              </td>
85            </tr>
86            <tr>
87              <td>Editors</td>
88              <td>
89                <g:if test="${studyInstance.editors.size()==0}">
90                  -
91                </g:if>
92                <g:else>
93                  <g:each in="${studyInstance.editors}" var="r" status="i">
94                    <g:if test="${i > 0}">, </g:if>
95                    <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link>
96                  </g:each>
97                </g:else>
98              </td>
99            </tr>
100
101          </table>
102        </div>
103
104        <div id="subjects">
105          <g:each in="${studyInstance.giveSubjectTemplates()}" var="template">
106            <table>
107              <thead>
108                <tr>
109                  <g:each in="${new dbnp.studycapturing.Subject().giveDomainFields()}" var="field">
110                    <th>${field}</th>
111                  </g:each>
112                  <g:each in="${template.fields}" var="field">
113                    <th>${field}</th>
114                  </g:each>
115                </tr>
116              </thead>
117             
118              <%
119                subjects = studyInstance.subjects.findAll {it.template == template};
120                sortedSubjects = subjects.sort( { a, b -> a.name <=> b.name } as Comparator )
121              %>
122              <g:each in="${sortedSubjects}" var="s" status="i">
123                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
124                  <g:each in="${s.giveDomainFields()}" var="field">
125                    <td>${s.getFieldValue(field.name)}</td>
126                  </g:each>
127                  <g:each in="${template.fields}" var="field">
128                    <td>
129                      ${s.getFieldValue(field.name)}
130                    </td>
131                </g:each>
132                </tr>
133              </g:each>
134
135            </table>
136
137          </g:each>
138        </div>
139
140        <div id="events">
141          <g:if test="${studyInstance.events.size()==0}">
142            No events in this study
143          </g:if>
144          <g:else>
145
146              <table>
147                <thead>
148                  <tr>
149                    <th>Start time</th>
150                    <th>Duration</th>
151                    <th>Type</th>
152                    <th>Sampling event</th>
153                    <th>Parameters</th>
154                  </tr>
155                </thead>
156
157              <%
158                // Sort events by starttime and duration
159                events = studyInstance.events + studyInstance.samplingEvents;
160                sortedEvents = events.sort( { a, b ->
161                      a.startTime == b.startTime ?
162                        a.getDuration().toMilliseconds() <=> b.getDuration().toMilliseconds() :
163                        a.startTime <=> b.startTime
164                  } as Comparator )
165              %>
166
167                <g:each in="${sortedEvents}" var="event" status="i">
168                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
169                    <td>${event.getPrettyDuration(studyInstance.startDate,event.startTime)}</td>
170                    <td>${event.getPrettyDuration()}</td>
171                    <td>${event.template.name}</td>
172                    <td>
173                      <g:if test="${event instanceof dbnp.studycapturing.SamplingEvent}">
174                        <g:checkBox name="samplingEvent" disabled="${true}" value="${true}"/>
175                      </g:if>
176                      <g:else>
177                        <g:checkBox name="event" disabled="${true}" value="${false}" />
178                      </g:else>
179                    </td>
180                    <td>
181                      <g:set var="fieldCounter" value="${1}" />
182                      <g:each in="${event.giveTemplateFields()}" var="field">
183                        <g:if test="${event.getFieldValue(field.name)}">
184                          <g:if test="${fieldCounter > 1}">, </g:if>
185                            ${field.name} = ${event.getFieldValue( field.name )}
186                          <g:set var="fieldCounter" value="${fieldCounter + 1}" />
187                        </g:if>
188                      </g:each>
189                    </td>
190                  </tr>
191                </g:each>
192
193              </table>
194
195          </g:else>
196        </div>
197
198        <div id="event-group">
199          <g:if test="${studyInstance.eventGroups.size()==0}">
200            No event groups in this study
201          </g:if>
202          <g:else>
203            <table>
204              <tr>
205                <td><b>Name</b></td>
206                <td colspan="${studyInstance.giveAllEventTemplates().size()}"><b>Events</b></td>
207                <td><b>Subjects</b></td>
208              </tr>
209              <tr>
210                <td></td>
211                <g:each in="${studyInstance.giveAllEventTemplates()}" var="eventTemplate">
212                  <td><b>${eventTemplate.name}</b></td>
213                </g:each>
214                <td></td>
215              </tr>
216              <g:each in="${studyInstance.eventGroups}" var="eventGroup">
217                <tr>
218                  <td>${eventGroup.name}</td>
219
220                  <g:each in="${studyInstance.giveAllEventTemplates()}" var="currentEventTemplate">
221                    <td>
222                      <g:each in="${eventGroup.events}" var="event">
223                        <g:if test="${event.template.name==currentEventTemplate.name}">
224
225                          <g:set var="fieldCounter" value="${1}" />
226                          <g:each in="${event.giveTemplateFields()}" var="field">
227                            <g:if test="${event.getFieldValue(field.name)}">
228                              <g:if test="${fieldCounter > 1}">, </g:if>
229                                ${field.name} = ${event.getFieldValue( field.name )}
230                              <g:set var="fieldCounter" value="${fieldCounter + 1}" />
231                            </g:if>
232                          </g:each>
233                        </g:if>
234                      </g:each>
235                     </td>
236                  </g:each>
237                  <td>
238                    <% sortedGroupSubjects = eventGroup.subjects.sort( { a, b -> a.name <=> b.name } as Comparator )  %>
239                    ${sortedGroupSubjects.name.join( ', ' )}
240                  </td>
241                </tr>
242              </g:each>
243            </table>
244          </g:else>
245        </div>
246
247        <div id="assays">
248          <g:if test="${studyInstance.assays.size()==0}">
249            No assays in this study
250          </g:if>
251          <g:else>
252            <table>
253              <thead>
254                <tr>
255                  <th width="100">Assay Name</th>
256                  <th width="100">Module</th>
257                  <th>Type</th>
258                  <th width="150">Platform</th>
259                  <th>Url</th>
260                  <th>Samples</th>
261                </tr>
262              </thead>
263              <g:each in="${studyInstance.assays}" var="assay" status="i">
264                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
265                  <td>${assay.name}</td>
266                  <td>${assay.module.name}</td>
267                  <td>${assay.module.type}</td>
268                  <td>${assay.module.platform}</td>
269                  <td>${assay.module.url}</td>
270                  <td>
271                    <% sortedAssaySamples = assay.samples.sort( { a, b -> a.name <=> b.name } as Comparator )  %>
272                    ${sortedAssaySamples.name.join( ', ' )}
273                  </td>
274                </tr>
275              </g:each>
276
277            </table>
278          </g:else>
279        </div>
280
281        <div id="persons">
282          <g:if test="${studyInstance.persons.size()==0}">
283            No persons involved in this study
284          </g:if>
285          <g:else>
286            <table>
287              <tr>
288                <thead>
289                  <th>Name</th>
290                  <th>Affiliations</th>
291                  <th>Role</th>
292                  <th>Phone</th>
293                  <th>Email</th>
294                </thead>
295              </tr>
296              <g:each in="${studyInstance.persons}" var="studyperson" status="i">
297                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
298                  <td>${studyperson.person.firstName} ${studyperson.person.prefix} ${studyperson.person.lastName}</td>
299                  <td>
300                    ${studyperson.person.affiliations.join(', ')}
301                  </td>
302                  <td>${studyperson.role.name}</td>
303                  <td>${studyperson.person.phone}</td>
304                  <td>${studyperson.person.email}</td>
305                </tr>
306              </g:each>
307            </table>
308          </g:else>
309        </div>
310
311        <div id="publications">
312          <g:if test="${studyInstance.publications.size()==0}">
313            No publications attached to this study
314          </g:if>
315          <g:else>
316            <table>
317              <tr>
318                <thead>
319                  <th>Title</th>
320                  <th>Authors</th>
321                  <th>Comments</th>
322                </thead>
323              </tr>
324              <g:each in="${studyInstance.publications}" var="publication" status="i">
325                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
326                  <td>${publication.title}</td>
327                  <td>
328                    ${publication.authorlist}
329                  </td>
330                  <td>${publication.comment}</td>
331                </tr>
332              </g:each>
333            </table>
334          </g:else>
335        </div>
336
337      </div>
338    </div>
339    <br>
340    <div class="buttons">
341      <g:form>
342        <g:hiddenField name="id" value="${studyInstance?.id}" />
343        <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
344        <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
345        <span class="button"><g:link class="backToList" action="list">Back to list</g:link></span>
346      </g:form>
347    </div>
348  </div>
349</body>
350</html>
Note: See TracBrowser for help on using the repository browser.