<template>
    <v-toolbar
        dense
        tile
        flat
        id="files-toolbar"
        outlined
    >   
        <cs-btn 
            icon="mdi-plus"
            tooltip="Adaugă permisiune"
            :disabled="! controller.activePermission"
            @click="OnClickInsert"
        />
    </v-toolbar>
</template>

<script>
    export default {
        props: {
            app: {required: true},
        },

        computed: {
            
            controller() {
                return this.app.classes.Controller;
            },

            activePermission() {
                return this.controller.activePermission;
            },

            form() {
                return this.app.forms.Children;
            }
        },

        methods: {
            OnClickInsert(e) {
                this.form.menu.visible = false;
                
                this.form.Show(null, 'insert', null);
                
                this.app.vue.$nextTick( () => {
                    this.form.menu.visible = true;
                    this.form.menu.x = e.clientX;
                    this.form.menu.y = e.clientY;

                    this.form.formprovider.activeRecord.parent_id = this.controller.activePermission.id;
                });
            }
        },

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

        name: 'PermissionChildrenToolbar',
    }
</script>

<style lang="scss" scoped>
    #files-toolbar {
        border-top: none !important;
        border-left: none !important;
        border-right: none !important;
    }
</style>