<template>
    <v-menu
        v-model="menu.visible"
        :position-x="menu.x"
        :position-y="menu.y"
        absolute
        offset-y
        :close-on-content-click="false"
        :close-on-click="false"
    >
        <v-card
            tile
            flat
            :width="width"
        >
            <v-card-title>
                {{ __('Utilizatori asociați cursului') }}
            </v-card-title>

            <v-divider></v-divider>

            <v-sheet
                :height="height"
                class="overflow-y-auto"
            >
                <v-card-text class="pa-1">
                    <data-table 
                        :app="app"
                        :dataprovider="app.dataSession.Customercursuriuser"
                        :datatable="app.datatables.Cursuriusers"
                        :height="height - 8"
                        :width="width"
                        :dtWidth="app.datatables.Cursuriusers.datatableWidth"
                    />
                </v-card-text>
            </v-sheet>

            <v-divider></v-divider>

            <v-card-actions>
                <v-spacer></v-spacer>

                <cs-btn 
                    caption="Renunță"
                    icon="mdi-close"
                    @click="OnClickCancel"
                />
            </v-card-actions>
        </v-card>
    </v-menu>
</template>

<script>
    export default {
        props: {
            app: {required: true},
            menu: {required: true},
            width: {default: 800},
            height: {default: 460},
            
        },

        watch: {
            'menu.visible': function() {
                if(this.menu.visible)
                {
                    this.LoadUsers();
                }
            }
        },

        methods: {
            LoadUsers() {
                this.app.dataSession.Customercursuriuser.GetByCustomerCursId(this.menu.customercurs.id);
            },

            OnClickCancel() {
                this.menu.visible = false;
            }
        },

        components: {
            CsBtn: require('@CsVueComp/buttons/CsBtn').default,
        },

        name: 'CursUsersMenu'
    }
</script>