-
Notifications
You must be signed in to change notification settings - Fork 966
/
display.mako
132 lines (126 loc) · 5.49 KB
/
display.mako
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<%inherit file="/display_base.mako"/>
<%namespace file="/display_common.mako" import="render_message" />
<%!
from galaxy.tools.parameters.basic import DataCollectionToolParameter, DataToolParameter, RuntimeValue
from galaxy.web import form_builder
import cgi
%>
<%def name="stylesheets()">
${parent.stylesheets()}
</%def>
<%def name="do_inputs( inputs, values, prefix, step, other_values=None )">
%for input_index, input in enumerate( inputs.itervalues() ):
%if input.type == "repeat":
<div class="repeat-group">
<div class="form-title-row"><b>${input.title_plural}</b></div>
<% repeat_values = values[input.name] %>
%for i in range( len( repeat_values ) ):
<div class="repeat-group-item">
<% index = repeat_values[i]['__index__'] %>
<div class="form-title-row"><b>${input.title} ${i + 1}</b></div>
${do_inputs( input.inputs, repeat_values[ i ], prefix + input.name + "_" + str(index) + "|", step, other_values )}
</div>
%endfor
</div>
%elif input.type == "conditional":
<% group_values = values[input.name] %>
<% current_case = group_values['__current_case__'] %>
<% new_prefix = prefix + input.name + "|" %>
${row_for_param( input.test_param, group_values[ input.test_param.name ], other_values, prefix, step )}
${do_inputs( input.cases[ current_case ].inputs, group_values, new_prefix, step, other_values )}
%elif input.type == "section":
<% new_prefix = prefix + input.name + "|" %>
<% group_values = values[input.name] %>
<div class="form-title-row"><b>${input.title}:</b></div>
<div class="repeat-group">
<div class="repeat-group-item">
${do_inputs( input.inputs, group_values, new_prefix, step, other_values )}
</div>
</div>
%else:
${row_for_param( input, values[ input.name ], other_values, prefix, step )}
%endif
%endfor
</%def>
<%def name="row_for_param( param, value, other_values, prefix, step )">
<% cls = "form-row" %>
<div class="${cls}">
<label>${param.get_label() | h}</label>
<div>
%if isinstance( param, DataToolParameter ) or isinstance( param, DataCollectionToolParameter ):
%if ( prefix + param.name ) in step.input_connections_by_name:
<%
conns = step.input_connections_by_name[ prefix + param.name ]
if not isinstance(conns, list):
conns = [conns]
vals = ["Output dataset '%s' from step %d" % (conn.output_name, int(conn.output_step.order_index)+1) for conn in conns]
%>
${",".join(vals)}
%else:
<i>select at runtime</i>
%endif
%else:
${cgi.escape( param.value_to_display_text( value, app ) )}
%endif
</div>
%if hasattr( step, 'upgrade_messages' ) and step.upgrade_messages and param.name in step.upgrade_messages:
${render_message( step.upgrade_messages[param.name], "info" )}
%endif
</div>
</%def>
<%def name="render_item_links( workflow )">
%if workflow.importable:
<a
href="${h.url_for( controller='/workflow', action='imp', id=trans.security.encode_id(workflow.id) )}"
class="icon-button import"
title="Import workflow"></a>
<a
href="${h.url_for( controller='/workflow', action='export_to_file', id=trans.security.encode_id(workflow.id) )}"
class="icon-button disk"
title="Save workflow"></a>
%endif
</%def>
<%def name="render_item( workflow, steps )">
<%
# HACK: Rendering workflow steps requires that trans have a history; however, if its user's first visit to Galaxy is here, he won't have a history
# and an error will occur. To prevent this error, make sure user has a history.
trans.get_history( create=True )
%>
<table class="annotated-item">
<tr><th>Step</th><th class="annotation">Annotation</th></tr>
%for i, step in enumerate( steps ):
<tr><td>
%if step.type == 'tool' or step.type is None:
<%
tool = trans.app.toolbox.get_tool( step.tool_id )
%>
<div class="toolForm">
%if tool:
<div class="toolFormTitle">Step ${int(step.order_index)+1}: ${tool.name | h}</div>
<div class="toolFormBody">
${do_inputs( tool.inputs, step.state.inputs, "", step )}
</div>
%else:
<div class="toolFormTitle">Step ${int(step.order_index)+1}: Unknown Tool with id '${step.tool_id | h}'</div>
%endif
</div>
%else:
## TODO: always input dataset?
<% module = step.module %>
<div class="toolForm">
<div class="toolFormTitle">Step ${int(step.order_index)+1}: ${module.name | h}</div>
<div class="toolFormBody">
${do_inputs( module.get_runtime_inputs(), step.state.inputs, "", step )}
</div>
</div>
%endif
</td>
<td class="annotation">
%if hasattr( step, "annotation") and step.annotation is not None:
${step.annotation}
%endif
</td>
</tr>
%endfor
</table>
</%def>