PageRenderTime 66ms CodeModel.GetById 39ms app.highlight 13ms RepoModel.GetById 10ms app.codeStats 0ms

/templates/tool_form.mako

https://bitbucket.org/ialbert/galaxy-genetrack
Mako | 281 lines | 254 code | 23 blank | 4 comment | 2 complexity | c89a34529d3b651744c903f1bd318950 MD5 | raw file
  1<!-- -->
  2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3
  4<%
  5from galaxy.util.expressions import ExpressionContext 
  6%>
  7
  8<html>
  9
 10<head>
 11<title>Galaxy</title>
 12<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 13<link href="${h.url_for('/static/style/base.css')}" rel="stylesheet" type="text/css" />
 14<script type='text/javascript' src="${h.url_for('/static/scripts/jquery.js')}"> </script>
 15<script type="text/javascript">
 16$( function() {
 17    $( "select[refresh_on_change='true']").change( function() {
 18        var refresh = false;
 19        var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' )
 20        if ( refresh_on_change_values ) {
 21            refresh_on_change_values = refresh_on_change_values.value.split( ',' );
 22            var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' );
 23            for( i= 0; i < refresh_on_change_values.length; i++ ) {
 24                if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){
 25                    refresh = true;
 26                    break;
 27                }
 28            }
 29        }
 30        else {
 31            refresh = true;
 32        }
 33        if ( refresh ){
 34            $( ':file' ).each( function() {
 35                var file_value = $( this )[0].value;
 36                if ( file_value ) {
 37                    //disable file input, since we don't want to upload the file on refresh
 38                    var file_name = $( this )[0].name;
 39                    $( this )[0].name = 'replaced_file_input_' + file_name
 40                    $( this )[0].disable = true;
 41                    //create a new hidden field which stores the filename and has the original name of the file input
 42                    var new_file_input = document.createElement( 'input' );
 43                    new_file_input.type = 'hidden';
 44                    new_file_input.value = file_value;
 45                    new_file_input.name = file_name;
 46                    document.getElementById( 'tool_form' ).appendChild( new_file_input );
 47                }
 48            } );
 49            $( "#tool_form" ).submit();
 50        }
 51    });
 52});
 53%if not add_frame.debug:
 54    if( window.name != "galaxy_main" ) {
 55        location.replace( '${h.url_for( controller='root', action='index', tool_id=tool.id )}' );
 56    }
 57%endif
 58function checkUncheckAll( name, check )
 59{
 60    if ( check == 0 )
 61    {
 62        $("input[name=" + name + "][type='checkbox']").attr('checked', false);
 63    }
 64    else
 65    {
 66        $("input[name=" + name + "][type='checkbox']").attr('checked', true );
 67    }
 68}
 69
 70</script>
 71</head>
 72
 73<body>
 74
 75<%def name="do_inputs( inputs, tool_state, errors, prefix, other_values=None )">
 76  <% other_values = ExpressionContext( tool_state, other_values ) %>
 77    %for input_index, input in enumerate( inputs.itervalues() ):
 78        %if input.type == "repeat":
 79          <div class="repeat-group">
 80              <div class="form-title-row"><b>${input.title_plural}</b></div>
 81              <% repeat_state = tool_state[input.name] %>
 82              %for i in range( len( repeat_state ) ):
 83                <div class="repeat-group-item">
 84                <%
 85                if input.name in errors:
 86                    rep_errors = errors[input.name][i]
 87                else:
 88                    rep_errors = dict()
 89                index = repeat_state[i]['__index__']
 90                %>
 91                <div class="form-title-row"><b>${input.title} ${i + 1}</b></div>
 92                ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )}
 93                <div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div>
 94                </div>
 95              %endfor
 96              <div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div>
 97          </div>
 98        %elif input.type == "conditional":
 99            <%
