salix/modules/worker/front/descriptor-popover/index.js

95 lines
2.3 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
constructor($element, $scope, $http, $timeout, $q) {
super($element, $scope);
this.$timeout = $timeout;
this.$http = $http;
this.$q = $q;
this.worker = null;
}
set userId(id) {
if (id == this._userId) return;
this._userId = id;
this.worker = null;
this.loadData();
}
get userId() {
return this._userId;
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this._quicklinks);
}
get quicklinks() {
return this._quicklinks;
}
show() {
this.$.popover.parent = this.parent;
this.$.popover.show();
}
loadData() {
let query = `api/Workers/findOne`;
let filter = {
where: {
userFk: this._userId
},
include: [
{
relation: 'user',
2019-03-15 11:58:26 +00:00
scope: {
fields: ['name'],
include: {
relation: 'emailUser',
scope: {
fields: ['email']
}
}
}
},
{
relation: 'client',
scope: {fields: ['fi']}
2019-03-15 11:58:26 +00:00
},
{
relation: 'sip',
scope: {fields: ['extension']}
2019-03-15 11:58:26 +00:00
},
{
relation: 'department',
scope: {
include: {
relation: 'department'
}
}
}
]
};
this.$http.get(query, {params: {filter}}).then(res => {
this.worker = res.data;
this.$.$applyAsync(() => {
this.$.popover.relocate();
});
});
}
}
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
ngModule.component('vnWorkerDescriptorPopover', {
template: require('./index.html'),
controller: Controller,
bindings: {
userId: '<',
quicklinks: '<'
}
});