<template>

    <v-card v-if="false">
        <index-page 
            :app="app"
            :controller="controller"
        >

            <template #append-breadcrumbs>
                <customer-entities-popup 
                    :menu="app.menus.Entitiespopup"
                />
            </template>
            
            <template #prepend>
                <contract-form-menu 
                    :app="app"
                    :form="controller.form"
                />

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

    <cs-centered-alert
        v-else-if="! controller.isBooted"
        :height="app.height"
        :width="app.width"
        :message="__('Se încarcă...', null, app.translations)"
    >
        <v-progress-circular
            indeterminate
            color="orange darken-1"
        >
        </v-progress-circular>
    </cs-centered-alert>

    <v-card
        v-else
        tile flat class=""
        :width="app.width"
        :height="app.height"
    >
        <v-card-title class="px-0 py-2">
            {{ __(':name. Contracte', {name: customer.name}) }}
        </v-card-title>

        <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 tile flat class="cyan"
            :height="app.height - 69"
            :width="app.width"
        >
            <manager-contracte 
                :customer="customer"
                :contracte="contracte"
                :app="app"
                :height="app.height - 69"
            />
        </v-card>


    </v-card>
    
</template>

<script>


    export default {
        props: {
            app: {require: true},
        },

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

            contracte() {
                return this.app.dataSession.Contracte.items;
            },

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

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

                // this.controller.MakeEditableColumn(this.controller.model, 'departament-column');
            },

            /**
             * Filtering
             */
            InitFiltering() {
                /**
                 * formularul de filtrare își inregistreaza dataprovider-ul
                 */
                this.controller.FilterformRegisterDataProvider(this.controller.model);


                /**
                 * La coloana name atasez filter controlul name din formularul de filtrare, etc
                 */
                // this.controller.MakeFilterableColumn(this.controller.model, 'departament-column', 'departament');
            },

            LoadData() {
                this.app.dataSession.Customers.GetById(this.controller.customer_id);
            }
        },

        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>