<xf:title>{{ phrase('outdated_templates') }}</xf:title>
<xf:description>{{ phrase('outdated_templates_desc') }}</xf:description>

<xf:if is="$autoMerged">
	<div class="blockMessage blockMessage--success blockMessage--iconic">
		{{ phrase('all_automatically_mergeable_templates_have_been_processed') }}
	</div>
</xf:if>

<xf:pageaction>
	<xf:button href="{{ link('styles/customized-components') }}">{{ phrase('customized_components') }}</xf:button>
	<xf:if is="$total">
		<xf:button href="{{ link('templates/auto-merge') }}" overlay="true">{{ phrase('automatically_merge') }}</xf:button>
	</xf:if>
</xf:pageaction>

<xf:if is="$total">
	<div class="block">
		<div class="block-outer">
			<xf:macro id="filter_macros::quick_filter" arg-key="outdated-templates" arg-class="block-outer-opposite" />
		</div>
		<div class="block-container">
			<div class="block-body">
				<xf:datalist>
					<xf:foreach loop="$styleTree.getFlattened(0)" value="$treeEntry">
						<xf:set var="$style" value="{$treeEntry.record}" />
						<xf:set var="$outdatedForStyle" value="{$outdatedGrouped.{$style.style_id}}" />
						<xf:if is="$outdatedForStyle is not empty">
							<xf:datarow rowtype="subsection" rowclass="dataList-row--noHover">
								<xf:cell colspan="2">{$style.title}</xf:cell>
							</xf:datarow>
							<xf:foreach loop="$outdatedForStyle" value="$outdated">
								<xf:datarow>
									<xf:cell href="{{ link('templates/edit', $outdated.template) }}" class="dataList-cell--main">
										<div class="dataList-mainRow" dir="auto">{$outdated.template.title}</div>
										<div class="dataList-subRow">
											<ul class="listInline listInline--bullet">
												<xf:if is="$outdated.outdated_by_date">
													<li>{{ phrase('last_edited:') }} <xf:date time="{$outdated.template.last_edit_date}" /></li>
													<li>{{ phrase('parent_last_edited:') }} <xf:date time="{$outdated.parent_last_edit_date}" /></li>
												<xf:elseif is="$outdated.outdated_by_version" />
													<li>{{ phrase('custom_version:') }} {$outdated.template.version_string}</li>
													<li>{{ phrase('parent_version:') }} {$outdated.parent_version_string}</li>
												</xf:if>
											</ul>
										</div>
									</xf:cell>
									<xf:action href="{{ link('templates/merge-outdated', $outdated.template) }}">{{ phrase('merge') }}</xf:action>
								</xf:datarow>
							</xf:foreach>
						</xf:if>
					</xf:foreach>
				</xf:datalist>
			</div>
			<div class="block-footer">
				<span class="block-footer-counter">{{ display_totals($total) }}</span>
			</div>
		</div>
	</div>
<xf:else />
	<div class="blockMessage">{{ phrase('there_are_no_outdated_templates') }}</div>
</xf:if>