<core:FragmentDefinition
    xmlns="sap.m"
    xmlns:core="sap.ui.core"
    xmlns:dnd="sap.ui.core.dnd"
    xmlns:grid="sap.ui.layout.cssgrid"
    xmlns:l="sap.ui.layout"
    xmlns:layout="sap.ui.layout"
    xmlns:f="sap.ui.layout.form"
    core:require="{
    format: 'sap/mcsuite/model/Format', 
    translate: 'sap/mcsuite/model/Translate', 
    utils: 'sap/mcsuite/model/Utils'
  }"
>
    <CustomListItem>
    <grid:CSSGrid 
        gridTemplateColumns="1fr 10fr 1fr"
        class="mc-item-grid"
    >
        <HBox alignItems="Center" justifyContent="Center">
        <Avatar 
            class='mc-item-avatar'
            initials="{=${_contact_id/surname}.charAt(0) + ${_contact_id/forename}.charAt(0)}"
            displaySize="S"
            backgroundColor="Accent6"
        />
        </HBox>
    <VBox class="mc-item-titles" justifyContent="Center" alignItems="Stretch">
        <Title text="{= ${path: '_contact_id/erp_jobs_dt/0/_job_id/name', targetType: 'any'} === undefined ? ${_contact_id/forename} + ' ' + ${_contact_id/surname} : ${_contact_id/forename} + ' ' + ${_contact_id/surname} + ' - ' + ${_contact_id/erp_jobs_dt/0/_job_id/name} + ', ' + ${_contact_id/erp_jobs_dt/0/_job_id/_client_id/name}}" class='sapUiTinyMarginBottom'/>
        <grid:CSSGrid 
            gridTemplateColumns="1fr 1fr 1fr"
            class='mc-item-property-grid'
        >
        <HBox alignItems="Center" visible="{= %{path: '_contact_id/crm_contacts_dt/0/phone', targetType: 'any'} !== undefined &amp;&amp; (%{path: '_contact_id/crm_contacts_dt/0/phone', targetType:  'string'} !== '' || %{path: '_contact_id/crm_contacts_dt/0/email', targetType:  'string'} !== '')}">
            <core:Icon src="{='sap-icon://fa-light/' + (%{path: '_contact_id/crm_contacts_dt/0/phone', targetType:  'string'} !== '' ? 'phone' : 'envelope')}"
                class="sapUiTinyMarginEnd"
            />
            <Label text="{_contact_id/crm_contacts_dt/0/name}" vAlign="Middle" class='sapUiTinyMarginEnd'/>
            <Link text="{=%{path: '_contact_id/crm_contacts_dt/0/phone', targetType:  'string'} !== '' ? ${_contact_id/crm_contacts_dt/0/phone} : ${_contact_id/crm_contacts_dt/0/email}}" href="{= %{path: '_contact_id/crm_contacts_dt/0/phone', targetType:  'string'} !== '' ? 'tel:' + ${_contact_id/crm_contacts_dt/0/phone} : 'mailto:' + ${_contact_id/crm_contacts_dt/0/email}}"/>
        </HBox>
        <HBox alignItems="Center">
            <core:Icon src="sap-icon://fa-light/bell"
                class="sapUiTinyMarginEnd"
            />
            <Text text="{parts: [{path: '_contact_id/id'}, {value: 'crm_contacts_bs'}, {value: 'crm_alerts_dt'}], formatter: '.getCount'}" class="sapUiTinyMarginEnd"/>
            <Text text="Alarmgruppen" />
        </HBox>
        <HBox alignItems="Center" >
            <core:Icon src="sap-icon://fa-light/users"
                class="sapUiTinyMarginEnd"
            />
            <Text text="{parts: [{path: '_contact_id/id'}, {value: 'crm_contacts_bs'}, {value: 'gpv_rosters_dt'}], formatter: '.getCount'}" class="sapUiTinyMarginEnd"/>
            <Text text="Sicherheitsdienste" />
        </HBox>
        </grid:CSSGrid>
    </VBox>
    <HBox alignItems="Center" justifyContent="Center">
    <Button
        class='mc-items-expandButton'
        icon="sap-icon://fa-light/arrow-up-right-from-square"
        type="Transparent"
        press="taskNav"
    >
        <customData>
            <core:CustomData key="module" value="contacts"/>
            <core:CustomData key="task" value="contacts_show"/>
            <core:CustomData key="field" value="id"/>
            <core:CustomData key="value" value="{_contact_id/id}"/>
        </customData>
    </Button>
    <Button
        class='mc-items-expandButton'
        icon="sap-icon://fa-light/trash"
        type="Transparent"
        press="utils.Roster.removeMember"
    >
        <customData>
            <core:CustomData key="id" value="{id}"/>
        </customData>
    </Button>
    </HBox>
    </grid:CSSGrid>
    </CustomListItem>
</core:FragmentDefinition>
