<template>
    <v-card
        tile
        flat
        :width="app.width"
        :height="app.height"
        class="overflow-x-auto overflow-y-hidden"
    >  
        <v-card-title class="px-1 py-0">
            <image-icon 
                :src="app.url + 'imgs/blue-icons/permissions.png'"
            />
            {{ __('Permisiuni') }}

            <v-spacer></v-spacer>
            
            <cs-quick-search 
                :dataprovider="dataprovider" 
                class="mr-2"
            />

            <cs-records-count 
                :dataprovider="dataprovider"
                field="itemsCount"
            >
                <cs-btn-reload 
                    :dataprovider="dataprovider" 
                />
            </cs-records-count>

        </v-card-title>

        <cs-toolbar 
            :toolbar="toolbar"
        >
            <v-sheet 
                max-width="200"
                class="transparent text-truncate text-dark-blue font-weight-bold"
            >
               {{ activePermission ? activePermission.name : ''}}
            </v-sheet>
        </cs-toolbar>

        <v-card
            tile
            flat
            :width="app.width"
            :height="app.height - 84"
            outlined
            class="overflow-hidden d-flex"
        >
            <v-sheet
                :width="permissionsWidth"
                :height="app.height - 84"
            >
                <permissions-root-side 
                    :app="app"
                    :width="permissionsWidth"
                    :height="app.height - 84"
                />
            </v-sheet>

            <v-sheet
                :width="'calc(100% - ' + permissionsWidth + ')'"
                :height="app.height - 84"
            >
                <permission-children 
                    :app="app"
                    width="100%"
                    :height="app.height - 84"
                />
            </v-sheet>
            
        </v-card>
        
        
    </v-card>
</template>

<script>

    export default {
        props: {
            app: {required: true},
            permissionsWidth: {default: '360px'},
        },

        computed: {

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

            toolbar() {
                return this.app.menus.Permissionstoolbar;
            },

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

        },

        components: {
            ImageIcon: require('@CsVueComp/helpers/images/ImageIcon').default,
            CsRecordsCount: require('@CsVueComp/dataprovider/CsRecordsCount').default,
            CsQuickSearch: require('@CsVueComp/dataprovider/CsQuickSearch').default,
            CsBtnReload: require('@CsVueComp/buttons/CsBtnReload').default,
            CsToolbar: require('@CsVueComp/menus/toolbar/CsToolbar').default,
        },

        name: 'PermissionsPage',
    }
</script>