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

    <v-card
        v-else
        tile
        flat
        :width="app.width"
        :height="app.height"
    >
        <v-card
            tile
            flat
            :width="app.width"
            :height="app.height"
            :disabled="controller.isPageDisabled || controller.sharedetailsmenu.visible"
        >
            <v-card-title class="pa-0 primary--text text--darken-3">
                {{ __('Trimiteri cursuri') }} 
            </v-card-title>

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

                <v-spacer></v-spacer>

                <cs-quick-search 
                    v-if="controller.hasQuickSearch"
                    :dataprovider="controller.dataprovider"
                />

                <v-chip small outlined>
                    {{controller.recordsCount}}
                </v-chip>
            </v-card-title>

            <cs-toolbar 
                v-if="controller.hasToolbar" 
                :toolbar="controller.toolbar"
            >
                <cs-pagination 
                    v-if="controller.hasPagination"
                    :dataprovider="controller.dataprovider" 
                    :width="null"
                    htmlClass="mr-0 ml-auto"
                />
            </cs-toolbar>

            <v-card
                tile
                flat
                :width="app.width"
                :height="app.height - 112"
            >            
                <data-table 
                    :app="app"
                    :dataprovider="controller.dataprovider"
                    :datatable="controller.datatable"
                    :height="app.height - 112"
                    :width="app.width"
                    :dtWidth="controller.datatableWidth"
                />
            </v-card>
        </v-card>

        <trimitere-form-menu 
            :app="app"
            :form="app.forms.Share"
        />

        <share-details-menu 
            :app="app"
            :menu="controller.sharedetailsmenu"
        />

        <share-filter-menu 
            :app="app"
            :filterform="controller.filterform"
        />
    </v-card>
</template>

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

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

        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));
            },

            InitDatatable() {
                this.controller.DatatableRegisterDataProvider(this.controller.model);
            },

            InitForms() {
                this.controller.FormRegisterFormProvider(this.controller.model);
            },

            InitFiltering() {
                this.app.filterForms.Share.RegisterDataProvider(this.app.dataSession.Share);
            },

            LoadData() {
                this.controller.LoadData();
            }
        },

        components: {
            CsCenteredAlert: require('@CsVueComp/sheets/CsCenteredAlert').default,
            CsToolbar: require('@CsVueComp/menus/toolbar/CsToolbar').default,
            CsPagination: require('@CsVueComp/dataprovider/CsPagination').default,
            CsQuickSearch: require('@CsVueComp/dataprovider/CsQuickSearch').default,
        },
        
        mixins: [
            require('VUEMIX/Index/IndexPage'),
        ],

        name: 'Index',
    }
</script>