salix/modules/worker/front/summary/index.js

78 lines
2.0 KiB
JavaScript
Raw Normal View History

2019-01-28 15:24:45 +00:00
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;
2019-01-29 20:45:43 +00:00
if (!value) return;
let query = `Workers/${value.id}`;
2019-01-29 20:45:43 +00:00
let filter = {
include: [
{
relation: 'user',
scope: {
2019-03-15 11:58:26 +00:00
fields: ['name', 'roleFk'],
include: [{
2019-01-29 20:45:43 +00:00
relation: 'role',
2019-03-15 11:58:26 +00:00
scope: {
fields: ['name']
}
},
{
relation: 'emailUser',
scope: {
fields: ['email']
}
}]
2019-01-29 20:45:43 +00:00
}
}, {
relation: 'client',
scope: {fields: ['fi']}
}, {
relation: 'sip',
scope: {fields: ['extension']}
2019-02-18 11:54:33 +00:00
}, {
relation: 'department',
scope: {
include: {
relation: 'department'
}
}
2019-10-18 06:36:33 +00:00
}, {
relation: 'phones',
scope: {
fields: ['phone'],
order: 'typeFk ASC'
}
2019-01-29 20:45:43 +00:00
}
]
};
this.$http.get(query, {params: {filter}}).then(res => {
this.$.worker = res.data;
});
2019-01-28 15:24:45 +00:00
}
}
Controller.$inject = ['$scope', '$http'];
ngModule.component('vnWorkerSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
worker: '<'
}
});