<xf:pageaction>
	<div class="buttonGroup">
		<xf:button href="{{ link($linkPrefix . '/add') }}" icon="add">{{ phrase('add_prefix') }}</xf:button>
		<xf:button href="{{ link($groupLinkPrefix . '/add') }}" icon="add" overlay="true">{{ phrase('add_prefix_group') }}</xf:button>
	</div>
</xf:pageaction>

<xf:if is="$prefixesGrouped is not empty OR count($prefixGroups) > 1">
	<xf:form action="{{ link($linkPrefix . '/quick-set') }}" ajax="true" class="block"

		data-xf-init="select-plus"
		data-sp-checkbox=".dataList-cell--toggle input[type='checkbox']"
		data-sp-container=".dataList-row"
		data-sp-control=".dataList-cell a">

		<div class="block-outer">
			<xf:macro id="filter_macros::quick_filter" arg-key="{$linkPrefix}" arg-class="block-outer-opposite" />
		</div>
		<div class="block-container">
			<div class="block-body">
				<xf:datalist>
					<xf:foreach loop="$prefixGroups" key="$prefixGroupId" value="$prefixGroup">
						<tbody class="dataList-rowGroup" id="js-prefixGroup{$prefixGroupId}">

						<xf:if is="{{ count($prefixGroups) > 1 }}">
							<xf:datarow rowtype="subsection" rowclass="{{ !$prefixGroupId ? 'dataList-row--noHover' : '' }}">
								<xf:if is="{{ $prefixGroupId > 0 }}">
									<xf:cell class="dataList-cell--min">
										<xf:if is="{{ count($prefixesGrouped.{$prefixGroupId}) }}">
											<xf:checkbox standalone="true"><xf:option check-all="#js-prefixGroup{$prefixGroupId}" /></xf:checkbox>
										</xf:if>
									</xf:cell>
									<xf:cell href="{{ link($groupLinkPrefix . '/edit', $prefixGroup) }}" overlay="true">
										{$prefixGroup.title}
									</xf:cell>
									<xf:delete href="{{ link($groupLinkPrefix . '/delete', $prefixGroup) }}" />
								<xf:elseif is="{{ count($prefixesGrouped.{$prefixGroupId}) }}" />
									<xf:cell class="dataList-cell--min">
										<xf:checkbox standalone="true"><xf:option check-all="#js-prefixGroup{$prefixGroupId}" /></xf:checkbox>
									</xf:cell>
									<xf:cell>{{ phrase('(ungrouped)') }}</xf:cell>
									<xf:cell>&nbsp;</xf:cell>
								</xf:if>
							</xf:datarow>
						</xf:if>

						<xf:foreach loop="{$prefixesGrouped.{$prefixGroupId}}" key="$prefixId" value="$prefix">
							<xf:datarow rowclass="prefixGroup{$prefixGroupId}">
								<xf:toggle name="prefix_ids[]" value="{$prefix.prefix_id}" />
								<xf:cell href="{{ link($linkPrefix . '/edit', $prefix) }}" class="dataList-cell">
									{$prefix.title}
								</xf:cell>
								<xf:delete href="{{ link($linkPrefix . '/delete', $prefix) }}" />
							</xf:datarow>
						<xf:else />
							<xf:if is="{{ count($prefixesGrouped.{$prefixGroupId}) || $prefixGroupId > 0 }}">
								<xf:datarow rowclass="dataList-row--noHover">
									<xf:cell colspan="3" class="dataList-cell--noSearch">
										<xf:if is="{{ count($prefixGroups) > 1 }}">
											{{ phrase('no_prefixes_have_been_added_to_this_group_yet') }}
										<xf:else />
											{{ phrase('no_prefixes_have_been_added_yet') }}
										</xf:if>
									</xf:cell>
								</xf:datarow>
							</xf:if>
						</xf:foreach>
						</tbody>
					</xf:foreach>
				</xf:datalist>
			</div>
			<div class="block-footer block-footer--split">
				<span class="block-footer-counter">{{ display_totals($prefixTotal) }}</span>
				<span class="block-footer-select"><xf:checkbox standalone="true"><xf:option check-all=".dataList" label="{{ phrase('select_all') }}" /></xf:checkbox></span>
				<span class="block-footer-controls"><xf:button type="submit" name="quickset" value="1">{{ phrase('quick_set') }}</xf:button></span>
			</div>
		</div>
	</xf:form>
<xf:else />
	<div class="blockMessage">{{ phrase('no_items_have_been_created_yet') }}</div>
</xf:if>