<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'
  }"
    controllerName="sap.mcsuite.controller.BaseController"
>
    <Dialog
        draggable="true"
        contentHeight="auto"
        contentWidth="auto"
        showHeader="false"
        class="mc-dialog"
    >
        <VBox
            class="mc-dialog-header"
            alignItems="Stretch"
            justifyContent="SpaceBetween"
        >
            <grid:CSSGrid
                gridTemplateColumns="2fr 5fr"
                width="90%"
            >
                <HBox
                    alignItems="Center"
                    justifyContent="Center"
                >
                    <Avatar
                        src="sap-icon://fa-light/user"
                        displaySize="S"
                        class="sapUiTinyMarginEnd"
                    />
                    <Title
                        text='{parts: [{value:"SUBTITLE"}, {value:"roster member add dialog"}, {value:"Teilnehmer hinzufügen"}], formatter: "translate.Label.get"}'
                        level='H2'
                    />
                </HBox>
            </grid:CSSGrid>
        </VBox>
        <VBox class='mc-dialog-content'>
            <VBox
                id='mc-dialog-form-container'
                class='mc-form'
                backgroundDesign='Solid'
                alignContent='SpaceAround'
            >
                <f:Form editable='true'>
                    <f:layout>
                        <f:ResponsiveGridLayout
                            labelSpanXL='2'
                            labelSpanL='2'
                            labelSpanM='2'
                            labelSpanS='2'
                            adjustLabelSpan='true'
                            emptySpanXL='0'
                            emptySpanL='4'
                            emptySpanM='0'
                            emptySpanS='0'
                            columnsXL='1'
                            columnsL='1'
                            columnsM='1'
                            singleContainerFullSize='true'
                        />
                    </f:layout>
                    <f:formContainers>
                        <f:FormContainer>
                            <f:FormElement
                                label='{parts: [{value:"gpv_rosters_dt"}, {value:"contact_id"}], formatter: "translate.Field.get"}'
                            >
                                <f:fields>
                                    <Input
                                        showValueHelp='true'
                                        value="{newEntity>/name}"
                                        selectedKey="{path: 'newEntity>/contact_id', targetType: 'string', type: 'sap.ui.model.type.Integer', formatOptions: { groupingEnabled: false }}"
                                        suggestionItems="{path: '/crm_contacts_bs', parameters: {
                                            $filter: 'field_free2 eq \'true\' and status lt 90'
                                        }}"
                                        valueHelpRequest='showValueHelp'
                                        class='mc-add-select'
                                        editable='true'
                                        valueHelpIconSrc='sap-icon://fa-solid/chevron-down'
                                    >
                                        <customData>
                                            <core:CustomData
                                                key='mandatory'
                                                value='false'
                                            />
                                            <core:CustomData
                                                key='table'
                                                value='crm_contacts_bs'
                                            />
                                            <core:CustomData 
                                                key='filter'
                                                value="field_free2 eq 'true' and status lt 90 and not gpv_rosters_dt/any(a: a/roster_id eq $id$ and a/status lt 90)"
                                            />
                                            <core:CustomData 
                                                key='orderby'
                                                value="name"
                                            />
                                            
                                        </customData>
                                        <core:Item
                                            key="{path: 'id', type: 'sap.ui.model.type.Integer', formatOptions: { groupingEnabled: false }}"
                                            text='{name}'
                                        />
                                    </Input>
                                </f:fields>
                            </f:FormElement>
                            <f:FormElement
                                label='{parts: [{value:"gpv_rosters_dt"}, {value:"comment"}], formatter: "translate.Field.get"}'
                            >
                                <f:fields>
                                    <TextArea
                                        value="{path: 'newEntity>/comment'}"
                                    >
                                        <customData>
                                            <core:CustomData
                                                key='mandatory'
                                                value='false'
                                            />
                                        </customData>
                                    </TextArea>
                                </f:fields>
                            </f:FormElement>
                        </f:FormContainer>
                    </f:formContainers>
                </f:Form>
            </VBox>
            <HBox
                alignContent="Center"
                justifyContent="Center"
                width='100%'
            >
                <Button
                    id='mc-dialog-form-container-submitButton'
                    text='{parts: [{value:"LITERAL"}, {value:"SAVE"}, {value:"Speichern"}], formatter: "translate.Label.get"}'
                >
                    <customData>
                        <core:CustomData
                            key='close'
                            value='true'
                        />
                    </customData>
                </Button>
            </HBox>
        </VBox>
    </Dialog>
</core:FragmentDefinition>