100            group_state = tool_state[input.name]
101            group_errors = errors.get( input.name, {} )
102            current_case = group_state['__current_case__']
103            group_prefix = prefix + input.name + "|"
104            %>
105            %if input.value_ref_in_group:
106                ${row_for_param( group_prefix, input.test_param, group_state, group_errors, other_values )}
107            %endif
108            ${do_inputs( input.cases[current_case].inputs, group_state, group_errors, group_prefix, other_values )}
109        %elif input.type == "upload_dataset":
110            %if input.get_datatype( trans, other_values ).composite_type is None: #have non-composite upload appear as before
111                <%
112                if input.name in errors:
113                    rep_errors = errors[input.name][0]
114                else:
115                    rep_errors = dict()
116                %>
117              ${do_inputs( input.inputs, tool_state[input.name][0], rep_errors, prefix + input.name + "_" + str( 0 ) + "|", other_values )}
118            %else:
119                <div class="repeat-group">
120                    <div class="form-title-row"><b>${input.group_title( other_values )}</b></div>
121                    <% 
122                    repeat_state = tool_state[input.name] 
123                    %>
124                    %for i in range( len( repeat_state ) ):
125                      <div class="repeat-group-item">
126                      <%
127                      if input.name in errors:
128                          rep_errors = errors[input.name][i]
129                      else:
130                          rep_errors = dict()
131                      index = repeat_state[i]['__index__']
132                      %>
133                      <div class="form-title-row"><b>File Contents for ${input.title_by_index( trans, i, other_values )}</b></div>
134                      ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )}
135                      ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div>
136                      </div>
137                    %endfor
138                    ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div>
139                </div>
140            %endif
141        %else:
142            ${row_for_param( prefix, input, tool_state, errors, other_values )}
143        %endif
144    %endfor  
145</%def>
146
147<%def name="row_for_param( prefix, param, parent_state, parent_errors, other_values )">
148    <%
149    if parent_errors.has_key( param.name ):
150        cls = "form-row form-row-error"
151    else:
152        cls = "form-row"
153    %>
154    <div class="${cls}">
155        <% label = param.get_label() %>
156        %if label:
157            <label>
158                ${label}:
159            </label>
160        %endif
161        <%
162        field = param.get_html_field( trans, parent_state[ param.name ], other_values )
163        field.refresh_on_change = param.refresh_on_change
164        %>
165        <div class="form-row-input">${field.get_html( prefix )}</div>
166        %if parent_errors.has_key( param.name ):
167        <div class="form-row-error-message">
168            <div><img style="vertical-align: middle;" src="${h.url_for('/static/style/error_small.png')}">&nbsp;<span style="vertical-align: middle;">${parent_errors[param.name]}</span></div>
169        </div>
170        %endif
171        
172        %if param.help:
173        <div class="toolParamHelp" style="clear: both;">
174            ${param.help}
175        </div>
176        %endif
177
178        <div style="clear: both"></div>
179                
180    </div>
181</%def>
182
183%if add_frame.from_noframe:
184    <div class="warningmessage">
185    <strong>Welcome to Galaxy</strong>
186    <hr/>
187    It appears that you found this tool from a link outside of Galaxy.
188    If you're not familiar with Galaxy, please consider visiting the
189    <a href="${h.url_for( controller='root' )}" target="_top">welcome page</a>.
190    To learn more about what Galaxy is and what it can do for you, please visit
191    the <a href="$add_frame.wiki_url" target="_top">Galaxy wiki</a>.
192    </div>
193    <br/>
194%endif
195
196<div class="toolForm" id="${tool.id}">
197  %if tool.has_multiple_pages:
198  <div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div>
199  %else:
200  <div class="toolFormTitle">${tool.name}</div>
201  %endif
202  <div class="toolFormBody">
203  <form id="tool_form" name="tool_form" action="${h.url_for( tool.action )}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}">
204    <input type="hidden" name="tool_id" value="${tool.id}">
205    <input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}">
206    
207    %if tool.display_by_page[tool_state.page]:
208        ${trans.fill_template_string( tool.display_by_page[tool_state.page], context=tool.get_param_html_map( trans, tool_state.page, tool_state.inputs ) )}
209        <input type="submit" class="primary-button" name="runtool_btn" value="Execute">
210        
211    %else:
212        
213          <div style="display: none;">
214            %if tool_state.page == tool.last_page:
215            <input type="submit" class="primary-button" name="runtool_btn" value="Execute">
216            %else:
217            <input type="submit" class="primary-button" name="runtool_btn" value="Next step">
218            %endif
219          </div>
220          ${do_inputs( tool.inputs_by_page[ tool_state.page ], tool_state.inputs, errors, "" )}
221          <div class="form-row">
222            %if tool_state.page == tool.last_page:
223            <input type="submit" class="primary-button" name="runtool_btn" value="Execute">
224            %else:
225            <input type="submit" class="primary-button" name="runtool_btn" value="Next step">
226            %endif
227          </div>    
228        
229    %endif    
230
231  </form>
232  </div>
233</div>
234
235%if tool.help:
236<div class="toolHelp">
237     <div class="toolHelpBody">
238     %if tool.has_multiple_pages:
239        ${tool.help_by_page[tool_state.page]}
240     %else:
241     ${tool.help}
242     %endif
243     </div>        
244</div>
245%endif
246
247</body>
248
249<script type="text/javascript">
250##For Drilldown Parameters adds expand/collapse buttons and collapses collapsed elements
251   $( function() {
252       $( 'li > ul' ).each( function( i ) {
253           if ( $( this )[0].className == 'toolParameterExpandableCollapsable' )
254           {
255               var parent_li = $( this ).parent( 'li' );
256               var sub_ul = $( this ).remove();
257               parent_li.find( 'span' ).wrapInner( '<a/>' ).find( 'a' ).click( function() {
258                 sub_ul.toggle();
259                 $( this )[0].innerHTML = ( sub_ul[0].style.display=='none' ) ? '[+]' : '[-]';
260               });
261               parent_li.append( sub_ul );
262           }
263       });
264       $( 'ul ul' ).each( function(i) {
265           if ( $( this )[0].className == 'toolParameterExpandableCollapsable' && this.attributes.getNamedItem( 'default_state' ).value == 'collapsed' )
266           {
267               $( this ).hide();
268           }
269       });
270   });
271
272##inserts the Select All / Unselect All buttons for checkboxes
273$( function() {
274    $("div.checkUncheckAllPlaceholder").each( function( i ) {
275        $( this )[0].innerHTML = '<a class="action-button" onclick="checkUncheckAll( \'' + this.attributes.getNamedItem( 'checkbox_name' ).value + '\', 1 );"><span>Select All</span></a> <a class="action-button" onclick="checkUncheckAll( \'' + this.attributes.getNamedItem( 'checkbox_name' ).value + '\', 0 );"><span>Unselect All</span></a>';
276    });
277});
278
279</script>
280
281</html>