2019-02-15 11:39:21 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:09:50 +00:00
|
|
|
set userId(id) {
|
|
|
|
if (id == this._userId) return;
|
2019-02-15 11:39:21 +00:00
|
|
|
|
2019-02-19 14:09:50 +00:00
|
|
|
this._userId = id;
|
2019-02-15 11:39:21 +00:00
|
|
|
this.worker = null;
|
|
|
|
this.loadData();
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:09:50 +00:00
|
|
|
get userId() {
|
|
|
|
return this._userId;
|
2019-02-15 11:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
2019-02-19 14:09:50 +00:00
|
|
|
let query = `api/Workers/findOne`;
|
2019-02-15 11:39:21 +00:00
|
|
|
let filter = {
|
2019-02-19 14:09:50 +00:00
|
|
|
where: {
|
|
|
|
userFk: this._userId
|
|
|
|
},
|
2019-02-15 11:39:21 +00:00
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'user',
|
|
|
|
scope: {fields: ['name', 'email']}
|
|
|
|
}, {
|
|
|
|
relation: 'client',
|
|
|
|
scope: {fields: ['fi']}
|
|
|
|
}, {
|
|
|
|
relation: 'sip',
|
|
|
|
scope: {fields: ['extension']}
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
|
|
|
|
|
|
|
|
ngModule.component('vnWorkerDescriptorPopover', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2019-02-19 14:09:50 +00:00
|
|
|
userId: '<',
|
2019-02-15 11:39:21 +00:00
|
|
|
quicklinks: '<'
|
|
|
|
}
|
|
|
|
});
|