<template>
    <v-sheet class="pa-1">
        <permission-item 
            v-for="(permission, index) in permissions"
            :key="'permissions-' + index"
            :app="app"
            :permission="permission"

            @right-click="OnRightClick"
        />
    </v-sheet>
</template>

<script>

    export default {
        props: {
            app: {required: true},
            parentPermission: {required: true},
            permissions: {default: () => []},
        },

        computed: {
            dataprovider() {
                return this.app.dataSession.Permissions;
            },

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

        methods: {
            OnRightClick(event) {
                let e = event.e;
                let permission = event.permission;

                e.preventDefault();
                e.stopPropagation();

                this.controller.SetActivePermission(permission);

                this.app.menus.Permissionrightmenu.Show(
                    this.$parent,
                    {
                        x: e.clientX, 
                        y: e.clientY
                    }, 
                    [
                        // this.app.menus.Filerightmenu,
                        // this.app.menus.Fileform
                    ],
                );
            }
        },

        name: 'Permissions',
    }
</script>