{% from "components/table_row.html" import row_action %} {% from "components/icons.html" import square_pen_icon, table_properties_icon, node_add_child_icon, corner_down_right_icon, trash_2_icon %} {% macro node_action(href, label, accessible_name, icon, danger=false) -%} {{ icon() }} {%- endmacro %} {% macro node_actions(row) -%}
{% if may_edit %} {{ node_action(url_for("dataset_hierarchy_node_edit", key=dataset.key, node_id=row.node.id, view=selected_view, q=hierarchy_search or none, sort=sort_key or none, direction=sort_direction if sort_key else none), "Edit node", "Edit node " ~ row.node.name, square_pen_icon) }} {{ node_action(url_for("dataset_hierarchy_node_create", key=dataset.key, parent_id=row.node.id), "Add child", "Add child to " ~ row.node.name, node_add_child_icon) }} {% if row.node.parent_id is not none %}{{ node_action(url_for("dataset_hierarchy_node_delete", key=dataset.key, node_id=row.node.id), "Delete branch", "Delete branch " ~ row.node.name, trash_2_icon, true) }}{% endif %} {% endif %}
{%- endmacro %} {% macro node_name(row, indented=false) -%} {% if indented %}{% if row.depth > 1 %}{% for level in range(row.depth - 1) %}{% endfor %}{% endif %}{% if row.depth %}{{ corner_down_right_icon() }}{% endif %}{% endif %}{{ row.node.name }} {% if indented %}Full path: {{ row.path }}{% endif %} {%- endmacro %} {% macro record_name(row, action_only=false, indented=false) -%} {% if may_edit %} {% if action_only %}{{ square_pen_icon() }} {% else %}{% call row_action(href=url_for("dataset_hierarchy_node_edit", key=dataset.key, node_id=row.node.id, view=selected_view, q=hierarchy_search or none, sort=sort_key or none, direction=sort_direction if sort_key else none), panel="hierarchy-panel", panel_url=true, accessible_name="Edit node " ~ row.path) %}{{ node_name(row, indented=indented) }}{% endcall %}{% endif %} {% else %} {% if not action_only %}{% call row_action(panel="hierarchy-node-" ~ row.node.id, accessible_name="View node " ~ row.path) %}{{ node_name(row, indented=indented) }}{% endcall %}{% endif %} {% endif %} {%- endmacro %} {% macro node_value(row, field) -%} {% if row is none %}No node at this level {% elif not row.leaf and field.hierarchy_scope != 'all_nodes' %}— {% elif row['values'].get(field.key) is none %}Empty {% else %}{{ row['values'].get(field.key)|record_value_text(field.data_type) }}{% endif %} {%- endmacro %}