2019-02-15 11:39:21 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Component from 'core/lib/component';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
2020-03-18 11:55:22 +00:00
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2019-02-15 11:39:21 +00:00
|
|
|
this.worker = null;
|
2019-05-07 09:32:35 +00:00
|
|
|
this._quicklinks = {};
|
2019-02-15 11:39:21 +00:00
|
|
|
}
|
|
|
|
|
2019-04-25 06:28:23 +00:00
|
|
|
set workerFk(workerFk) {
|
|
|
|
if (workerFk == this._workerFk) return;
|
2019-02-15 11:39:21 +00:00
|
|
|
|
2019-04-25 06:28:23 +00:00
|
|
|
this._workerFk = workerFk;
|
2019-02-15 11:39:21 +00:00
|
|
|
this.worker = null;
|
|
|
|
this.loadData();
|
|
|
|
}
|
|
|
|
|
2019-04-25 06:28:23 +00:00
|
|
|
get workerFk() {
|
|
|
|
return this._workerFk;
|
2019-02-15 11:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
|
|
|
}
|
|
|
|
|
2019-05-07 09:32:35 +00:00
|
|
|
set quicklinks(value = {}) {
|
|
|
|
Object.keys(value).forEach(key => {
|
|
|
|
this._quicklinks[key] = value[key];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-15 11:39:21 +00:00
|
|
|
show() {
|
|
|
|
this.$.popover.parent = this.parent;
|
|
|
|
this.$.popover.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
loadData() {
|
2019-10-24 22:53:53 +00:00
|
|
|
let query = `Workers/findOne`;
|
2019-02-15 11:39:21 +00:00
|
|
|
let filter = {
|
2019-02-19 14:09:50 +00:00
|
|
|
where: {
|
2019-04-25 06:28:23 +00:00
|
|
|
id: this._workerFk
|
2019-02-19 14:09:50 +00:00
|
|
|
},
|
2019-02-15 11:39:21 +00:00
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'user',
|
2019-03-15 11:58:26 +00:00
|
|
|
scope: {
|
|
|
|
fields: ['name'],
|
|
|
|
include: {
|
|
|
|
relation: 'emailUser',
|
|
|
|
scope: {
|
|
|
|
fields: ['email']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2019-02-15 11:39:21 +00:00
|
|
|
relation: 'client',
|
|
|
|
scope: {fields: ['fi']}
|
2019-03-15 11:58:26 +00:00
|
|
|
},
|
|
|
|
{
|
2019-02-15 11:39:21 +00:00
|
|
|
relation: 'sip',
|
|
|
|
scope: {fields: ['extension']}
|
2019-03-15 11:58:26 +00:00
|
|
|
},
|
|
|
|
{
|
2019-02-19 14:09:50 +00:00
|
|
|
relation: 'department',
|
|
|
|
scope: {
|
|
|
|
include: {
|
|
|
|
relation: 'department'
|
|
|
|
}
|
|
|
|
}
|
2019-02-15 11:39:21 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$http.get(query, {params: {filter}}).then(res => {
|
|
|
|
this.worker = res.data;
|
|
|
|
this.$.$applyAsync(() => {
|
|
|
|
this.$.popover.relocate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnWorkerDescriptorPopover', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2019-04-25 06:28:23 +00:00
|
|
|
workerFk: '<',
|
2019-02-15 11:39:21 +00:00
|
|
|
quicklinks: '<'
|
|
|
|
}
|
|
|
|
});
|