<template>
    <v-menu
        v-model="form.menu.visible"
        :position-x="form.menu.x"
        :position-y="form.menu.y"
        absolute
        offset-y
        right
        :close-on-content-click="false"
        :close-on-click="false"
    >
        <cs-form-card 
            :form="form"
            :messageBox="null"
            
        > 
            <customer-account-input 
                :controls="controls"
                :activeRecord="activeRecord"
                :errorsManager="errorsManager"
                :action="action"
                :currentAction="currentAction"
                :customers="customers"
                :users="users"
                :departamente="departamente"
                @show-user-insert-form="$emit('show-user-insert-form', $event)"
            />
            
        </cs-form-card>
    </v-menu>
</template>

<script>
    export default {
        props: {
            app: {required: true},
            form: {required: true},
            customers: {required: true},
            users: {required: true},
            departamente: {required: true},
        },

        watch: {
            'activeRecord.customer_id': function(newValue, oldValue) {
                if(this.form.visible)
                {
                    if( !! newValue )
                    {
                        this.app.dataSession.Departments.GetByCustomerId(newValue);
                    }
                    else
                    {
                        this.activeRecord.department_id = null;
                    }
                }
            }
        },

        components: {
            CsFormCard: require('@CsVueComp/cards/CsFormCard').default,
        },

        mixins: [
            require('@CsVueMix/Forminput/Forminput')
        ],

        name: 'CustomerAccountFormMenu',
    }
</script>