<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'
  }"
>
    <Dialog
        draggable="true"
        contentHeight="auto"
        contentWidth="auto"
        showHeader="false"
        class="mc-dialog"
    >
        <HBox
            alignItems="Center"
            justifyContent="Center"
            class='mc-dialog-toolButtons'
        >
            <Button
                class='transparent-button'
                icon="sap-icon://fa-light/copy"
                type="Unstyled"
                press="copyDialogData"
            />
            <Button
                class='transparent-button'
                icon="sap-icon://fa-light/arrow-up-right-from-square"
                type="Unstyled"
                press="taskNav"
            >
                <customData>
                    <core:CustomData
                        key="module"
                        value="shops"
                    />
                    <core:CustomData
                        key="task"
                        value="shops_show"
                    />
                    <core:CustomData
                        key="field"
                        value="id"
                    />
                    <core:CustomData
                        key="value"
                        value="{id}"
                    />
                </customData>
            </Button>
        </HBox>
        <VBox
            class="mc-dialog-header"
            alignItems="Stretch"
            justifyContent="SpaceBetween"
        >
            <grid:CSSGrid gridTemplateColumns="2fr 5fr 1fr">
                <HBox
                    alignItems="Start"
                    justifyContent="Center"
                >
                    <Avatar
                        src="{='sap-icon://fa-light/' + ${_cat_id/icon}}"
                        displaySize="S"
                        class="sapUiTinyMarginEnd"
                    />
                </HBox>
                <VBox
                    alignItems="Start"
                    justifyContent="Center"
                >
                    <HBox
                        alignItems="Center"
                        justifyContent="Start"
                        height="1rem"
                    >
                        <Title
                            text="{name}"
                            level="H3"
                        />
                    </HBox>
                    <Text text="{_cat_id/name}" />
                </VBox>
                <!-- Button upper right corner -->

                <!-- </HBox> -->
            </grid:CSSGrid>
            <grid:CSSGrid gridTemplateColumns="1fr 1fr 1fr">
                <VBox
                    alignItems="Center"
                    justifyContent="Center"
                >
                    <core:Icon
                        class="property-icon"
                        src="sap-icon://fa-light/sitemap"
                    />
                    <Text text="{_client_id/name}" />
                </VBox>
                <VBox
                    alignItems="Center"
                    justifyContent="Center"
                >
                    <core:Icon
                        class="property-icon"
                        src="sap-icon://fa-light/building"
                    />
                    <Text text="{sap_number}" />
                </VBox>
                <VBox
                    alignItems="Center"
                    justifyContent="Center"
                >
                    <core:Icon
                        class="property-icon"
                        src="sap-icon://fa-light/location-dot"
                    />
                    <Text text="{crm_clusters_dt/0/_cluster_id/name}" />
                </VBox>
            </grid:CSSGrid>
            <VBox
                class='mc-dialog-content'
                items="{path: 'erp_jobs_bs', 
            templateShareable: false,
            sorter: {path: '_cat_id/pos', descending: false}}"
            > 
                <VBox class='sapUiSmallMarginBottom'>
                    <HBox
                        alignItems="Center"
                        justifyContent="Start"
                        width="100%"
                    >
                        <core:Icon
                            src="{='sap-icon://fa-light/' + ${_cat_id/icon}}"
                            size="1rem"
                            color="{_cat_id/color}"
                            class='sapUiSmallMarginEnd'
                        />
                        <Text text="{_cat_id/name}" />
                    </HBox>
                    <VBox
                        items="{path: 'erp_jobs_dt', templateShareable: false}"
                        class='sapUiSmallMarginBegin'
                    >
                        <VBox width="100%">
                        <HBox visible="{= %{path: '_object', targetType: 'object'} !== null}">
                            <core:Icon
                                src="sap-icon://fa-solid/circle"
                                size="0.7rem"
                                class='sapUiTinyMarginEnd property-icon'
                            />
                            <Text text="{name}" />
                            <Text
                                text='-'
                                visible="{= %{path: '_object', targetType: 'object'} !== null}"
                            />
                            <Link
                                visible="{= ${path: '_object', targetType: 'object'} !== null}"
                                href="{='tel:' + JSON.parse(${_object}).contact_information.phone}"
                                text="{=JSON.parse(${_object}).contact_information.phone}"
                            />
                        </HBox>
                        <HBox visible="{= %{path: '_object', targetType: 'object'} === null}" items="{path: '_contact_id/crm_contacts_dt', templateShareable: false, length: 1, filters: [{path: 'type', operator: 'EQ', value1: 'INTERN'}]}">
                            <HBox class='sapUiTinyMarginBegin'>
                            
                            <Text text="{_contact_id/name}" />
                            <Text
                                text="-" class='sapUiTinyMarginBegin sapUiTinyMarginEnd'
                            />
                            <Link
                                href="{= %{path: 'phone', targetType:  'string'} !== '' ? ('tel:' + ${phone}) : ('mailto:' + ${email})}"
                                text="{= %{path: 'phone', targetType:  'string'} !== '' ? ${phone} : ${email}}"
                            />
                            </HBox>
                        </HBox>
                        </VBox>
                    </VBox>
                </VBox>
            </VBox>
        </VBox>
    </Dialog>
</core:FragmentDefinition>
