/templates/workflow/editor_tool_form.mako

https://bitbucket.org/ialbert/galaxy-genetrack · Mako · 110 lines · 105 code · 3 blank · 2 comment · 2 complexity · 83915a300efada282d9cb0490164481f MD5 · raw file

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