1 | <%inherit file="/base.mako"/> |
---|
2 | <%namespace file="/message.mako" import="render_msg" /> |
---|
3 | <%namespace file="/requests/common/sample_state.mako" import="render_sample_state" /> |
---|
4 | <%namespace file="/requests/common/sample_datasets.mako" import="render_sample_datasets" /> |
---|
5 | |
---|
6 | <%def name="stylesheets()"> |
---|
7 | ${parent.stylesheets()} |
---|
8 | ${h.css( "library" )} |
---|
9 | </%def> |
---|
10 | |
---|
11 | <%def name="javascripts()"> |
---|
12 | ${parent.javascripts()} |
---|
13 | <script type="text/javascript"> |
---|
14 | function showContent(vThis) |
---|
15 | { |
---|
16 | // http://www.javascriptjunkie.com |
---|
17 | // alert(vSibling.className + " " + vDef_Key); |
---|
18 | vParent = vThis.parentNode; |
---|
19 | vSibling = vParent.nextSibling; |
---|
20 | while (vSibling.nodeType==3) { |
---|
21 | // Fix for Mozilla/FireFox Empty Space becomes a TextNode or Something |
---|
22 | vSibling = vSibling.nextSibling; |
---|
23 | }; |
---|
24 | if(vSibling.style.display == "none") |
---|
25 | { |
---|
26 | vThis.src="/static/images/fugue/toggle.png"; |
---|
27 | vThis.alt = "Hide"; |
---|
28 | vSibling.style.display = "block"; |
---|
29 | } else { |
---|
30 | vSibling.style.display = "none"; |
---|
31 | vThis.src="/static/images/fugue/toggle-expand.png"; |
---|
32 | vThis.alt = "Show"; |
---|
33 | } |
---|
34 | return; |
---|
35 | } |
---|
36 | |
---|
37 | $(document).ready(function(){ |
---|
38 | //hide the all of the element with class msg_body |
---|
39 | $(".msg_body").hide(); |
---|
40 | //toggle the component with class msg_body |
---|
41 | $(".msg_head").click(function(){ |
---|
42 | $(this).next(".msg_body").slideToggle(0); |
---|
43 | }); |
---|
44 | }); |
---|
45 | |
---|
46 | // Looks for changes in sample states using an async request. Keeps |
---|
47 | // calling itself (via setTimeout) until all samples are in a terminal |
---|
48 | // state. |
---|
49 | var updater = function ( sample_states ) { |
---|
50 | // Check if there are any items left to track |
---|
51 | var empty = true; |
---|
52 | for ( i in sample_states ) { |
---|
53 | empty = false; |
---|
54 | break; |
---|
55 | } |
---|
56 | if ( ! empty ) { |
---|
57 | setTimeout( function() { updater_callback( sample_states ) }, 1000 ); |
---|
58 | } |
---|
59 | }; |
---|
60 | |
---|
61 | var updater_callback = function ( sample_states ) { |
---|
62 | // Build request data |
---|
63 | var ids = [] |
---|
64 | var states = [] |
---|
65 | $.each( sample_states, function ( id, state ) { |
---|
66 | ids.push( id ); |
---|
67 | states.push( state ); |
---|
68 | }); |
---|
69 | // Make ajax call |
---|
70 | $.ajax( { |
---|
71 | type: "POST", |
---|
72 | url: "${h.url_for( controller='requests_common', action='sample_state_updates' )}", |
---|
73 | dataType: "json", |
---|
74 | data: { ids: ids.join( "," ), states: states.join( "," ) }, |
---|
75 | success : function ( data ) { |
---|
76 | $.each( data, function( id, val ) { |
---|
77 | // Replace HTML |
---|
78 | var cell1 = $("#sampleState-" + id); |
---|
79 | cell1.html( val.html_state ); |
---|
80 | var cell2 = $("#sampleDatasets-" + id); |
---|
81 | cell2.html( val.html_datasets ); |
---|
82 | sample_states[ parseInt( id ) ] = val.state; |
---|
83 | }); |
---|
84 | updater( sample_states ); |
---|
85 | }, |
---|
86 | error: function() { |
---|
87 | // Just retry, like the old method, should try to be smarter |
---|
88 | updater( sample_states ); |
---|
89 | } |
---|
90 | }); |
---|
91 | }; |
---|
92 | |
---|
93 | function checkAllFields() |
---|
94 | { |
---|
95 | var chkAll = document.getElementById('checkAll'); |
---|
96 | var checks = document.getElementsByTagName('input'); |
---|
97 | var boxLength = checks.length; |
---|
98 | var allChecked = false; |
---|
99 | var totalChecked = 0; |
---|
100 | if ( chkAll.checked == true ) |
---|
101 | { |
---|
102 | for ( i=0; i < boxLength; i++ ) |
---|
103 | { |
---|
104 | if ( checks[i].name.indexOf( 'select_sample_' ) != -1) |
---|
105 | { |
---|
106 | checks[i].checked = true; |
---|
107 | } |
---|
108 | } |
---|
109 | } |
---|
110 | else |
---|
111 | { |
---|
112 | for ( i=0; i < boxLength; i++ ) |
---|
113 | { |
---|
114 | if ( checks[i].name.indexOf( 'select_sample_' ) != -1) |
---|
115 | { |
---|
116 | checks[i].checked = false |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | function stopRKey(evt) { |
---|
123 | var evt = (evt) ? evt : ((event) ? event : null); |
---|
124 | var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); |
---|
125 | if ((evt.keyCode == 13) && (node.type=="text")) {return false;} |
---|
126 | } |
---|
127 | document.onkeypress = stopRKey |
---|
128 | </script> |
---|
129 | </%def> |
---|
130 | |
---|
131 | <% is_admin = cntrller == 'requests_admin' and trans.user_is_admin() %> |
---|
132 | |
---|
133 | <div class="grid-header"> |
---|
134 | <h2>Sequencing Request "${request.name}"</h2> |
---|
135 | |
---|
136 | <ul class="manage-table-actions"> |
---|
137 | <li><a class="action-button" id="seqreq-${request.id}-popup" class="menubutton">Sequencing Request Actions</a></li> |
---|
138 | <div popupmenu="seqreq-${request.id}-popup"> |
---|
139 | %if request.is_unsubmitted and request.samples: |
---|
140 | <a class="action-button" confirm="More samples cannot be added to this request once it is submitted. Click OK to submit." href="${h.url_for( controller='requests_common', action='submit_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Submit</a> |
---|
141 | %endif |
---|
142 | <a class="action-button" href="${h.url_for( controller='requests_common', action='request_events', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">History</a> |
---|
143 | %if is_admin: |
---|
144 | %if request.is_submitted: |
---|
145 | <a class="action-button" href="${h.url_for( controller='requests_admin', action='reject', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Reject</a> |
---|
146 | <a class="action-button" href="${h.url_for( controller='requests_admin', action='get_data', request_id=trans.security.encode_id( request.id ) )}">Select datasets to transfer</a> |
---|
147 | %endif |
---|
148 | %endif |
---|
149 | </div> |
---|
150 | <li><a class="action-button" href="${h.url_for( controller=cntrller, action='browse_requests' )}">Browse requests</a></li> |
---|
151 | </ul> |
---|
152 | |
---|
153 | <div class="toolParamHelp" style="clear: both;"> |
---|
154 | <b>Sequencer</b>: ${request.type.name} |
---|
155 | %if is_admin: |
---|
156 | | <b>User</b>: ${request.user.email} |
---|
157 | %endif |
---|
158 | %if request.is_submitted: |
---|
159 | | <b>State</b>: <i>${request.state}</i> |
---|
160 | %else: |
---|
161 | | <b>State</b>: ${request.state} |
---|
162 | %endif |
---|
163 | </div> |
---|
164 | </div> |
---|
165 | |
---|
166 | %if request.samples_without_library_destinations: |
---|
167 | ${render_msg( "Select a target data library and folder for all the samples before starting the sequence run", "warning" )} |
---|
168 | %endif |
---|
169 | |
---|
170 | %if request.is_rejected: |
---|
171 | ${render_msg( "Reason for rejection: " + request.last_comment, "warning" )} |
---|
172 | %endif |
---|
173 | |
---|
174 | %if message: |
---|
175 | ${render_msg( message, status )} |
---|
176 | %endif |
---|
177 | |
---|
178 | <h4><img src="/static/images/fugue/toggle-expand.png" alt="Show" onclick="showContent(this);" style="cursor:pointer;"/> Request Information</h4> |
---|
179 | <div style="display:none;"> |
---|
180 | <div class="form-row"> |
---|
181 | <ul class="manage-table-actions"> |
---|
182 | <li> |
---|
183 | <a class="action-button" href="${h.url_for( controller='requests_common', action='edit_basic_request_info', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Edit request informaton</a> |
---|
184 | </li> |
---|
185 | </ul> |
---|
186 | </div> |
---|
187 | <table class="grid" border="0"> |
---|
188 | <tbody> |
---|
189 | <tr> |
---|
190 | <td valign="top" width="50%"> |
---|
191 | <div class="form-row"> |
---|
192 | <label>Description:</label> |
---|
193 | ${request.desc} |
---|
194 | </div> |
---|
195 | <div style="clear: both"></div> |
---|
196 | %for index, rd in enumerate( request_widgets ): |
---|
197 | <% |
---|
198 | field_label = rd[ 'label' ] |
---|
199 | field_value = rd[ 'value' ] |
---|
200 | %> |
---|
201 | <div class="form-row"> |
---|
202 | <label>${field_label}:</label> |
---|
203 | %if field_label == 'State': |
---|
204 | <a href="${h.url_for( controller='requests_common', action='request_events', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">${field_value}</a> |
---|
205 | %else: |
---|
206 | ${field_value} |
---|
207 | %endif |
---|
208 | </div> |
---|
209 | <div style="clear: both"></div> |
---|
210 | %endfor |
---|
211 | </td> |
---|
212 | <td valign="top" width="50%"> |
---|
213 | <div class="form-row"> |
---|
214 | <label>Date created:</label> |
---|
215 | ${request.create_time} |
---|
216 | </div> |
---|
217 | <div class="form-row"> |
---|
218 | <label>Date updated:</label> |
---|
219 | ${request.update_time} |
---|
220 | </div> |
---|
221 | <div class="form-row"> |
---|
222 | <label>Email notification recipients:</label> |
---|
223 | <% |
---|
224 | if request.notification: |
---|
225 | emails = ', '.join( request.notification[ 'email' ] ) |
---|
226 | else: |
---|
227 | emails = '' |
---|
228 | %> |
---|
229 | ${emails} |
---|
230 | </div> |
---|
231 | <div style="clear: both"></div> |
---|
232 | <div class="form-row"> |
---|
233 | <label>Email notification on sample states:</label> |
---|
234 | <% |
---|
235 | if request.notification: |
---|
236 | states = [] |
---|
237 | for ss in request.type.states: |
---|
238 | if ss.id in request.notification[ 'sample_states' ]: |
---|
239 | states.append( ss.name ) |
---|
240 | states = ', '.join( states ) |
---|
241 | else: |
---|
242 | states = '' |
---|
243 | %> |
---|
244 | ${states} |
---|
245 | </div> |
---|
246 | <div style="clear: both"></div> |
---|
247 | </td> |
---|
248 | </tr> |
---|
249 | </tbody> |
---|
250 | </table> |
---|
251 | </div> |
---|
252 | <br/> |
---|
253 | <form id="manage_request" name="manage_request" action="${h.url_for( controller='requests_common', action='manage_request', cntrller=cntrller, id=trans.security.encode_id( request.id ), managing_samples=managing_samples )}" method="post"> |
---|
254 | %if current_samples: |
---|
255 | <% sample_operation_selected_value = sample_operation_select_field.get_selected( return_value=True ) %> |
---|
256 | ## first render the basic info grid |
---|
257 | ${render_basic_info_grid()} |
---|
258 | %if not request.is_new and not managing_samples and len( sample_operation_select_field.options ) > 1: |
---|
259 | <div class="form-row" style="background-color:#FAFAFA;"> |
---|
260 | For selected samples: |
---|
261 | ${sample_operation_select_field.get_html()} |
---|
262 | </div> |
---|
263 | %if sample_operation_selected_value != 'none' and selected_samples: |
---|
264 | <div class="form-row" style="background-color:#FAFAFA;"> |
---|
265 | %if sample_operation_selected_value == trans.model.Sample.bulk_operations.CHANGE_STATE: |
---|
266 | ## sample_operation_selected_value == 'Change state' |
---|
267 | <div class="form-row"> |
---|
268 | <label>Change current state</label> |
---|
269 | ${sample_state_id_select_field.get_html()} |
---|
270 | <label>Comments</label> |
---|
271 | <input type="text" name="sample_event_comment" value=""/> |
---|
272 | <div class="toolParamHelp" style="clear: both;"> |
---|
273 | Optional |
---|
274 | </div> |
---|
275 | </div> |
---|
276 | <div class="form-row"> |
---|
277 | <input type="submit" name="change_state_button" value="Save"/> |
---|
278 | <input type="submit" name="cancel_change_state_button" value="Cancel"/> |
---|
279 | </div> |
---|
280 | %elif sample_operation_selected_value == trans.app.model.Sample.bulk_operations.SELECT_LIBRARY: |
---|
281 | <% libraries_selected_value = libraries_select_field.get_selected( return_value=True ) %> |
---|
282 | <div class="form-row"> |
---|
283 | <label>Select data library:</label> |
---|
284 | ${libraries_select_field.get_html()} |
---|
285 | </div> |
---|
286 | %if libraries_selected_value != 'none': |
---|
287 | <div class="form-row"> |
---|
288 | <label>Select folder:</label> |
---|
289 | ${folders_select_field.get_html()} |
---|
290 | </div> |
---|
291 | <div class="form-row"> |
---|
292 | <input type="submit" name="change_lib_button" value="Save"/> |
---|
293 | <input type="submit" name="cancel_change_lib_button" value="Cancel"/> |
---|
294 | </div> |
---|
295 | %endif |
---|
296 | %endif |
---|
297 | </div> |
---|
298 | %endif |
---|
299 | %endif |
---|
300 | ## Render the other grids |
---|
301 | <% trans.sa_session.refresh( request.type.sample_form ) %> |
---|
302 | %for grid_index, grid_name in enumerate( request.type.sample_form.layout ): |
---|
303 | ${render_grid( grid_index, grid_name, request.type.sample_form.fields_of_grid( grid_index ) )} |
---|
304 | %endfor |
---|
305 | %else: |
---|
306 | <label>There are no samples.</label> |
---|
307 | %endif |
---|
308 | %if request.samples and request.is_submitted: |
---|
309 | <script type="text/javascript"> |
---|
310 | // Updater |
---|
311 | updater({${ ",".join( [ '"%s" : "%s"' % ( s.id, s.state.name ) for s in request.samples ] ) }}); |
---|
312 | </script> |
---|
313 | %endif |
---|
314 | %if not managing_samples: |
---|
315 | <table class="grid"> |
---|
316 | <tbody> |
---|
317 | <tr> |
---|
318 | <div class="form-row"> |
---|
319 | %if request.is_unsubmitted: |
---|
320 | <td> |
---|
321 | %if current_samples: |
---|
322 | <label>Copy </label> |
---|
323 | <input type="integer" name="num_sample_to_copy" value="1" size="3"/> |
---|
324 | <label>samples from sample</label> |
---|
325 | ${sample_copy.get_html()} |
---|
326 | %endif |
---|
327 | <input type="submit" name="add_sample_button" value="Add New"/> |
---|
328 | </td> |
---|
329 | %endif |
---|
330 | <td> |
---|
331 | %if current_samples and len( current_samples ) <= len( request.samples ): |
---|
332 | <input type="submit" name="edit_samples_button" value="Edit samples"/> |
---|
333 | %endif |
---|
334 | </td> |
---|
335 | </div> |
---|
336 | </tr> |
---|
337 | </tbody> |
---|
338 | </table> |
---|
339 | %endif |
---|
340 | %if request.samples or current_samples: |
---|
341 | %if managing_samples: |
---|
342 | <div class="form-row"> |
---|
343 | <input type="submit" name="save_samples_button" value="Save"/> |
---|
344 | <input type="submit" name="cancel_changes_button" value="Cancel"/> |
---|
345 | </div> |
---|
346 | %elif len( current_samples ) > len( request.samples ): |
---|
347 | <div class="form-row"> |
---|
348 | <input type="submit" name="save_samples_button" value="Save"/> |
---|
349 | <input type="submit" name="cancel_changes_button" value="Cancel"/> |
---|
350 | </div> |
---|
351 | %endif |
---|
352 | %endif |
---|
353 | </form> |
---|
354 | <br/> |
---|
355 | %if request.is_unsubmitted: |
---|
356 | <form id="import" name="import" action="${h.url_for( controller='requests_common', action='manage_request', managing_samples=managing_samples, id=trans.security.encode_id( request.id ) )}" enctype="multipart/form-data" method="post" > |
---|
357 | <h4><img src="/static/images/fugue/toggle-expand.png" alt="Show" onclick="showContent(this);" style="cursor:pointer;"/> Import samples</h4> |
---|
358 | <div style="display:none;"> |
---|
359 | <input type="file" name="file_data" /> |
---|
360 | <input type="submit" name="import_samples_button" value="Import samples"/> |
---|
361 | <br/> |
---|
362 | <div class="toolParamHelp" style="clear: both;"> |
---|
363 | The csv file must be in the following format:<br/> |
---|
364 | SampleName,DataLibrary,DataLibraryFolder,FieldValue1,FieldValue2... |
---|
365 | </div> |
---|
366 | </div> |
---|
367 | </form> |
---|
368 | %endif |
---|
369 | |
---|
370 | <%def name="render_grid( grid_index, grid_name, fields_dict )"> |
---|
371 | <br/> |
---|
372 | <% if not grid_name: |
---|
373 | grid_name = "Grid "+ grid_index |
---|
374 | %> |
---|
375 | <div> |
---|
376 | %if managing_samples or len( current_samples ) > len( request.samples ): |
---|
377 | <h4><img src="/static/images/fugue/toggle.png" alt="Show" onclick="showContent(this);" style="cursor:pointer;"/> ${grid_name}</h4> |
---|
378 | <div> |
---|
379 | %else: |
---|
380 | <h4><img src="/static/images/fugue/toggle-expand.png" alt="Hide" onclick="showContent(this);" style="cursor:pointer;"/> ${grid_name}</h4> |
---|
381 | <div style="display:none;"> |
---|
382 | %endif |
---|
383 | <table class="grid"> |
---|
384 | <thead> |
---|
385 | <tr> |
---|
386 | <th>Name</th> |
---|
387 | %for index, field in fields_dict.items(): |
---|
388 | <th> |
---|
389 | ${field['label']} |
---|
390 | <div class="toolParamHelp" style="clear: both;"> |
---|
391 | <i>${field['helptext']}</i> |
---|
392 | </div> |
---|
393 | </th> |
---|
394 | %endfor |
---|
395 | <th></th> |
---|
396 | </tr> |
---|
397 | <thead> |
---|
398 | <tbody> |
---|
399 | <% trans.sa_session.refresh( request ) %> |
---|
400 | %for sample_index, sample in enumerate( current_samples ): |
---|
401 | %if managing_samples: |
---|
402 | <tr>${render_sample_form( sample_index, sample['name'], sample['field_values'], fields_dict)}</tr> |
---|
403 | %else: |
---|
404 | <tr> |
---|
405 | %if sample_index in range( len( request.samples ) ): |
---|
406 | ${render_sample( sample_index, sample['name'], sample['field_values'], fields_dict )} |
---|
407 | %else: |
---|
408 | ${render_sample_form( sample_index, sample['name'], sample['field_values'], fields_dict)} |
---|
409 | %endif |
---|
410 | </tr> |
---|
411 | %endif |
---|
412 | %endfor |
---|
413 | </tbody> |
---|
414 | </table> |
---|
415 | </div> |
---|
416 | </div> |
---|
417 | </%def> |
---|
418 | |
---|
419 | ## This function displays the "Basic Information" grid |
---|
420 | <%def name="render_basic_info_grid()"> |
---|
421 | <h3>Sample Information</h3> |
---|
422 | <table class="grid"> |
---|
423 | <thead> |
---|
424 | <tr> |
---|
425 | <th><input type="checkbox" id="checkAll" name=select_all_samples_checkbox value="true" onclick='checkAllFields(1);'><input type="hidden" name=select_all_samples_checkbox value="true"></th> |
---|
426 | <th>Name</th> |
---|
427 | <th>Barcode</th> |
---|
428 | <th>State</th> |
---|
429 | <th>Data Library</th> |
---|
430 | <th>Folder</th> |
---|
431 | %if request.is_submitted or request.is_complete: |
---|
432 | <th>Datasets Transferred</th> |
---|
433 | %endif |
---|
434 | <th></th> |
---|
435 | </tr> |
---|
436 | <thead> |
---|
437 | <tbody> |
---|
438 | <% trans.sa_session.refresh( request ) %> |
---|
439 | %for sample_index, info in enumerate( current_samples ): |
---|
440 | <% |
---|
441 | if sample_index in range( len(request.samples ) ): |
---|
442 | sample = request.samples[sample_index] |
---|
443 | else: |
---|
444 | sample = None |
---|
445 | %> |
---|
446 | %if managing_samples: |
---|
447 | <tr>${show_basic_info_form( sample_index, sample, info )}</tr> |
---|
448 | %else: |
---|
449 | <tr> |
---|
450 | %if sample_index in range( len( request.samples ) ): |
---|
451 | %if trans.security.encode_id( sample.id ) in selected_samples: |
---|
452 | <td><input type="checkbox" name=select_sample_${sample.id} id="sample_checkbox" value="true" checked><input type="hidden" name=select_sample_${sample.id} id="sample_checkbox" value="true"></td> |
---|
453 | %else: |
---|
454 | <td><input type="checkbox" name=select_sample_${sample.id} id="sample_checkbox" value="true"><input type="hidden" name=select_sample_${sample.id} id="sample_checkbox" value="true"></td> |
---|
455 | %endif |
---|
456 | <td>${info['name']}</td> |
---|
457 | <td>${info['barcode']}</td> |
---|
458 | %if sample.request.is_unsubmitted: |
---|
459 | <td>Unsubmitted</td> |
---|
460 | %else: |
---|
461 | <td><a id="sampleState-${sample.id}" href="${h.url_for( controller='requests_common', action='sample_events', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${render_sample_state( sample )}</a></td> |
---|
462 | %endif |
---|
463 | %if info['library']: |
---|
464 | %if cntrller == 'requests': |
---|
465 | <td><a href="${h.url_for( controller='library_common', action='browse_library', cntrller='library', id=trans.security.encode_id( info['library'].id ) )}">${info['library'].name}</a></td> |
---|
466 | %elif is_admin: |
---|
467 | <td><a href="${h.url_for( controller='library_common', action='browse_library', cntrller='library_admin', id=trans.security.encode_id( info['library'].id ) )}">${info['library'].name}</a></td> |
---|
468 | %endif |
---|
469 | %else: |
---|
470 | <td></td> |
---|
471 | %endif |
---|
472 | %if info['folder']: |
---|
473 | <td>${info['folder'].name}</td> |
---|
474 | %else: |
---|
475 | <td></td> |
---|
476 | %endif |
---|
477 | %if request.is_submitted or request.is_complete: |
---|
478 | <td><a id="sampleDatasets-${sample.id}" href="${h.url_for( controller='requests_common', action='view_dataset_transfer', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}"> |
---|
479 | ${render_sample_datasets( sample )} |
---|
480 | </a></td> |
---|
481 | %endif |
---|
482 | %else: |
---|
483 | ${show_basic_info_form( sample_index, sample, info )} |
---|
484 | %endif |
---|
485 | %if request.is_unsubmitted or request.is_rejected: |
---|
486 | <td> |
---|
487 | %if sample: |
---|
488 | %if sample.request.is_unsubmitted: |
---|
489 | <a class="action-button" href="${h.url_for( controller='requests_common', cntrller=cntrller, action='delete_sample', request_id=trans.security.encode_id( request.id ), sample_id=sample_index )}"><img src="${h.url_for('/static/images/delete_icon.png')}" style="cursor:pointer;"/></a> |
---|
490 | %endif |
---|
491 | %endif |
---|
492 | </td> |
---|
493 | %endif |
---|
494 | </tr> |
---|
495 | %endif |
---|
496 | %endfor |
---|
497 | </tbody> |
---|
498 | </table> |
---|
499 | </%def> |
---|
500 | |
---|
501 | <%def name="show_basic_info_form( sample_index, sample, info )"> |
---|
502 | <td></td> |
---|
503 | <td> |
---|
504 | <input type="text" name="sample_${sample_index}_name" value="${info['name']}" size="10"/> |
---|
505 | <div class="toolParamHelp" style="clear: both;"> |
---|
506 | <i>${' (required)' }</i> |
---|
507 | </div> |
---|
508 | </td> |
---|
509 | %if cntrller == 'requests': |
---|
510 | %if sample: |
---|
511 | %if sample.request.is_unsubmitted: |
---|
512 | <td></td> |
---|
513 | %else: |
---|
514 | <td><input type="text" name="sample_${sample_index}_barcode" value="${info['barcode']}" size="10"/></td> |
---|
515 | %endif |
---|
516 | %else: |
---|
517 | <td></td> |
---|
518 | %endif |
---|
519 | %elif is_admin: |
---|
520 | %if sample: |
---|
521 | %if sample.request.is_unsubmitted: |
---|
522 | <td></td> |
---|
523 | %else: |
---|
524 | <td><input type="text" name="sample_${sample_index}_barcode" value="${info['barcode']}" size="10"/></td> |
---|
525 | %endif |
---|
526 | %else: |
---|
527 | <td></td> |
---|
528 | %endif |
---|
529 | %endif |
---|
530 | %if sample: |
---|
531 | %if sample.request.is_unsubmitted: |
---|
532 | <td>Unsubmitted</td> |
---|
533 | %else: |
---|
534 | <td><a href="${h.url_for( controller='requests_common', action='sample_events', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${sample.state.name}</a></td> |
---|
535 | %endif |
---|
536 | %else: |
---|
537 | <td></td> |
---|
538 | %endif |
---|
539 | <td>${info['library_select_field'].get_html()}</td> |
---|
540 | <td>${info['folder_select_field'].get_html()}</td> |
---|
541 | %if request.is_submitted or request.is_complete: |
---|
542 | <% |
---|
543 | if sample: |
---|
544 | label = str( len( sample.datasets ) ) |
---|
545 | else: |
---|
546 | label = 'Add' |
---|
547 | %> |
---|
548 | <td><a href="${h.url_for( controller='requests_common', action='view_dataset_transfer', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${label}</a></td> |
---|
549 | %endif |
---|
550 | </%def> |
---|
551 | |
---|
552 | <%def name="render_sample( index, sample_name, sample_values, fields_dict )"> |
---|
553 | <td> |
---|
554 | ${sample_name} |
---|
555 | </td> |
---|
556 | %for field_index, field in fields_dict.items(): |
---|
557 | <td> |
---|
558 | %if sample_values[field_index]: |
---|
559 | %if field['type'] == 'WorkflowField': |
---|
560 | %if str(sample_values[field_index]) != 'none': |
---|
561 | <% workflow = trans.sa_session.query( trans.app.model.StoredWorkflow ).get( int(sample_values[field_index]) ) %> |
---|
562 | <a href="${h.url_for( controller='workflow', action='run', id=trans.security.encode_id(workflow.id) )}">${workflow.name}</a> |
---|
563 | %endif |
---|
564 | %else: |
---|
565 | ${sample_values[field_index]} |
---|
566 | %endif |
---|
567 | %else: |
---|
568 | <i>None</i> |
---|
569 | %endif |
---|
570 | </td> |
---|
571 | %endfor |
---|
572 | </%def> |
---|
573 | |
---|
574 | <%def name="render_sample_form( index, sample_name, sample_values, fields_dict )"> |
---|
575 | <td>${sample_name}</td> |
---|
576 | %for field_index, field in fields_dict.items(): |
---|
577 | <td> |
---|
578 | %if field['type'] == 'TextField': |
---|
579 | <input type="text" name="sample_${index}_field_${field_index}" value="${sample_values[field_index]}" size="7"/> |
---|
580 | %elif field['type'] == 'SelectField': |
---|
581 | <select name="sample_${index}_field_${field_index}" last_selected_value="2"> |
---|
582 | %for option_index, option in enumerate(field['selectlist']): |
---|
583 | %if option == sample_values[field_index]: |
---|
584 | <option value="${option}" selected>${option}</option> |
---|
585 | %else: |
---|
586 | <option value="${option}">${option}</option> |
---|
587 | %endif |
---|
588 | %endfor |
---|
589 | </select> |
---|
590 | %elif field['type'] == 'WorkflowField': |
---|
591 | <select name="sample_${index}_field_${field_index}"> |
---|
592 | %if str(sample_values[field_index]) == 'none': |
---|
593 | <option value="none" selected>Select one</option> |
---|
594 | %else: |
---|
595 | <option value="none">Select one</option> |
---|
596 | %endif |
---|
597 | %for option_index, option in enumerate(request.user.stored_workflows): |
---|
598 | %if not option.deleted: |
---|
599 | %if str(option.id) == str(sample_values[field_index]): |
---|
600 | <option value="${option.id}" selected>${option.name}</option> |
---|
601 | %else: |
---|
602 | <option value="${option.id}">${option.name}</option> |
---|
603 | %endif |
---|
604 | %endif |
---|
605 | %endfor |
---|
606 | </select> |
---|
607 | %elif field['type'] == 'CheckboxField': |
---|
608 | <input type="checkbox" name="sample_${index}_field_${field_index}" value="Yes"/> |
---|
609 | %endif |
---|
610 | <div class="toolParamHelp" style="clear: both;"> |
---|
611 | <i>${'('+field['required']+')' }</i> |
---|
612 | </div> |
---|
613 | </td> |
---|
614 | %endfor |
---|
615 | </%def> |
---|