<template>

    <cs-centered-alert
        v-if="! controller.isBooted"
        :height="controller.height"
        :width="controller.width"
        message="Se încarcă..."
    >
        <v-progress-circular
            indeterminate
            color="orange darken-1"
        >
        </v-progress-circular>
    </cs-centered-alert>

    <v-card v-else tile flat>
        <v-card tile flat :height="app.height" :width="app.width" :disabled="controller.page_disabled">

            <v-card-title class="pa-0 primary--text text--darken-3">
                {{ controller.title  }}
            </v-card-title>

            <v-card-title class="pa-0">
                <v-breadcrumbs 
                    v-if="controller.hasBreadcrumbs"
                    :items="controller.breadcrumbs" 
                    class="pa-0"
                >
                    <template v-slot:divider>
                        <v-icon>mdi-dots-vertical</v-icon>
                    </template>
                </v-breadcrumbs>
            </v-card-title>

            <cs-toolbar :toolbar="mytoolbar" :translate="false">
                <v-text-field
                    dense
                    hide-details
                    clearable
                    :placeholder="__('Căutare...')"
                    append-icon="mdi-magnify"
                    class="text-body-2"
                    :disabled="false"
                    v-model="controller.innerSearchText"
                >
                </v-text-field>
            </cs-toolbar>

            <v-card tile flat :height="app.height - 112" :width="app.width" class="d-flex overflow-hidden">

                <v-sheet :width="leftWidth" :height="app.height - 112">
                    <user-cursuri-quick-lists :app="app" :height="app.height - 112" />
                </v-sheet>

                <v-sheet :width="'calc(100% - ' + leftWidth + 'px)'" :height="app.height - 112">
                    <user-cursuri-list :app="app" :dataprovider="app.dataSession.Customercursuriuser" :height="app.height - 112" />
                </v-sheet>
            </v-card>
        </v-card>

        <curs-preview-menu :app="app" :menu="controller.curspreviewmenu" />

        <curs-asigneaza-menu :app="app" :menu="controller.cursasigneazawmenu" target="cursurile-mele" />

        <curs-change-status-menu :app="app" :menu="controller.curschangestatusmenu" />
    </v-card>

</template>

<script>
    export default {
        props: {
            app: {require: true},
            leftWidth: {default: 320}
        },

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

            mytoolbar() {
                return this.controller.toolbar;
            }
        },

        methods: {
            LoadResources() {
                this.app.AddClassesByContext(require.context('./../../Classes', true, /\.class.js$/i));
                this.app.AddDataProvidersByContext(require.context('./../../DataSessions', true, /\.dataprovider.js$/i));
                this.app.AddDatatablesByContext(require.context('./../../Datatables', true, /\.datatable.js$/i));
                this.app.AddFormProvidersByContext(require.context('./../../FormProviders', true, /\.formprovider.js$/i));                
                this.app.AddFormsByContext(require.context('./../../Forms', true, /\.form.js$/i));
                this.app.AddFilterFormsByContext(require.context('./../../Filterforms', true, /\.filterform.js$/i));
                this.app.AddMenusByContext(require.context('./../../Toolbars', true, /\.toolbar.js$/i));
                this.app.AddMenusByContext(require.context('./../../Menus', true, /\.menu.js$/i));
                this.app.AddMenusByContext(require.context('./../../Breadcrumbs', true, /\.breadcrumbs.js$/i));
                this.app.AddRequestsByContext(require.context('./../../Requests', true, /\.request.js$/i));
            },

            LoadData() {
                this.app.dataSession.Accounts.GetByCustomerId(this.controller.customer_id);
                this.app.dataSession.Cursuriatasate.GetByCustomerId(this.controller.customer_id);
                this.app.dataSession.Customers.GetById(this.controller.customer_id);
                this.app.forms.Share.formprovider = this.app.formproviders.Share; 
                this.controller.GetCustomerusercursuricounter();
            }
        },

        created() {
            this.LoadResources();                        
            this.LoadData();
        },

        components: {
            CsCenteredAlert: require('@CsVueComp/sheets/CsCenteredAlert').default,
            CsToolbar: require('@CsVueComp/menus/toolbar/CsToolbar').default,
        },

        name: 'Index',
    }
</script>