<xf:title>{{ phrase('sort_nodes') }}</xf:title>

<xf:macro id="public:nestable_macros::setup" />

<xf:form action="{{ link('nodes/sort') }}" class="block" ajax="true">
	<div class="block-container">
		<div class="block-body">
			<div class="nestable-container" data-xf-init="nestable">
				<xf:macro id="node_list" arg-children="{$nodeTree}" />
				<xf:hiddenval name="nodes" value="" />
			</div>
		</div>
		<xf:submitrow icon="save" rowtype="simple" />
	</div>
</xf:form>

<xf:macro id="node_list" arg-children="!">
	<ol class="nestable-list">
		<xf:foreach loop="$children" key="$id" value="$child">
			<xf:macro id="node_list_entry" arg-node="{$child}" arg-children="{$child.children}" />
		</xf:foreach>
	</ol>
</xf:macro>

<xf:macro id="node_list_entry" arg-node="!" arg-children="!">
	<li class="nestable-item" data-id="{$node.id}">
		<div class="nestable-handle" aria-label="{{ phrase('drag_handle')|for_attr }}"><xf:macro id="node_list::node_icon" arg-node="{$node.record}" /></div>
		<div class="nestable-content">
			<strong>{$node.record.title}</strong>
			<span class="nestable-label nestable-label--smallest" dir="auto">
				{$node.record.NodeType.title}
				<xf:if is="
					$node.record.node_type_id == 'Forum'
					AND $node.record.Data.TypeHandler
					AND $node.record.Data.forum_type_id != 'discussion'
				">
					({{ $node.record.Data.TypeHandler.getTypeTitle() }})
				</xf:if>
			</span>
		</div>
		<xf:if is="$node.children is not empty">
			<xf:macro id="node_list" arg-children="{$node.children}" />
		</xf:if>
	</li>
</xf:macro>