57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
class Controller {
|
|
constructor($, $http) {
|
|
Object.assign(this, {
|
|
$,
|
|
$http
|
|
});
|
|
}
|
|
|
|
get worker() {
|
|
return this._worker;
|
|
}
|
|
|
|
set worker(value) {
|
|
this._worker = value;
|
|
this.$.worker = null;
|
|
if (!value) return;
|
|
|
|
let query = `api/Workers/${value.id}`;
|
|
let filter = {
|
|
include: [
|
|
{
|
|
relation: 'user',
|
|
scope: {
|
|
fields: ['name', 'email', 'roleFk'],
|
|
include: {
|
|
relation: 'role',
|
|
scope: {fields: ['name']}
|
|
}
|
|
}
|
|
}, {
|
|
relation: 'client',
|
|
scope: {fields: ['fi']}
|
|
}, {
|
|
relation: 'sip',
|
|
scope: {fields: ['extension']}
|
|
}
|
|
]
|
|
};
|
|
|
|
this.$http.get(query, {params: {filter}}).then(res => {
|
|
this.$.worker = res.data;
|
|
});
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$scope', '$http'];
|
|
|
|
ngModule.component('vnWorkerSummary', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
worker: '<'
|
|
}
|
|
});
|