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

<xf:pageaction>
	<xf:button href="{{ link('permission-definitions/permissions/add') }}" icon="add">
		{{ phrase('add_permission') }}
	</xf:button>
	<xf:button href="{{ link('permission-definitions/interface-groups/add') }}" icon="add">
		{{ phrase('add_interface_group') }}
	</xf:button>
</xf:pageaction>

<xf:foreach loop="$interfaceGroups" key="$interfaceGroupId" value="$interfaceGroup">
	<div class="block">
		<div class="block-container">
			<h2 class="block-header">
				{{ anchor_target('interface_group_' . $interfaceGroup.interface_group_id) }}
				<a href="{{ link('permission-definitions/interface-groups/edit', $interfaceGroup) }}" class="u-pullRight">{{ phrase('edit') }}</a>
				{$interfaceGroup.title}
				<span class="block-desc">
					{$interfaceGroupId} ({$interfaceGroup.display_order})
				</span>
			</h2>
			<div class="block-body">
				<xf:if is="{$permissionsGrouped.{$interfaceGroupId}} is not empty">
					<xf:datalist>
						<xf:foreach loop="{$permissionsGrouped.{$interfaceGroupId}}" value="$permission">
							<xf:datarow
								href="{{ link('permission-definitions/permissions/edit', $permission) }}"
								label="{$permission.title}"
								hint="{$permission.permission_group_id} / {$permission.permission_id} ({$permission.display_order})"
								hash="{$permission.permission_group_id}_{$permission.permission_id}" />
						</xf:foreach>
					</xf:datalist>
				<xf:else />
					<div class="block-row">
						{{ phrase('no_permissions_have_been_created_for_interface_group_yet', {
							'link': link('permission-definitions/permissions/add', null, {
								'interface_group_id': $interfaceGroupId
							})
						}) }}
					</div>
				</xf:if>
			</div>
		</div>
	</div>
</xf:foreach>

<xf:set var="$ungroupedKey" value="" />
<xf:if is="{$permissionsGrouped.{$ungroupedKey}} is not empty">
	<div class="block">
		<div class="block-container">
			<h2 class="block-header">
				{{ phrase('ungrouped_permissions') }}
			</h2>
			<div class="block-body">
				<xf:datalist>
					<xf:foreach loop="{$permissionsGrouped.{$ungroupedKey}}" value="$permission">
						<xf:datarow
							href="{{ link('permission-definitions/permissions/edit', $permission) }}"
							label="{$permission.title}"
							hint="{$permission.permission_group_id} / {$permission.permission_id}"
							hash="{$permission.permission_group_id}_{$permission.permission_id}" />
					</xf:foreach>
				</xf:datalist>
			</div>
		</div>
	</div>
</xf:if>