root/galaxy-central/templates/tool_form.mako @ 3

リビジョン 2, 12.1 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
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${h.css( "base", "autocomplete_tagging" )}
14${h.js( "jquery", "galaxy.base", "jquery.autocomplete" )}
15<script type="text/javascript">
16$(function() {
17    $(window).bind("refresh_on_change", function() {
18        $(':file').each( function() {
19            var file = $(this);
20            var file_value = file.val();
21            if (file_value) {
22                // disable file input, since we don't want to upload the file on refresh
23                var file_name = $(this).attr("name");
24                file.attr( { name: 'replaced_file_input_' + file_name, disabled: true } );
25                // create a new hidden field which stores the filename and has the original name of the file input
26                var new_file_input = $(document.createElement('input'));
27                new_file_input.attr( { "type", "hidden", "value": file_value, "name": file_name } );
28                file.after(new_file_input);
29            }
30        });
31    });
32});
33
34%if not add_frame.debug:
35    if( window.name != "galaxy_main" ) {
36        location.replace( '${h.url_for( controller='root', action='index', tool_id=tool.id )}' );
37    }
38%endif
39function checkUncheckAll( name, check )
40{
41    if ( check == 0 )
42    {
43        $("input[name=" + name + "][type='checkbox']").attr('checked', false);
44    }
45    else
46    {
47        $("input[name=" + name + "][type='checkbox']").attr('checked', true );
48    }
49}
50
51</script>
52</head>
53
54<body>
55    <%def name="do_inputs( inputs, tool_state, errors, prefix, other_values=None )">
56      <% other_values = ExpressionContext( tool_state, other_values ) %>
57        %for input_index, input in enumerate( inputs.itervalues() ):
58            %if input.type == "repeat":
59              <div class="repeat-group">
60                  <div class="form-title-row"><b>${input.title_plural}</b></div>
61                  <% repeat_state = tool_state[input.name] %>
62                  %for i in range( len( repeat_state ) ):
63                    <div class="repeat-group-item">
64                    <%
65                    if input.name in errors:
66                        rep_errors = errors[input.name][i]
67                    else:
68                        rep_errors = dict()
69                    index = repeat_state[i]['__index__']
70                    %>
71                    <div class="form-title-row"><b>${input.title} ${i + 1}</b></div>
72                    ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )}
73                    <div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div>
74                    </div>
75                    %if rep_errors.has_key( '__index__' ):
76                        <div><img style="vertical-align: middle;" src="${h.url_for('/static/style/error_small.png')}">&nbsp;<span style="vertical-align: middle;">${rep_errors['__index__']}</span></div>
77                    %endif
78                  %endfor
79                  <div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div>
80              </div>
81            %elif input.type == "conditional":
82                <%
83                group_state = tool_state[input.name]
84                group_errors = errors.get( input.name, {} )
85                current_case = group_state['__current_case__']
86                group_prefix = prefix + input.name + "|"
87                %>
88                %if input.value_ref_in_group:
89                    ${row_for_param( group_prefix, input.test_param, group_state, group_errors, other_values )}
90                %endif
91                ${do_inputs( input.cases[current_case].inputs, group_state, group_errors, group_prefix, other_values )}
92            %elif input.type == "upload_dataset":
93                %if input.get_datatype( trans, other_values ).composite_type is None: #have non-composite upload appear as before
94                    <%
95                    if input.name in errors:
96                        rep_errors = errors[input.name][0]
97                    else:
98                        rep_errors = dict()
99                    %>
100                  ${do_inputs( input.inputs, tool_state[input.name][0], rep_errors, prefix + input.name + "_" + str( 0 ) + "|", other_values )}
101                %else:
102                    <div class="repeat-group">
103                        <div class="form-title-row"><b>${input.group_title( other_values )}</b></div>
104                        <%
105                        repeat_state = tool_state[input.name]
106                        %>
107                        %for i in range( len( repeat_state ) ):
108                          <div class="repeat-group-item">
109                          <%
110                          if input.name in errors:
111                              rep_errors = errors[input.name][i]
112                          else:
113                              rep_errors = dict()
114                          index = repeat_state[i]['__index__']
115                          %>
116                          <div class="form-title-row"><b>File Contents for ${input.title_by_index( trans, i, other_values )}</b></div>
117                          ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )}
118                          ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div>
119                          </div>
120                        %endfor
121                        ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div>
122                    </div>
123                %endif
124            %else:
125                ${row_for_param( prefix, input, tool_state, errors, other_values )}
126            %endif
127        %endfor 
128    </%def>
129   
130    <%def name="row_for_param( prefix, param, parent_state, parent_errors, other_values )">
131        <%
132        if parent_errors.has_key( param.name ):
133            cls = "form-row form-row-error"
134        else:
135            cls = "form-row"
136        %>
137        <div class="${cls}">
138            <% label = param.get_label() %>
139            %if label:
140                <label>
141                    ${label}:
142                </label>
143            %endif
144            <%
145                field = param.get_html_field( trans, parent_state[ param.name ], other_values )
146                field.refresh_on_change = param.refresh_on_change
147               
148                # Field may contain characters submitted by user and these characters may be unicode; handle non-ascii characters gracefully.
149                field_html = field.get_html( prefix )
150                if type( field_html ) is not unicode:
151                    field_html = unicode( field_html, 'utf-8' )
152            %>
153            <div class="form-row-input">${field_html}</div>
154            %if parent_errors.has_key( param.name ):
155            <div class="form-row-error-message">
156                <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>
157            </div>
158            %endif
159           
160            %if param.help:
161            <div class="toolParamHelp" style="clear: both;">
162                ${param.help}
163            </div>
164            %endif
165   
166            <div style="clear: both"></div>
167                   
168        </div>
169    </%def>
170   
171    %if add_frame.from_noframe:
172        <div class="warningmessage">
173        <strong>Welcome to Galaxy</strong>
174        <hr/>
175        It appears that you found this tool from a link outside of Galaxy.
176        If you're not familiar with Galaxy, please consider visiting the
177        <a href="${h.url_for( controller='root' )}" target="_top">welcome page</a>.
178        To learn more about what Galaxy is and what it can do for you, please visit
179        the <a href="$add_frame.wiki_url" target="_top">Galaxy wiki</a>.
180        </div>
181        <br/>
182    %endif
183   
184    ## handle calculating the redict url for the special case where we have nginx proxy
185    ## upload and need to do url_for on the redirect portion of the tool action
186    <%
187        try:   
188            tool_url = h.url_for(tool.action)
189        except AttributeError:
190            assert len(tool.action) == 2
191            tool_url = tool.action[0] + h.url_for(tool.action[1])
192    %><div class="toolForm" id="${tool.id}">
193        %if tool.has_multiple_pages:
194            <div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div>
195        %else:
196            <div class="toolFormTitle">${tool.name}</div>
197        %endif
198        <div class="toolFormBody">
199            <form id="tool_form" name="tool_form" action="${tool_url}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}">
200                <input type="hidden" name="tool_id" value="${tool.id}">
201                <input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}">
202                %if tool.display_by_page[tool_state.page]:
203                    ${trans.fill_template_string( tool.display_by_page[tool_state.page], context=tool.get_param_html_map( trans, tool_state.page, tool_state.inputs ) )}
204                    <input type="submit" class="primary-button" name="runtool_btn" value="Execute">
205                %else:
206                    ${do_inputs( tool.inputs_by_page[ tool_state.page ], tool_state.inputs, errors, "" )}
207                    <div class="form-row">
208                        %if tool_state.page == tool.last_page:
209                            <input type="submit" class="primary-button" name="runtool_btn" value="Execute">
210                        %else:
211                            <input type="submit" class="primary-button" name="runtool_btn" value="Next step">
212                        %endif
213                    </div>
214                %endif   
215            </form>
216        </div>
217    </div>
218    %if tool.help:
219        <div class="toolHelp">
220            <div class="toolHelpBody">
221                <%
222                    if tool.has_multiple_pages:
223                        tool_help = tool.help_by_page[tool_state.page]
224                    else:
225                        tool_help = tool.help
226                   
227                    # Convert to unicode to display non-ascii characters.
228                    if type( tool_help ) is not unicode:
229                        tool_help = unicode( tool_help, 'utf-8')
230                %>
231                ${tool_help}
232            </div>       
233        </div>
234    %endif
235</body>
236
237<script type="text/javascript">
238##For Drilldown Parameters adds expand/collapse buttons and collapses collapsed elements
239   $( function() {
240       $( 'li > ul' ).each( function( i ) {
241           if ( $( this )[0].className == 'toolParameterExpandableCollapsable' )
242           {
243               var parent_li = $( this ).parent( 'li' );
244               var sub_ul = $( this ).remove();
245               parent_li.find( 'span' ).wrapInner( '<a/>' ).find( 'a' ).click( function() {
246                 sub_ul.toggle();
247                 $( this )[0].innerHTML = ( sub_ul[0].style.display=='none' ) ? '[+]' : '[-]';
248               });
249               parent_li.append( sub_ul );
250           }
251       });
252       $( 'ul ul' ).each( function(i) {
253           if ( $( this )[0].className == 'toolParameterExpandableCollapsable' && this.attributes.getNamedItem( 'default_state' ).value == 'collapsed' )
254           {
255               $( this ).hide();
256           }
257       });
258   });
259
260##inserts the Select All / Unselect All buttons for checkboxes
261$( function() {
262    $("div.checkUncheckAllPlaceholder").each( function( i ) {
263        $( 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>';
264    });
265});
266
267</script>
268
269</html>
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。