PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/requests/common/edit_samples.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 145 lines | 132 code | 9 blank | 4 comment | 9 complexity | 5442fa6b9b814cba1ec008950bdc6c83 MD5 | raw file
  1<%inherit file="/base.mako"/>
  2<%namespace file="/message.mako" import="render_msg" />
  3<%namespace file="/requests/common/common.mako" import="common_javascripts" />
  4<%namespace file="/requests/common/common.mako" import="render_samples_grid" />
  5<%namespace file="/requests/common/common.mako" import="render_request_type_sample_form_grids" />
  6<%namespace file="/requests/common/common.mako" import="render_samples_messages" />
  7
  8<%def name="stylesheets()">
  9    ${parent.stylesheets()}
 10    ${h.css( "library" )}
 11</%def>
 12
 13<%def name="javascripts()">
 14   ${parent.javascripts()}
 15   ${common_javascripts()}
 16   ${local_javascripts()}
 17</%def>
 18
 19<%def name="local_javascripts()">
 20    <script type="text/javascript">
 21	    // This function stops the form from getting submitted when return key is pressed
 22	    // This is needed in this form as the barcode scanner (when in keyboard emulation mode)
 23	    // may send a return key appended to the scanned barcode string.  
 24	    function stopRKey(evt) {
 25	      var evt = (evt) ? evt : ((event) ? event : null);
 26	      var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
 27	      if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
 28	    }
 29	    document.onkeypress = stopRKey
 30    </script>
 31</%def>
 32
 33<%
 34    from galaxy.web.framework.helpers import time_ago
 35
 36    is_admin = cntrller == 'requests_admin' and trans.user_is_admin()
 37    is_complete = request.is_complete
 38    is_submitted = request.is_submitted
 39    is_unsubmitted = request.is_unsubmitted
 40    if is_admin:
 41        can_add_samples = not is_complete
 42    else:
 43        can_add_samples = is_unsubmitted
 44    can_delete_samples = request.samples and not is_complete
 45    can_edit_request = ( is_admin and not request.is_complete ) or request.is_unsubmitted
 46    can_reject = is_admin and is_submitted
 47    can_submit = request.samples and is_unsubmitted
 48%>
 49
 50<br/><br/>
 51
 52<ul class="manage-table-actions">
 53    %if can_add_samples:
 54        <li><a class="action-button" href="${h.url_for( controller='requests_common', action='add_sample', cntrller=cntrller, request_id=trans.security.encode_id( request.id ), add_sample_button='Add sample' )}">Add sample</a></li>
 55    %endif
 56    %if can_submit:
 57        <li><a class="action-button" confirm="More samples cannot be added to this request after 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 request</a></li>
 58    %endif
 59    <li><a class="action-button" id="request-${request.id}-popup" class="menubutton">Request Actions</a></li>
 60    <div popupmenu="request-${request.id}-popup">
 61        <a class="action-button" href="${h.url_for( controller='requests_common', action='view_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Browse this request</a>
 62        %if can_edit_request:
 63            <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 this request</a>
 64        %endif
 65        <a class="action-button" href="${h.url_for( controller='requests_common', action='view_request_history', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">View history</a>
 66        %if can_reject:
 67            <a class="action-button" href="${h.url_for( controller='requests_admin', action='reject_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Reject this request</a>
 68        %endif
 69    </div>
 70</ul>
 71
 72${render_samples_messages(request, is_admin, is_submitted, message, status)}
 73
 74<div class="toolFormBody">
 75    <form id="edit_samples" name="edit_samples" action="${h.url_for( controller='requests_common', action='edit_samples', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}" method="post">
 76        %if displayable_sample_widgets:
 77            <%
 78                grid_header = '<h3>Edit Current Samples of Sequencing Request "%s"</h3>' % request.name
 79            %>
 80            ${render_samples_grid( cntrller, request, displayable_sample_widgets, action='edit_samples', encoded_selected_sample_ids=encoded_selected_sample_ids, render_buttons=False, grid_header=grid_header )}
 81            %if len( sample_operation_select_field.options ) > 1 and not is_unsubmitted:
 82                <div class="form-row" style="background-color:#FAFAFA;">
 83                    For selected samples: 
 84                    ${sample_operation_select_field.get_html()}
 85                </div>
 86                <% sample_operation_selected_value = sample_operation_select_field.get_selected( return_value=True ) %>
 87                %if ( is_admin or not is_complete ) and sample_operation_selected_value != 'none' and encoded_selected_sample_ids:
 88                    <div class="form-row" style="background-color:#FAFAFA;">
 89                        %if sample_operation_selected_value == trans.model.Sample.bulk_operations.CHANGE_STATE:
 90                            ## sample_operation_selected_value == 'Change state'
 91                            <div class="form-row">
 92                                <label>Change current state</label>
 93                                ${sample_state_id_select_field.get_html()}
 94                                <label>Comments</label>
 95                                <input type="text" name="sample_event_comment" value=""/>
 96                                <div class="toolParamHelp" style="clear: both;">
 97                                    Optional
 98                                </div>
 99                            </div>
100                        %elif sample_operation_selected_value == trans.app.model.Sample.bulk_operations.SELECT_LIBRARY:
101                        <% libraries_selected_value = libraries_select_field.get_selected( return_value=True ) %>
102                            <div class="form-row">
103    	                        <label>Select data library:</label>
104    	                        ${libraries_select_field.get_html()}
105                            </div>
106                            %if libraries_selected_value != 'none':
107                                <div class="form-row">
108    		                        <label>Select folder:</label>
109    		                        ${folders_select_field.get_html()}
110    	                        </div>
111                            %endif
112                        %endif
113                    </div>
114                %endif
115            %endif
116            <div class="toolParamHelp" style="clear: both;">
117                For each sample, select the data library and folder in which you would like the run datasets deposited.
118                To automatically run a workflow on run datastets, select a history first and then the desired workflow. 
119            </div>
120            ## Render the other grids
121            <% trans.sa_session.refresh( request.type.sample_form ) %>
122            %for grid_index, grid_name in enumerate( request.type.sample_form.layout ):
123                ${render_request_type_sample_form_grids( grid_index, grid_name, request.type.sample_form.grid_fields( grid_index ), displayable_sample_widgets=displayable_sample_widgets, show_saved_samples_read_only=False )}
124            %endfor
125        %else:
126            <label>There are no samples.</label>
127        %endif  
128        <p/>
129        <div class="form-row">
130            ## hidden element to make twill work.
131            ## Greg will fix this
132            <input type="hidden" name="twill" value=""/>
133            <input type="submit" name="save_samples_button" value="Save"/>
134            <input type="submit" name="cancel_changes_button" value="Cancel"/>
135            <div class="toolParamHelp" style="clear: both;">
136            Click the <b>Save</b> button when you have finished editing the samples
137        </div>
138        %if request.samples and request.is_submitted:
139            <script type="text/javascript">
140                // Updater
141                sample_state_updater( {${ ",".join( [ '"%s" : "%s"' % ( s.id, s.state.name ) for s in request.samples ] ) }});
142            </script>
143        %endif
144    </form>
145</div>