<mvc:View
	controllerName="sap.ui.core.sample.odata.v4.SalesOrdersTemplate.Main"
	template:require="{AH : 'sap/ui/model/odata/v4/AnnotationHelper',
		Helper : 'sap/ui/core/sample/odata/v4/ListBindingTemplate/Helper'}"
	xmlns="sap.m"
	xmlns:ce="sap.ui.codeeditor"
	xmlns:core="sap.ui.core"
	xmlns:demo="sap.ui.core.sample.common"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1">
	<template:alias name="getValueListType" value="AH.getValueListType">
	<template:alias name="stringify" value="Helper.stringify">
	<template:alias name="value" value="AH.value">
	<template:alias name="label" value="AH.label">
	<VBox>
		<HBox>
			<ToggleButton icon="sap-icon://syntax" press="onSourceCode"
				text="Source Code after Templating"/>
		</HBox>
		<Panel expandable="false" visible="{ui>/bCodeVisible}"
			headerText="Source Code after Templating" width="auto" class="sapUiResponsiveMargin">
			<ce:CodeEditor editable="false" height="500px" type="xml" value="{ui>/sCode}"/>
		</Panel>
		<Panel expandable="true" headerText="(Technical Tests)">
			<VBox>
				<Title level="H1" text="Annotations at action parameters"/>
				<Label design="Bold" text="{meta>/com.sap.gateway.default.zui5_epm_sample.v0002.SalesOrder_Cancel/SalesOrder@com.sap.vocabularies.Common.v1.Label}"/>
				<Text text="----------"/>
				<Title level="H1" text="isMultiple"/>
				<template:repeat list="{meta>/}" var="topLevel">
					<template:if test="{:= ${topLevel>$kind} === 'EntitySet' }">
						<Label design="Bold" text="{topLevel>$Type}"/>
						<template:with path="topLevel>./@com.sap.vocabularies.UI.v1.Facets"
							var="facets">
							<core:Fragment
								fragmentName="sap.ui.core.sample.odata.v4.SalesOrdersTemplate.Facets"
								type="XML"/>
						</template:with>
					</template:if>
				</template:repeat>
				<Text text="----------"/>
				<template:with path="meta>/$EntityContainer/" var="objectWithKind">
					<core:Fragment
						fragmentName="sap.ui.core.sample.odata.v4.SalesOrdersTemplate.FormattedText"
						type="XML"/>
				</template:with>
				<Text text="----------"/>
				<template:with path="meta>/BusinessPartnerList" var="objectWithKind">
					<core:Fragment
						fragmentName="sap.ui.core.sample.odata.v4.SalesOrdersTemplate.FormattedText"
						type="XML"/>
				</template:with>
				<Text text="----------"/>
				<template:repeat
					list="{path: 'meta>/', filters: {path: '@sapui.name', operator: 'EndsWith', value1: 'List'}}"
					var="entitySet">
					<Text text="{entitySet>@sapui.name}: {entitySet>$Type}"/>
				</template:repeat>
				<Text text="----------"/>
				<Table id="entitySets"
					items="{path: 'metaModel>/', filters: {path: '$kind', operator: 'EQ', value1: 'EntitySet'}}">
					<headerToolbar>
						<Toolbar>
							<Title text="Entity Sets" titleStyle="H2"/>
							<ToggleButton text="Sort" press="onSort"/>
						</Toolbar>
					</headerToolbar>
					<columns>
						<Column>
							<Label text="Name"/>
						</Column>
						<Column>
							<Label text="Type"/>
						</Column>
					</columns>
					<ColumnListItem>
						<Text text="{metaModel>@sapui.name}"/>
						<Text text="{metaModel>$Type}"/>
					</ColumnListItem>
				</Table>
				<template:repeat
					list="{path: 'meta>/', filters: {path: '$kind', operator: 'EQ', value1: 'EntitySet'}}"
					var="entitySet">
					<Text text="{entitySet>@sapui.name}: {entitySet>$Type}"/>
				</template:repeat>
				<Text text="----------"/>
				<template:repeat list="{path: 'meta>/BusinessPartnerList', filters: {path: '$kind', operator: 'EQ', value1: 'Property'}, sorter: {path: '@sapui.name'}}" var="property">
					<Label design="Bold" text="{property>@sapui.name}: {property>$Type}"/>
					<template:repeat
						list="{path: 'property>@', filters: {path: '@sapui.name', operator: 'StartsWith', value1: '@com.sap.vocabularies.Common.v1.'}}"
						var="annotation">
						<Text text="{annotation>@sapui.name} = {path:'annotation>', formatter: 'stringify'}"/>
					</template:repeat>
					<Text text="ValueListType: {property>@@getValueListType}"/>
				</template:repeat>
				<!-- TODO repeat over $* properties! -->
			</VBox>
		</Panel>
		<template:with path="data>#/" var="entityType">
			<template:with path="entityType>@com.sap.vocabularies.UI.v1.LineItem" var="lineItem">
				<!-- Note: this limits the data shown to 5 rows! -->
				<Table headerText="Business Partners"
					items="{path:'', length: 5, parameters : {$$updateGroupId : 'update'}}">
					<columns>
						<template:repeat list="{lineItem>}" var="field">
							<Column>
								<Label design="{:= ${field>@com.sap.vocabularies.UI.v1.Importance/$EnumMember}
									=== 'com.sap.vocabularies.UI.v1.ImportanceType/High' ? 'Bold' : 'Standard'}"
									text="{field>@@label}"/>
							</Column>
						</template:repeat>
					</columns>
					<ColumnListItem>
						<template:repeat list="{lineItem>}" var="field">
							<template:with path="field>Value/$Path" var="target">
								<template:if test="{= ${target>@@getValueListType} !== 'None' }">
									<template:then>
										<demo:ValueHelp value="{field>Value/@@value}"/>
									</template:then>
									<template:elseif test="{target>@com.sap.vocabularies.Common.v1.Text}">
										<!-- Note: TextFirst, TextLast, TextSeparate, TextOnly -->
										<template:if test="{= ${target>@com.sap.vocabularies.Common.v1.Text@com.sap.vocabularies.UI.v1.TextArrangement/$EnumMember}
											=== 'com.sap.vocabularies.UI.v1.TextArrangementType/TextLast' }">
											<!-- Text: "A descriptive text for values of the annotated property.
												Value MUST be a dynamic expression when used as metadata annotation." -->
											<Text text="{field>Value/@@value} {target>@com.sap.vocabularies.Common.v1.Text/@@value}"/>
										</template:if>
									</template:elseif>
									<template:else>
										<Text text="{field>Value/@@value}"/>
									</template:else>
								</template:if>
							</template:with>
						</template:repeat>
					</ColumnListItem>
				</Table>
			</template:with>
		</template:with>
	</VBox>
	</template:alias>
	</template:alias>
	</template:alias>
	</template:alias>
</mvc:View>
