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

class Controller extends Summary {
    $onChanges() {
        if (!this.supplier)
            return;

        this.getSummary();
    }

    get isAdministrative() {
        return this.aclService.hasAny(['administrative']);
    }

    getSummary() {
        return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
            this.summary = response.data;
        });
    }
}

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