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

class Controller extends Summary {
    set user(value) {
        this._user = value;
        this.$.summary = null;
        if (!value) return;

        const filter = {
            include: {
                relation: 'role',
                scope: {
                    fields: ['id', 'name']
                }
            }
        };
        this.$http.get(`Accounts/${value.id}`, {filter})
            .then(res => this.$.summary = res.data);
    }
    get isHr() {
        return this.aclService.hasAny(['hr']);
    }

    get user() {
        return this._user;
    }
}

ngModule.component('vnUserSummary', {
    template: require('./index.html'),
    controller: Controller,
    bindings: {
        user: '<'
    }
});