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

<xf:pageaction>
	<xf:button href="{{ link('admin-navigation/add') }}" icon="add">{{ phrase('add_navigation') }}</xf:button>
</xf:pageaction>

<div class="block">
	<div class="block-outer">
		<xf:macro template="filter_macros" name="quick_filter" arg-key="admin-navigation" arg-class="block-outer-opposite" />
	</div>
	<div class="block-container">
		<div class="block-body">
			<xf:datalist>
				<xf:macro name="navigation_list" arg-children="{$tree}" />
			</xf:datalist>
		</div>
		<div class="block-footer">
			<span class="block-footer-counter">{{ display_totals($tree.getFlattened(0)) }}</span>
		</div>
	</div>
</div>

<xf:macro name="navigation_list" arg-children="!" arg-depth="1">
	<xf:foreach loop="$children" value="$child">
		<xf:macro name="navigation_list_entry" arg-navigation="{$child.record}" arg-children="{$child.children}" arg-depth="{$depth}" />
	</xf:foreach>
</xf:macro>

<xf:macro name="navigation_list_entry" arg-navigation="!" arg-children="!" arg-depth="1">
	<xf:if is="$depth == 1">
		<xf:datarow rowtype="subsection">
			<xf:cell href="{{ link('admin-navigation/edit', $navigation) }}" hash="{$navigation.navigation_id}">
				<div class="dataList-textRow">
					<xf:if is="{$navigation.icon}"><xf:fa icon="{$navigation.icon} fa-fw" /></xf:if>
					{$navigation.title}
					<xf:if is="{$navigation.link}"><span class="dataList-hint" dir="auto">{$navigation.link}</span></xf:if>
				</div>
			</xf:cell>
			<xf:cell class="dataList-cell--min dataList-cell--hint">{$navigation.display_order}</xf:cell>
			<xf:delete href="{{ link('admin-navigation/delete', $navigation) }}" />
		</xf:datarow>
	<xf:else />
		<xf:datarow>
			<xf:cell href="{{ link('admin-navigation/edit', $navigation) }}"
				class="dataList-cell--d{{ $depth - 1 }}"
				hash="{$navigation.navigation_id}">

				<div class="dataList-textRow">
					<xf:if is="$navigation.icon"><xf:fa icon="{$navigation.icon}" /></xf:if>
					{$navigation.title}
					<xf:if is="{$navigation.link}"><span class="dataList-hint" dir="auto">{$navigation.link}</span></xf:if>
				</div>
			</xf:cell>
			<xf:cell class="dataList-cell--min dataList-cell--hint">{$navigation.navigation_id} / {$navigation.display_order}</xf:cell>
			<xf:delete href="{{ link('admin-navigation/delete', $navigation) }}" />
		</xf:datarow>
	</xf:if>
	<xf:macro name="navigation_list" arg-children="{$children}" arg-depth="{{ $depth + 1 }}" />
</xf:macro>