<mvc:View
	controllerName="sap.ui.core.sample.ViewTemplate.scenario.Detail"
	template:require="{AH: 'sap/ui/model/odata/AnnotationHelper',
		Helper: 'sap/ui/core/sample/ViewTemplate/scenario/Helper'}"
	xmlns="sap.m"
	xmlns:core="sap.ui.core"
	xmlns:layout="sap.ui.layout"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns:scenario="sap.ui.core.sample.ViewTemplate.scenario"
	xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1">
	<layout:VerticalLayout class="sapUiSmallMarginBottom">
		<!-- Note: "meta>" MUST point to an entity set! -->
		<template:alias name=".formatParts" value="Helper.formatParts">
		<template:alias name=".id" value="Helper.id">
			<template:with path="meta>/" var="fieldGroup"><!-- default value needed for IDs -->
			<template:with path="meta>entityType" helper="AH.gotoEntityType" var="entityType">

				<template:if test="{entityType>com.sap.vocabularies.UI.v1.LineItem}">
					<!-- Note: this limits the data shown to 5 rows! -->
					<Table headerText="Items" includeItemInSelection="true" mode="SingleSelectMaster"
						selectionChange="onSelectionChange" items="{:= '{path:\'/' + ${meta>name} + '\', length: 5}' }">
						<template:with path="entityType>com.sap.vocabularies.UI.v1.LineItem" var="target">
							<core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.scenario.Table" type="XML"/>
						</template:with>
					</Table>
				</template:if>

				<core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.scenario.ChartAnnotation" type="XML"/>

				<!-- expression binding just to test dynamic name -->
				<core:ExtensionPoint name="{:= 'HeaderInfo' }">
					<scenario:Form title="HeaderInfo">
						<template:with path="entityType>com.sap.vocabularies.UI.v1.HeaderInfo">
							<!-- Note: composite bindings instead of separate labels for testing only! -->
							<Text text="[Type Name] {path: 'entityType>TypeName', formatter: 'AH.format'}"/>
							<!-- Text text="[{path: 'entityType>Title/Label', formatter: 'AH.format'}] {path: 'entityType>Title/Value', formatter: 'AH.format'}" / -->
							<Text text="{parts: [{path: 'entityType>Title/Label'}, {path: 'entityType>Title/Value'}], formatter: '.formatParts'}"/>
							<template:if test="{entityType>Description}"> <!-- HeaderInfo Description is Nullable -->
								<Text text="[{path: 'entityType>Description/Label', formatter: 'AH.format'}] {path: 'entityType>Description/Value', formatter: 'AH.format'}"/>
							</template:if>
						</template:with>
					</scenario:Form>
				</core:ExtensionPoint>

				<core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.scenario.Identification" type="XML"/>

				<template:repeat list="{path:'entityType>', filters: {path: '@sapui.name', operator: 'StartsWith', value1: 'com.sap.vocabularies.UI.v1.FieldGroup'}}" var="fieldGroup">
					<scenario:Form title="{path: 'fieldGroup>Label', formatter: 'AH.format'}">
						<template:repeat list="{fieldGroup>Data}" var="field">
							<core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.scenario.LabeledField" type="XML"/>
						</template:repeat>
					</scenario:Form>
				</template:repeat>

				<Panel expandable="true" expanded="true" headerText="Facets">
					<template:with path="entityType>com.sap.vocabularies.UI.v1.Facets" var="facets">
						<core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.scenario.Facets" type="XML"/>
					</template:with>
				</Panel>
			</template:with>

			<template:with path="meta>com.sap.vocabularies.UI.v1.DataPoint" var="dataPoint">
				<template:if test="{dataPoint>}">
					<scenario:Form title="DataPoint@EntitySet - {path: 'dataPoint>Title', formatter: 'AH.format'}">
						<Label labelFor="dataPoint"
							text="{path: 'dataPoint>Description', formatter: 'AH.format'}"/>
						<Text id="dataPoint" text="{path: 'dataPoint>Value', formatter: 'AH.format'}"/>
					</scenario:Form>
				</template:if>
			</template:with>
			</template:with>
		</template:alias>
		</template:alias>
	</layout:VerticalLayout>
</mvc:View>
