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

Last change on this file was 1923, checked in by work@…, 12 years ago
  • resolves # 469
  • added tiptip support
  • Property svn:keywords set to Rev Author Date
File size: 9.2 KB
Line 
1<%@ page import="dbnp.studycapturing.*" %>
2<%@ page import="org.dbnp.gdt.*" %>
3<html>
4<head>
5        <meta name="layout" content="main"/>
6        <g:if test="${studyList.size() == 1}">
7        <meta property="og:title" content="${studyList[0].title}"/>
8        <meta property="og:description" content="${(studyList[0].getFieldValue('description')) ? studyList[0].getFieldValue('description') : 'A study in the Generic Study Capture Framework'}"/>
9        </g:if>
10        <g:set var="entityName" value="${message(code: 'study.label', default: 'Study')}"/>
11        <title><g:message code="default.show.label" args="[entityName]"/></title>
12        <link rel="stylesheet" href="${resource(dir: 'css', file: 'tipTip.css')}"/>
13        <script type="text/javascript" src="${resource(dir: 'js', file: 'jquery.tipTip.minified.js')}"></script>
14        <script type="text/javascript">
15                $(document).ready(function() {
16                        $("a.linktips").tipTip();
17                });
18
19            // Flag whether the timelines have been loaded
20        var timelineloaded = false;
21
22                // Number of timelines that should be loaded
23                var numTimelines = ${studyList?.size()};
24
25                // This method is called on the event body.onLoad
26                $(function() {
27                        $("#tabs").tabs({
28                show: function(event, ui) {
29                  // If the events tab is shown, the timeline should be redrawn
30                  if( ui.tab.hash == '#events-timeline' && !timelineloaded ) {
31                    loadTimeline( 'eventstimeline', 'eventtitles', 0 );
32                    timelineloaded = true;
33                  }
34                },
35                                ajaxOptions: {
36                                        error: function(xhr, status, index, anchor) {
37                                                $(anchor.hash).html(
38                                                        "Couldn't load this tab. We'll try to fix this as soon as possible.");
39                                        }
40                                }
41                        });
42                });
43
44                // Parameters for the SIMILE timeline
45                Timeline_ajax_url = "${resource(dir: 'js', file: 'timeline-simile/timeline_ajax/simile-ajax-api.js')}";
46                Timeline_urlPrefix = '${resource(dir: 'js', file: 'timeline-simile/')}';
47                Timeline_parameters = 'bundle=true';
48
49        </script>
50        <link rel="stylesheet" type="text/css" href="${resource(dir: 'css', file: 'studies.css')}"/>
51
52        <!-- Include scripts for the SIMILE timeline. See http://simile-widgets.org/wiki/ -->
53        <script src="${resource(dir: 'js', file: 'timeline-simile/timeline-api.js')}" type="text/javascript"></script>
54        <script src="${resource(dir: 'js', file: 'timeline-simile/custom-timeline.js')}" type="text/javascript"></script>
55        <script src="${resource(dir: 'js', file: 'timeline-simile/relative-time.js')}" type="text/javascript"></script>
56        <script src="${resource(dir: 'js', file: 'jquery-callback-1.2.js')}" type="text/javascript"></script>
57
58        <!-- Create the JSON objects for the timeline with events -->
59        <script type="text/javascript" src="<g:createLink action="createTimelineBandsJs" id="${studyList.id.join(',')}"/>" type="text/javascript"></script>
60</head>
61<body>
62
63<div class="body" id="studies">
64        <h1><g:message code="default.show.label" args="[entityName]"/></h1>
65        <g:if test="${flash.message}">
66                <div class="message">${flash.message}</div>
67        </g:if>
68        <div class="dialog">
69                <div id="tabs">
70                        <ul>
71                                <li tab="study"><a href="#study">Study Information</a></li>
72                                <li tab="subjects"><a href="<g:createLink action="show_subjects" id="${studyList.id.join(',')}"/>" title="Subjects"><span>Subjects</span></a></li>
73                                <li tab="events"><a href="#events-timeline"><span>Events timeline</span></a></li>
74                                <li tab="events"><a href="<g:createLink action="show_events_table" id="${studyList.id.join(',')}"/>" title="Events table"><span>Events table</span></a></li>
75                                <li tab="assays"><a href="<g:createLink action="show_assays" id="${studyList.id.join(',')}"/>" title="Assays"><span>Assays</span></a></li>
76                                <li tab="samples"><a href="<g:createLink action="show_samples" id="${studyList.id.join(',')}"/>" title="Samples"><span>Samples</span></a></li>
77                                <li tab="study"><a href="<g:createLink action="show_persons" id="${studyList.id.join(',')}"/>" title="Persons"><span>Persons</span></a></li>
78                                <li tab="study"><a href="<g:createLink action="show_publications" id="${studyList.id.join(',')}"/>" title="Publications"><span>Publications</span></a></li>
79                        </ul>
80
81                        <div id="study">
82                                <table>
83                                <!-- only show the head section if there are multiple studies -->
84                                        <g:if test="${multipleStudies}">
85                                                <thead>
86                                                <tr>
87                                                        <th></th>
88                                                        <g:each in="${studyList}" var="studyInstance">
89                                                                <th>${studyInstance.title}</th>
90                                                        </g:each>
91                                                </tr>
92                                                </thead>
93                                        </g:if>
94                                        <%
95                                                // Determine a union of the fields from all studies, in order
96                                                // to show a proper list. We want every field to appear just once,
97                                                // so the list is filtered for unique values
98                                                studyFields = studyList[0].giveDomainFields() + studyList*.giveTemplateFields()?.flatten().unique()
99                                        %>
100                                <!-- Show all template and domain fields, if filled -->
101                                        <g:each in="${studyFields}" var="field">
102                                                <g:if test="${field && field?.isFilledInList( studyList )}">
103                                                        <tr>
104                                                                <td>${field}</td>
105                                                                <g:each in="${studyList}" var="studyInstance">
106                                                                        <td>
107                                                                                <g:if test="${studyInstance.fieldExists(field.name)}">
108                                                                                        <af:showTemplateField field="${field}" entity="${studyInstance}"/>
109                                                                                </g:if>
110                                                                                <g:else>
111                                                                                        -
112                                                                                </g:else>
113                                                                        </td>
114                                                                </g:each>
115                                                        </tr>
116                                                </g:if>
117                                        </g:each>
118
119                                <!-- Add some extra fields -->
120                                        <tr>
121                                                <td>Events</td>
122                                                <g:each in="${studyList}" var="studyInstance">
123                                                        <td>
124                                                                <g:if test="${studyInstance.giveEventTemplates()?.size()==0}">
125                                                                        -
126                                                                </g:if>
127                                                                <g:else>
128                                                                        ${studyInstance.giveEventTemplates().name.join(", ")}
129                                                                </g:else>
130                                                        </td>
131                                                </g:each>
132                                        </tr>
133                                        <tr>
134                                                <td>Sampling events</td>
135                                                <g:each in="${studyList}" var="studyInstance">
136                                                        <td>
137                                                                <g:if test="${studyInstance.giveSamplingEventTemplates()?.size()==0}">
138                                                                        -
139                                                                </g:if>
140                                                                <g:else>
141                                                                        ${studyInstance.giveSamplingEventTemplates().name.join(", ")}
142                                                                </g:else>
143                                                        </td>
144                                                </g:each>
145                                        </tr>
146                                        <tr>
147                                                <td>Public</td>
148                                                <g:each in="${studyList}" var="studyInstance">
149                                                        <td>
150                                                                ${studyInstance.publicstudy}
151                                                        </td>
152                                                </g:each>
153                                        </tr>
154                                        <tr>
155                                                <td>Owner</td>
156                                                <g:each in="${studyList}" var="studyInstance">
157                                                        <td>
158                                                                ${studyInstance.owner?.username}
159                                                        </td>
160                                                </g:each>
161                                        </tr>
162                                        <tr>
163                                                <td>Readers</td>
164                                                <g:each in="${studyList}" var="studyInstance">
165                                                        <td>
166                                                                <g:if test="${studyInstance.readers.size() == 0}">
167                                                                        -
168                                                                </g:if>
169                                                                <g:else>
170                                                                        ${studyInstance.readers.username.join(", ")}
171                                                                </g:else>
172                                                        </td>
173                                                </g:each>
174                                        </tr>
175                                        <tr>
176                                                <td>Writers</td>
177                                                <g:each in="${studyList}" var="studyInstance">
178                                                        <td>
179                                                                <g:if test="${studyInstance.writers?.size()==0}">
180                                                                        -
181                                                                </g:if>
182                                                                <g:else>
183                                                                        ${studyInstance.writers.username.join(", ")}
184                                                                </g:else>
185                                                        </td>
186                                                </g:each>
187                                        </tr>
188                                </table>
189                        </div>
190
191                  <div id="events-timeline">
192                        <g:if test="${studyList*.events?.flatten()?.size()==0 && studyInstance*.samplingEvents?.flatten()?.size()==0 }">
193                          No events in these studies
194                        </g:if>
195                        <g:else>
196                          <g:each in="${studyList}" var="study" status="i">
197                                <div style="margin: 10px; ">
198                                  <div class="eventtitles" id="eventtitles-${i}"></div>
199                                  <div class="eventstimeline" id="eventstimeline-${i}"></div>
200                                </div>
201                          </g:each>
202                          <noscript>
203                                Javascript is needed for showing the timeline, but it has been disabled in your browser. Please enable javascript or use
204                                the events table instead.
205                          </noscript>
206                        </g:else>
207                  </div>
208
209                        <% /*
210                  All other tabs are moved to separate views and are loaded using
211                  ajax calls when a tab is opened. See http://jqueryui.com/demos/tabs/#ajax
212                */ %>
213
214                </div>
215        </div>
216        <br>
217        <div class="buttons">
218                <g:form action="delete">
219                        <g:if test="${studyList?.size() == 1}">
220                                <g:set var="studyInstance" value="${studyList[0]}"/>
221                                <g:hiddenField name="id" value="${studyInstance?.id}"/>
222                                <g:if test="${studyInstance.canWrite(loggedInUser)}">
223                                        <span class="button">
224                                                <g:link class="edit linktips" title="Edit this stuy" onclick="getTab(); return false;">
225                                                        ${message(code: 'default.button.edit.label', default: 'Edit')}
226                                                </g:link>
227                                        </span>
228                                        <span class="button"><g:link class="edit linktips" title="Edit the basic properties of this study" controller="simpleWizard" action="index" id="${studyInstance?.id}">Simple edit</g:link></span>
229                                </g:if>
230                                <g:if test="${studyInstance.isOwner(loggedInUser)}">
231                                        <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>
232                                </g:if>
233                        </g:if>
234
235                        <script type="text/javascript">
236                                function getTab() {
237                                        var tab = $('li.ui-state-active', $('ul.ui-tabs-nav')).attr('tab');
238                                        var url = '<g:createLink controller="studyWizard" params="[jump:'edit']" id="${studyInstance?.id}" />&tab='+tab;
239                                        document.location = url;
240                                }
241                        </script>
242
243                        <span class="button"><g:link class="backToList" action="list">Back to list</g:link></span>
244                </g:form>
245        </div>
246</div>
247</body>
248</html>
Note: See TracBrowser for help on using the repository browser.