<xf:macro id="list"
	arg-category="!"
	arg-isPrivate="!"
	arg-userGroups="!"
	arg-users="!"
	arg-entries="!"
	arg-routeBase="!">

	<xf:form action="{{ link($routeBase . '/save', $category) }}" ajax="true" class="block">
		<div class="block-container">
			<div class="block-body">
				<xf:checkboxrow>
					<xf:option name="private" selected="{$isPrivate}"
						label="{{ phrase('private_category') }}"
						hint="{{ phrase('private_category_hint') }}" />
				</xf:checkboxrow>
			</div>
			<xf:submitrow icon="save" />
		</div>
		<xf:hiddenval name="type">private</xf:hiddenval>
	</xf:form>

	<div class="block">
		<div class="block-container">
			<h3 class="block-header">{{ phrase('user_groups') }}</h3>
			<div class="block-body">
				<xf:datalist>
					<xf:foreach loop="$userGroups" value="$userGroup">
						<xf:datarow
							label="{$userGroup.title}"
							href="{{ link($routeBase . '/edit', $category, {'user_group_id': $userGroup.user_group_id}) }}"
							rowclass="{{ {$entries.groups.{$userGroup.user_group_id}} ? 'dataList-row--custom' : '' }}" />
					</xf:foreach>
				</xf:datalist>
			</div>
		</div>
	</div>

	<xf:form action="{{ link($routeBase . '/edit', $category) }}" class="block">
		<div class="block-container">
			<h3 class="block-header">{{ phrase('users_with_permissions_set') }}</h3>
			<div class="block-body">
				<xf:if is="$users is not empty">
					<xf:datalist>
						<xf:foreach loop="$users" value="$user">
							<xf:datarow
								label="{$user.username}"
								href="{{ link($routeBase . '/edit', $category, {'user_id': $user.user_id}) }}"
								rowclass="dataList-row--custom" />
						</xf:foreach>
					</xf:datalist>
					<hr class="block-separator" />
				</xf:if>
				<xf:textboxrow name="username" ac="single"
					label="{{ phrase('set_permissions_for_user') }}" />
			</div>
			<xf:submitrow submit="{{ phrase('proceed...') }}" />
		</div>
		<xf:hiddenval name="type">user</xf:hiddenval>
	</xf:form>
</xf:macro>

<xf:macro id="edit"
	arg-category="!"
	arg-permissionData="!"
	arg-typeEntries="!"
	arg-routeBase="!"
	arg-saveParams="!">

	<xf:form action="{{ link($routeBase . '/save', $category, $saveParams) }}" ajax="true" class="block">
		<xf:macro id="permission_macros::edit_outer" arg-type="content" />

		<div class="block-container">
			<xf:macro id="permission_macros::content_edit_groups"
				arg-permissionsGrouped="{$permissionData.permissionsGrouped}"
				arg-interfaceGroups="{$permissionData.interfaceGroups}"
				arg-values="{$typeEntries}"
			/>
			<xf:submitrow sticky="true" icon="save" />
		</div>
	</xf:form>
</xf:macro>