{% extends 'base.html' %}
+{% macro process_with_steps(step_id, step_node, indent) %}
+<tr>
+<td>
+<input type="hidden" name="steps" value="{{step_id}}" />
+{% if step_node.is_explicit %}
+<input type="checkbox" name="keep_step" value="{{step_id}}" checked />
+<input type="hidden" name="step_{{step_id}}_process_id" value="{{step_node.process.id_}}" />
+<input type="hidden" name="step_{{step_id}}_parent_id" value="{{step_node.parent_id or ''}}" />
+{% endif %}
+</td>
+<td>{% for i in range(indent) %}+{%endfor %}
+<a href="process?id={{step_node.process.id_}}">{{step_node.process.title.newest|e}}</a>
+</td>
+<td>
+{% if step_node.is_explicit %}
+add step: <input name="new_step_to_{{step_id}}" list="candidates" autocomplete="off" />
+{% endif %}
+</td>
+</tr>
+{% for substep_id, substep in step_node.steps.items() %}
+{{ process_with_steps(substep_id, substep, indent+1) }}
+{% endfor %}
+{% endmacro %}
+
{% block content %}
<h3>Process</h3>
<form action="process?id={{process.id_ or ''}}" method="POST">
description: <input name="description" value="{{process.description.newest|e}}" />
default effort: <input name="effort" type="number" step=0.1 value={{process.effort.newest}} />
<table>
-{% for child in children %}
-<tr>
-<td>
-<input type="checkbox" name="children" value="{{child.id_}}" checked />
-</td>
-<td>
-<a href="process?id={{child.id_}}">{{child.title.newest|e}}</a>
-</td>
-</tr>
+{% for step_id, step_node in steps.items() %}
+{{ process_with_steps(step_id, step_node, 0) }}
{% endfor %}
</table>
-add child: <input name="children" list="candidates" autocomplete="off" />
+add step: <input name="new_top_step" list="candidates" autocomplete="off" />
<datalist id="candidates">
{% for candidate in candidates %}
<option value="{{candidate.id_}}">{{candidate.title.newest|e}}</option>