/templates/workflow/editor_tool_form.mako
Mako | 110 lines | 105 code | 3 blank | 2 comment | 2 complexity | 83915a300efada282d9cb0490164481f MD5 | raw file
1<%
2from galaxy.tools.parameters import DataToolParameter, RuntimeValue
3from galaxy.util.expressions import ExpressionContext
4%>
5
6<%def name="do_inputs( inputs, values, errors, prefix, ctx=None )">
7 <% ctx = ExpressionContext( values, ctx ) %>
8 %for input_index, input in enumerate( inputs.itervalues() ):
9 %if input.type == "repeat":
10 <div class="repeat-group">
11 <div class="form-title-row"><b>${input.title_plural}</b></div>
12 <% repeat_values = values[input.name] %>
13 %for i in range( len( repeat_values ) ):
14 <%
15 if input.name in errors:
16 rep_errors = errors[input.name][i]
17 else:
18 rep_errors = dict()
19 index = repeat_values[i]['__index__']
20 %>
21 <div class="repeat-group-item">
22 <div class="form-title-row"><b>${input.title} ${i + 1}</b></div>
23 ${do_inputs( input.inputs, repeat_values[ i ], rep_errors, prefix + input.name + "_" + str(index) + "|", ctx )}
24 <div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div>
25 </div>
26 %endfor
27 <div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div>
28 </div>
29 %elif input.type == "conditional":
30 <% group_values = values[input.name] %>
31 <% current_case = group_values['__current_case__'] %>
32 <% group_prefix = prefix + input.name + "|" %>
33 <% group_errors = errors.get( input.name, {} ) %>
34 ${row_for_param( input.test_param, group_values[ input.test_param.name ], group_errors, group_prefix, ctx, allow_runtime=False )}
35 ${do_inputs( input.cases[ current_case ].inputs, group_values, group_errors, group_prefix, ctx )}
36 %else:
37 %if input.name in values:
38 ${row_for_param( input, values[ input.name ], errors, prefix, ctx )}
39 %else:
40 <% errors[ input.name ] = 'Value not stored, displaying default' %>
41 ${row_for_param( input, input.get_initial_value( trans, values ), errors, prefix, ctx )}
42 %endif
43 %endif
44 %endfor
45</%def>
46
47<%def name="row_for_param( param, value, error_dict, prefix, ctx, allow_runtime=True )">
48 %if error_dict.has_key( param.name ):
49 <% cls = "form-row form-row-error" %>
50 %else:
51 <% cls = "form-row" %>
52 %endif
53 <div class="${cls}" id="row-${prefix}${param.name}">
54 ## Data parameters are very special since their value / runtime state
55 ## comes from connectors
56 %if type( param ) is DataToolParameter:
57 <label>
58 ${param.get_label()}
59 </label>
60 <div>
61 Data input '${param.name}' (${" or ".join( param.extensions )})
62 </div>
63 %else:
64 %if isinstance( value, RuntimeValue ):
65 <label>
66 ${param.get_label()}
67 <span class="popupmenu">
68 <button type="submit" name="make_buildtime" value="${prefix}${param.name}">Set in advance</button>
69 </span>
70 </label>
71 <div>
72 <i>To be set at runtime</i>
73 </div>
74 %else:
75 <label>
76 ${param.get_label()}
77 %if allow_runtime:
78 <span class="popupmenu">
79 <button type="submit" name="make_runtime" value="${prefix}${param.name}">Set at runtime</button>
80 </span>
81 %endif
82 </label>
83 <div>
84 ${param.get_html_field( trans, value, ctx ).get_html( prefix )}
85 </div>
86 %endif
87 %if error_dict.has_key( param.name ):
88 <div style="color: red; font-weight: bold; padding-top: 1px; padding-bottom: 3px;">
89 <div style="width: 300px;"><img style="vertical-align: middle;" src="${h.url_for('/static/style/error_small.png')}"> <span style="vertical-align: middle;">${error_dict[param.name]}</span></div>
90 </div>
91 %endif
92 %endif
93 <div style="clear: both"></div>
94 </div>
95</%def>
96
97<div class="toolForm">
98 <div class="toolFormTitle">Tool: ${tool.name}</div>
99 <div class="toolFormBody">
100 <form method="post" action="${h.url_for( action='editor_form_post' )}">
101 <input type="hidden" name="tool_id" value="${tool.id}" />
102 %for i, inputs in enumerate( tool.inputs_by_page ):
103 %if tool.has_multiple_pages:
104 <div class='titleRow'>Page ${i+1}</div>
105 %endif
106 ${do_inputs( inputs, values, errors, "" )}
107 %endfor
108 </form>
109 </div>
110</div>