<core:FragmentDefinition xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"
	xmlns="sap.m"
	xmlns:core="sap.ui.core"
	xmlns:macro="sap.fe.macros"
	template:require="{
		macroLibrary: 'sap/fe/macros/macroLibrary',
		MODEL: 'sap/ui/model/odata/v4/AnnotationHelper',
		VLH: 'sap/fe/macros/ValueListHelper'
	}">
	<Table id="{source>id}::Table" items="{= '{ path : \'/' + ${valueList>CollectionPath} + '\' , suspended : true }' }" width="26rem" growing="true" growingScrollToLoad="true">
		<columns>
			<template:repeat list="{valueList>Parameters}" var="parameter">
				<template:if test="{= ${parameter>$Type} !== 'com.sap.vocabularies.Common.v1.ValueListParameterIn'}">
					<template:with path="parameter>ValueListProperty" var="parameter" helper="VLH.getValueListProperty">
						<template:if test="{= !(${parameter>@com.sap.vocabularies.UI.v1.Hidden} === true)}">
							<Column>
								<template:if test="{parameter>Label}">
									<template:then>
										<Label text="{parameter>Label@@MODEL.value}"/>
									</template:then>

									<template:elseif test="{parameter>@com.sap.vocabularies.Common.v1.Label}">
										<Label text="{parameter>@com.sap.vocabularies.Common.v1.Label@@MODEL.value}"/>
									</template:elseif>

									<template:else>
										<!-- no label found, property path as fallback, to highlight it put it into [] -->
										<Label text="[{parameter>@sapui.name@@MODEL.value}]"/>
									</template:else>
								</template:if>
							</Column>
						</template:if>
					</template:with>
				</template:if>
			</template:repeat>
		</columns>
		<items>
			<ColumnListItem type="Active">
				<cells>
					<template:with path="valueList>" helper="VLH.getValueListCollectionEntitySet" var="entitySet">
						<template:repeat list="{valueList>Parameters}" var="parameter">
							<template:if test="{= ${parameter>$Type} !== 'com.sap.vocabularies.Common.v1.ValueListParameterIn'}">
								<template:with path="parameter>ValueListProperty" var="dataField" helper="VLH.getValueListProperty">
									<template:if test="{= !(${dataField>@com.sap.vocabularies.UI.v1.Hidden} === true)}">
										<!-- TODO: as a workaround we pass VHTable as parent control so ignore text annotation -->
										<macro:Field idPrefix="{source>id}::Table" editMode="Display"
													 parentControl="VHTable"
													 metadataContexts="
											{ model: 'entitySet', path:'',  name: 'entitySet'},
											{ model: 'dataField', path:'',  name: 'dataField'}
										"></macro:Field>
									</template:if>
								</template:with>
							</template:if>
						</template:repeat>
					</template:with>
				</cells>
			</ColumnListItem>
		</items>
	</Table>
</core:FragmentDefinition>
