<core:FragmentDefinition
	xmlns="sap.m"
	xmlns:core="sap.ui.core"
	xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1">
	<!-- Note: the field's ID is computed from the mandatory 'field>' and optional 'fieldGroup>' -->
	<template:if test="{field>Value}"><!-- duck typing for com.sap.vocabularies.UI.v1.DataField -->
		<template:if test="{field>Url}">
			<template:then>
				<Link id="{parts: [{path: 'field>'}, {path: 'fieldGroup>'}], formatter: '.id'}"
					target="_blank"
					text="{path: 'field>Value', formatter: 'AH.format'}"
					href="{path: 'field>Url', formatter: 'AH.format'}" />
			</template:then>
			<template:else>
				<template:if test="{field>Value/Path}"><!-- could also be Apply etc. -->
					<template:then>
						<template:with path="field>Value" helper="AH.resolvePath" var="target">
							<template:if test="{target>com.sap.vocabularies.Common.v1.Text}">
								<template:then>
									<!--  check that IsEmailAddress annotation is available and that it has value true -->
									<template:if test="{= ${target>com.sap.vocabularies.Communication.v1.IsEmailAddress} &amp;&amp; ${target>com.sap.vocabularies.Communication.v1.IsEmailAddress}.Bool}">
										<template:then>
											<ObjectStatus id="{parts: [{path: 'field>'}, {path: 'fieldGroup>'}], formatter: '.id'}"
												icon="sap-icon://email"
												text="{path: 'target>com.sap.vocabularies.Common.v1.Text', formatter: 'AH.format'}"
												tooltip="Email" />
										</template:then>
										<template:else>
											<!--  check only the availability of the annotation IsPhoneNumber -->
											<ObjectStatus id="{parts: [{path: 'field>'}, {path: 'fieldGroup>'}], formatter: '.id'}"
												icon="{= ${target>com.sap.vocabularies.Communication.v1.IsPhoneNumber} ? 'sap-icon://phone' : ''}"
												text="{path: 'target>com.sap.vocabularies.Common.v1.Text', formatter: 'AH.format'}"
												tooltip="{= ${target>com.sap.vocabularies.Communication.v1.IsPhoneNumber} ? 'Phone' : ''}" />
										</template:else>
									</template:if>
								</template:then>
								<template:else>
									<!--  check that IsEmailAddress annotation is available and that it has value true -->
									<template:if test="{= ${target>com.sap.vocabularies.Communication.v1.IsEmailAddress} &amp;&amp; ${target>com.sap.vocabularies.Communication.v1.IsEmailAddress}.Bool}">
										<template:then>
											<ObjectStatus id="{parts: [{path: 'field>'}, {path: 'fieldGroup>'}], formatter: '.id'}"
												icon="sap-icon://email"
												text="{path: 'field>Value', formatter: 'AH.format'}"
												tooltip="Email" />
										</template:then>
										<template:else>
											<!--  check only the availability of the annotation IsPhoneNumber -->
											<ObjectStatus id="{parts: [{path: 'field>'}, {path: 'fieldGroup>'}], formatter: '.id'}"
												icon="{= ${target>com.sap.vocabularies.Communication.v1.IsPhoneNumber} ? 'sap-icon://phone' : ''}"
												text="{path: 'field>Value', formatter: 'AH.format'}"
												tooltip="{= ${target>com.sap.vocabularies.Communication.v1.IsPhoneNumber} ? 'Phone' : ''}" />
										</template:else>
									</template:if>
								</template:else>
							</template:if>
						</template:with>
					</template:then>
					<template:else>
						<Text id="{parts: [{path: 'field>'}, {path: 'fieldGroup>'}], formatter: '.id'}"
							text="{path: 'field>Value', formatter: 'AH.format'}" />
					</template:else>
				</template:if>
			</template:else>
		</template:if>
	</template:if>
</core:FragmentDefinition>
