{% import "partials/fields.html" as f %} {% import "partials/icons.html" as ic %} {# One condition, rendered recursively. A composition draws as an operator pill above a bracketed list of children; a leaf draws as `subject -> target | metric | rule value`, which is the reading that makes a trigger legible on the canvas at a glance. #} {% macro render(node, draft, selected, document) %} {%- set spec = get_condition_spec(node.type) -%} {% if spec and spec.kind in ('composite', 'wrapper') %}
{{ spec.title }} {% if spec.visual.value %} {{ node.params.get(spec.visual.value) }}{{ ' ' ~ spec.visual.unit if spec.visual.unit }} {% endif %} {{ delete_button(draft, node) }}
{% for child in node.children %} {{ render(child, draft, selected, document) }} {% endfor %} {% if spec.max_children is none or node.children|length < spec.max_children %} {{ add(draft, 'node:' ~ node.id) }} {% endif %}
{% else %} {# `data-caused-by` is what lets the canvas draw the causal link, and it is the document's own reference: the action this condition waits on. #}
{{ f.condition_summary(node, document) }} {{ delete_button(draft, node) }}
{% endif %} {% endmacro %} {% macro delete_button(draft, node) %} {% endmacro %} {# The type picker stays folded away until asked for: an always-open select in every lane and every composition reads as content, and there are a lot of them. `
` gets that for free, with no JavaScript and no popover. #} {% macro add(draft, slot) %}
{{ ic.icon('plus', 11) }} condition
{% endmacro %}