1 | <html> |
---|
2 | |
---|
3 | <head> |
---|
4 | <meta name="layout" content="main" /> |
---|
5 | <g:set var="entityName" value="${message(code: 'event.label', default: 'Event')}" /> |
---|
6 | <g:setProvider library="jquery"/> |
---|
7 | <script src="${createLinkTo(dir: 'js', file: 'timepicker-0.2.1.js')}" type="text/javascript"></script> |
---|
8 | </head> |
---|
9 | |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | |
---|
14 | <body> |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | <script type="text/javascript"> |
---|
20 | |
---|
21 | var nextSampleRowId=0; |
---|
22 | |
---|
23 | function addAddButton(elementId,sampleTableId) { |
---|
24 | var parent=document.getElementById(elementId); |
---|
25 | var button=document.createElement('input'); |
---|
26 | button.setAttribute('type','button'); |
---|
27 | button.setAttribute('onclick','addEmptySampleRow(\''+sampleTableId+'\');'); |
---|
28 | button.value='add Sample'; |
---|
29 | parent.appendChild(button); |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | function addEmptySampleRow(elementId) { |
---|
34 | addSampleRow(elementId,'',''); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | function addSampleRow(elementId,text1,text2) { |
---|
39 | addSampleRowWithId(elementId,text1,text2,nextSampleRowId); |
---|
40 | nextSampleRowId++; |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | function addSampleRowWithId(elementId,text1,text2,newId) { |
---|
45 | |
---|
46 | var parent=document.getElementById(elementId); |
---|
47 | var tr=document.createElement('tr'); |
---|
48 | tr.id='samplerow'+newId; |
---|
49 | parent.appendChild(tr); |
---|
50 | |
---|
51 | var td1=document.createElement('td'); |
---|
52 | var input1= document.createElement('input'); |
---|
53 | input1.type='text'; |
---|
54 | input1.value=text1; |
---|
55 | input1.name='sampleName'+(newId); |
---|
56 | input1.id=input1.name |
---|
57 | td1.appendChild(input1); |
---|
58 | |
---|
59 | var td2=document.createElement('td'); |
---|
60 | var input2= document.createElement('input'); |
---|
61 | input2.type='text'; |
---|
62 | input2.value=text2; |
---|
63 | input2.name='sampleMaterial'+(newId); |
---|
64 | input2.id=input2.name |
---|
65 | td2.appendChild(input2); |
---|
66 | |
---|
67 | tr.appendChild(td1); |
---|
68 | tr.appendChild(td2); |
---|
69 | |
---|
70 | var td3=document.createElement('td'); |
---|
71 | var button=document.createElement('input'); |
---|
72 | button.setAttribute('type','button'); |
---|
73 | button.value='delete'; |
---|
74 | button.onclick=function(){jQuery(tr).remove();} |
---|
75 | tr.appendChild(td3); |
---|
76 | td3.appendChild(button); |
---|
77 | } |
---|
78 | |
---|
79 | </script> |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | <div class="body"> |
---|
85 | |
---|
86 | <h1><g:message code="default.create.label" args="[entityName]" /></h1> |
---|
87 | |
---|
88 | |
---|
89 | <g:if test="${flash.message}"> |
---|
90 | <div class="message">${flash.message}</div> |
---|
91 | </g:if> |
---|
92 | <g:hasErrors bean="${eventInstance}"> |
---|
93 | <div class="errors"> <g:renderErrors bean="${eventInstance}" as="list" /> </div> |
---|
94 | </g:hasErrors> |
---|
95 | |
---|
96 | |
---|
97 | <g:form action="save" method="post" id="${eventInstance.id}"> |
---|
98 | |
---|
99 | <div class="dialog"> |
---|
100 | <table> |
---|
101 | <tbody> |
---|
102 | |
---|
103 | |
---|
104 | <!-- show the EventDescription --> |
---|
105 | |
---|
106 | <tr class="prop"> |
---|
107 | <td valign="top" class="name"> |
---|
108 | <label for="name"><g:message code="eventDescription.name.label" default="Name" /></label> |
---|
109 | </td> |
---|
110 | <td valign="top" class="value ${hasErrors(bean: description, field: 'name', 'errors')}"> |
---|
111 | <g:textField name="name" value="${description?.name}" /> |
---|
112 | </td> |
---|
113 | </tr> |
---|
114 | |
---|
115 | |
---|
116 | <tr class="prop"> |
---|
117 | <td valign="top" class="name"> |
---|
118 | <label for="description"><g:message code="eventDescription.description.label" default="Description" /></label> |
---|
119 | </td> |
---|
120 | <td valign="top" class="value ${hasErrors(bean: description, field: 'description', 'errors')}"> |
---|
121 | <g:textArea name="description" value="${description?.description}" cols="40" rows="6" /> |
---|
122 | </td> |
---|
123 | </tr> |
---|
124 | |
---|
125 | |
---|
126 | <!-- show Event members --> |
---|
127 | |
---|
128 | <tr class="prop"> |
---|
129 | <td valign="top" class="name"> |
---|
130 | <label for="startTime"><g:message code="event.startTime" default="Start Time" /></label> |
---|
131 | </td> |
---|
132 | <td valign="top" class="name"> |
---|
133 | <script> $(function() { $('#startTime').datepicker({ duration: '', showTime: true, constrainInput: false });}); </script> |
---|
134 | <% def displayStartTime =String.format("%tm/", sDate ) %> |
---|
135 | <% displayStartTime+=String.format("%td/", sDate ) %> |
---|
136 | <% displayStartTime+=String.format("%tY", sDate ) %> |
---|
137 | <% displayStartTime+=String.format(" %tI:", sDate ) %> |
---|
138 | <% displayStartTime+=String.format("%tM ", sDate ) %> |
---|
139 | <% displayStartTime+=String.format("%tp", sDate ) %> |
---|
140 | <g:textField name="startTime" value="${displayStartTime}" /> |
---|
141 | </td> |
---|
142 | </tr> |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | <tr class="prop"> |
---|
147 | <td valign="top" class="name"> |
---|
148 | <label for="endTime"><g:message code="event.endTime.label" default="End Time" /></label> |
---|
149 | </td> |
---|
150 | <td valign="top" class="name"> |
---|
151 | <script> $(function() { $('#endTime').datepicker({ duration: '', showTime: true, constrainInput: false });}); </script> |
---|
152 | <% def displayEndTime =String.format("%tm/", eDate ) %> |
---|
153 | <% displayEndTime+=String.format("%td/", eDate ) %> |
---|
154 | <% displayEndTime+=String.format("%tY", eDate ) %> |
---|
155 | <% displayEndTime+=String.format(" %tI:", eDate ) %> |
---|
156 | <% displayEndTime+=String.format("%tM ", eDate ) %> |
---|
157 | <% displayEndTime+=String.format("%tp", eDate ) %> |
---|
158 | <g:textField name="endTime" value="${displayEndTime}" /> |
---|
159 | </td> |
---|
160 | </tr> |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | <!-- select protocol --> |
---|
165 | |
---|
166 | <tr class="prop"> |
---|
167 | |
---|
168 | <td valign="top" class="name" width=200 > |
---|
169 | <label for="protocol"><g:message code="eventDescription.protocol.label" default="Protocol" /></label> |
---|
170 | </td> |
---|
171 | <td valign="top" class="value ${hasErrors(bean: description, field: 'rotocol', 'errors')}"> |
---|
172 | <% protocols=dbnp.studycapturing.Protocol.list() %> |
---|
173 | <g:select name="protocol" id="protocol" from="${protocols}" optionKey="id" optionValue="${{it.name}}" |
---|
174 | value="${{it?.id}}" onchange="${remoteFunction(action:'showPartial', controller:'eventDescription', update:'preview', |
---|
175 | params:'\'protocolid=\' + this.value')} " /> |
---|
176 | </td> |
---|
177 | </tr> |
---|
178 | |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | <tbody id="preview"> |
---|
184 | |
---|
185 | <!-- this part changes dynamically on select --> |
---|
186 | <g:include action='showPartial' controller='eventDescription' params="[protocolid:protocols[0].id]" id="${eventInstance.id}" /> |
---|
187 | |
---|
188 | |
---|
189 | <!-- show checkbox when creating events --> |
---|
190 | <g:if test="${createNew}"> |
---|
191 | <tr class="prop"> |
---|
192 | <td valign="top" class="name"> |
---|
193 | <label for="endTime"><g:message code="event.endTime.label" default="This is a Sampling event" /></label> |
---|
194 | </td> |
---|
195 | <td valign="top" class="name"> |
---|
196 | <g:checkBox name="isSamplingEvent" value="${false}" /> |
---|
197 | </td> |
---|
198 | </tr> |
---|
199 | </g:if> |
---|
200 | |
---|
201 | </tbody> |
---|
202 | |
---|
203 | |
---|
204 | |
---|
205 | |
---|
206 | |
---|
207 | |
---|
208 | </tbody> <!-- end of main table --> |
---|
209 | |
---|
210 | |
---|
211 | |
---|
212 | |
---|
213 | |
---|
214 | |
---|
215 | |
---|
216 | <!-- samplePartial --> |
---|
217 | |
---|
218 | <g:if test="${showSample}"> |
---|
219 | |
---|
220 | <tbody> |
---|
221 | <tr> <td> Sample </td> <td> |
---|
222 | <table> |
---|
223 | <thead> <th>Name</th> <th>Material</th> <th> Delete </th> </thead> |
---|
224 | <tbody id="Samples" class="Samples"> </tbody> |
---|
225 | </table> |
---|
226 | </td> </tr> |
---|
227 | <g:each var="sample" in="${samples}"> |
---|
228 | <script type="text/javascript"> |
---|
229 | addSampleRowWithId('Samples',"${sample.name}","${sample.material}","_existing_${sample.id}") |
---|
230 | </script> |
---|
231 | </g:each> |
---|
232 | <tr><td></td><td id="sampleAddButtonRow"></td></tr> |
---|
233 | </tbody> |
---|
234 | |
---|
235 | <script type="text/javascript"> |
---|
236 | addAddButton('sampleAddButtonRow','Samples'); |
---|
237 | </script> |
---|
238 | |
---|
239 | </g:if> |
---|
240 | |
---|
241 | |
---|
242 | |
---|
243 | </table> |
---|
244 | </div> |
---|
245 | |
---|
246 | <div class="buttons"> |
---|
247 | <span class="button"><g:submitButton name="save" class="save" value="${message(code: 'default.button.save.label', default: 'Save')}" /></span> |
---|
248 | </div> |
---|
249 | |
---|
250 | |
---|
251 | </g:form> |
---|
252 | </div> |
---|
253 | |
---|
254 | |
---|
255 | </body> |
---|
256 | </html> |
---|