<xf:if is="$navigation.isInsert()">
	<xf:title>{{ phrase('add_navigation') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_navigation:') }} {$navigation.title}</xf:title>
</xf:if>

<xf:pageaction if="$navigation.isUpdate()">
	<xf:button href="{{ link('admin-navigation/delete', $navigation) }}" icon="delete" overlay="true" />
</xf:pageaction>

<xf:form action="{{ link('admin-navigation/save', $navigation) }}" class="block" ajax="true">
	<div class="block-container">
		<div class="block-body">
			<xf:textboxrow name="navigation_id" value="{$navigation.navigation_id}" maxlength="{{ max_length($navigation, 'navigation_id') }}"
				label="{{ phrase('admin_navigation_id') }}"
				dir="ltr" />
			<xf:textboxrow name="title" value="{{ $navigation.exists() ? $navigation.MasterTitle.phrase_text : '' }}"
				label="{{ phrase('title') }}" />
			<xf:textboxrow name="link" value="{$navigation.link}" maxlength="{{ max_length($navigation, 'link') }}"
				label="{{ phrase('link') }}"
				dir="ltr" />
			<xf:textboxrow name="icon" value="{$navigation.icon}" maxlength="{{ max_length($navigation, 'icon') }}"
				label="{{ phrase('font_awesome_icon') }}"
				explain="{{ phrase('admin_navigation_icon_explain') }}"
				dir="ltr" />

			<hr class="formRowSep" />

			<xf:selectrow name="parent_navigation_id" value="{$navigation.parent_navigation_id}"
				label="{{ phrase('parent_navigation_entry') }}">

				<xf:option>&nbsp;</xf:option>
				<xf:foreach loop="$navigationTree.getFlattened()" value="$treeEntry">
					<xf:option value="{$treeEntry.record.navigation_id}" class="u-indentDepth{$treeEntry.depth}">{{ (repeat('--', $treeEntry.depth)|raw) }}
						{$treeEntry.record.title}
						({$treeEntry.record.display_order})
					</xf:option>
				</xf:foreach>
			</xf:selectrow>

			<xf:macro template="display_order_macros" name="row"
				arg-value="{$navigation.display_order}" />

			<hr class="formRowSep" />

			<xf:selectrow name="admin_permission_id" value="{$navigation.admin_permission_id}"
				label="{{ phrase('required_admin_permission') }}">

				<xf:option>&nbsp;</xf:option>
				<xf:foreach loop="$adminPermissions" value="$adminPermission">
					<xf:option value="{$adminPermission.admin_permission_id}">{$adminPermission.title}</xf:option>
				</xf:foreach>
			</xf:selectrow>
			<xf:checkboxrow>
				<xf:option name="debug_only" selected="$navigation.debug_only">{{
					phrase('display_this_navigation_in_debug_mode_only') }}
				</xf:option>
				<xf:option name="development_only" selected="$navigation.debug_only">{{
					phrase('display_this_navigation_in_development_mode_only') }}
				</xf:option>
				<xf:option name="hide_no_children" selected="$navigation.hide_no_children">{{
					phrase('hide_this_navigation_when_there_no_viewable_children') }}
				</xf:option>
			</xf:checkboxrow>

			<hr class="formRowSep" />

			<xf:macro template="addon_macros" name="addon_edit" arg-addOnId="{$navigation.addon_id}" />

		</div>

		<xf:submitrow sticky="true" icon="save" />
	</div>
</xf:form>