import ngModule from '../module';
import Summary from 'salix/components/summary';
import './style.scss';

class Controller extends Summary {
    set shelving(value) {
        this._shelving = value;
        this.summary = null;
        if (!value) return;

        const filter = {
            include: [
                {relation: 'worker',
                    scope: {
                        fields: ['userFk'],
                        include: {
                            relation: 'user',
                            scope: {
                                fields: ['nickname']
                            }
                        }
                    }},
                {relation: 'parking'}
            ]
        };
        this.$http.get(`Shelvings/${value.id}`, {filter})
            .then(res => this.summary = res.data);
    }

    get shelving() {
        return this._shelving;
    }
}

ngModule.vnComponent('vnShelvingSummary', {
    template: require('./index.html'),
    controller: Controller,
    bindings: {
        shelving: '<'
    }
});