<core:FragmentDefinition
	xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"
	xmlns:core="sap.ui.core"
	xmlns="sap.m"
	template:require="{
					CONTACT: 'sap/fe/macros/contact/ContactHelper',
					UI: 'sap/fe/core/templating/UIFormatters'
	}"
>
	<Label text="{sap.fe.i18n>POPOVER_CONTACT_SECTION_JOBTITLE}" visible="{= !!${contact>title}}" />
	<Text text="{contact>title@@MODEL.format}" visible="{= !!${contact>title}}" />

	<Label text="{sap.fe.i18n>POPOVER_CONTACT_SECTION_DEPARTMENT}" visible="{= !!${contact>org}}" />
	<Text text="{contact>org@@MODEL.format}" visible="{= !!${contact>org}}" />

	<template:if test="{contact>tel}">
		<template:with path="contact>tel" var="tels">
			<template:repeat
				list="{path:'tels>', filters: { path: 'type/$EnumMember', operator: 'EndsWith', value1: 'preferred'}}"
				var="tel"
			>
				<Label text="{= CONTACT.computePhoneLabel(${tel>type/$EnumMember})}" />
				<Link text="{tel>uri/@@MODEL.format}" href="{= CONTACT.formatUri('phone', ${tel>uri/@@MODEL.format})}" wrapping="true" />
			</template:repeat>
			<template:repeat list="{path:'tels>', filters: { path: 'type/$EnumMember', operator: 'EndsWith', value1: 'work'}}" var="tel">
				<Label text="{= CONTACT.computePhoneLabel(${tel>type/$EnumMember})}" />
				<Link text="{tel>uri/@@MODEL.format}" href="{= CONTACT.formatUri('phone', ${tel>uri/@@MODEL.format})}" wrapping="true" />
			</template:repeat>
			<template:repeat list="{path:'tels>', filters: { path: 'type/$EnumMember', operator: 'EndsWith', value1: 'cell'}}" var="tel">
				<Label text="{= CONTACT.computePhoneLabel(${tel>type/$EnumMember})}" />
				<Link text="{tel>uri/@@MODEL.format}" href="{= CONTACT.formatUri('phone', ${tel>uri/@@MODEL.format})}" wrapping="true" />
			</template:repeat>
			<template:repeat list="{path:'tels>', filters: { path: 'type/$EnumMember', operator: 'EndsWith', value1: 'fax'}}" var="tel">
				<Label text="{= CONTACT.computePhoneLabel(${tel>type/$EnumMember})}" />
				<Link text="{tel>uri/@@MODEL.format}" href="{= CONTACT.formatUri('phone', ${tel>uri/@@MODEL.format})}" wrapping="true" />
			</template:repeat>
		</template:with>
	</template:if>
	<template:if test="{contact>email}">
		<template:with path="contact>email" var="emails">
			<template:repeat
				list="{path:'emails>', filters: { path: 'type/$EnumMember', operator: 'EndsWith', value1: 'preferred'}}"
				var="mail"
			>
				<Label text="{sap.fe.i18n>POPOVER_CONTACT_SECTION_EMAIL}" />
				<Link
					text="{mail>address/@@MODEL.format}"
					href="{= CONTACT.formatUri('mail', ${mail>address/@@MODEL.format})}"
					wrapping="true"
				/>
			</template:repeat>
			<template:repeat list="{path:'emails>', filters: { path: 'type/$EnumMember', operator: 'EndsWith', value1: 'work'}}" var="mail">
				<Label text="{sap.fe.i18n>POPOVER_CONTACT_SECTION_EMAIL}" />
				<Link
					text="{mail>address/@@MODEL.format}"
					href="{= CONTACT.formatUri('mail', ${mail>address/@@MODEL.format})}"
					wrapping="true"
				/>
			</template:repeat>
		</template:with>
	</template:if>
	<template:if test="{contact>adr}">
		<template:with path="contact>adr" var="adrs">
			<template:repeat list="{adrs>}" var="adr">
				<template:if test="{adr>label}">
					<template:then>
						<Label text="{sap.fe.i18n>POPOVER_CONTACT_SECTION_ADR}" />
						<Text text="{adr>label/@@MODEL.format}" />
					</template:then>
					<template:else>
						<Label text="{sap.fe.i18n>POPOVER_CONTACT_SECTION_ADR}" />
						<Text
							text="{= CONTACT.formatAddress(${adr>street/@@MODEL.format}, ${adr>code/@@MODEL.format}, ${adr>locality/@@MODEL.format}, ${adr>region/@@MODEL.format}, ${adr>country/@@MODEL.format})}"
						/>
					</template:else>
				</template:if>
			</template:repeat>
		</template:with>
	</template:if>
</core:FragmentDefinition>
