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

78 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-01-28 15:24:45 +00:00
import ngModule from '../module';
2020-04-25 09:50:04 +00:00
import Descriptor from 'salix/components/descriptor';
2019-01-28 15:24:45 +00:00
2020-04-25 09:50:04 +00:00
class Controller extends Descriptor {
2020-11-27 12:10:39 +00:00
constructor($element, $, $rootScope) {
super($element, $);
this.$rootScope = $rootScope;
}
2019-10-21 12:21:52 +00:00
get worker() {
return this.entity;
2019-10-21 12:21:52 +00:00
}
set worker(value) {
this.entity = value;
}
2019-10-21 12:21:52 +00:00
loadData() {
const filter = {
include: [
{
relation: 'user',
scope: {
fields: ['name'],
include: {
relation: 'emailUser',
scope: {
fields: ['email']
}
}
}
}, {
relation: 'client',
scope: {
fields: ['fi']
}
}, {
relation: 'sip',
scope: {
fields: ['extension']
}
}, {
relation: 'department',
scope: {
include: {
relation: 'department'
}
}
}
]
2019-10-21 12:21:52 +00:00
};
return this.getData(`Workers/${this.id}`, {filter})
.then(res => this.entity = res.data);
2019-10-21 12:21:52 +00:00
}
2020-11-27 12:10:39 +00:00
onUploadResponse() {
const timestamp = new Date().getTime();
const src = this.$rootScope.imagePath('user', '520x520', this.worker.id);
2021-02-04 17:28:58 +00:00
const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id);
2020-11-27 12:10:39 +00:00
const newSrc = `${src}&t=${timestamp}`;
const newZoomSrc = `${zoomSrc}&t=${timestamp}`;
this.$.photo.setAttribute('src', newSrc);
this.$.photo.setAttribute('zoom-image', newZoomSrc);
}
2019-10-21 12:21:52 +00:00
}
2020-11-27 12:10:39 +00:00
Controller.$inject = ['$element', '$scope', '$rootScope'];
2020-04-25 09:50:04 +00:00
ngModule.vnComponent('vnWorkerDescriptor', {
2019-01-28 15:24:45 +00:00
template: require('./index.html'),
2019-10-21 12:21:52 +00:00
controller: Controller,
2019-01-28 15:24:45 +00:00
bindings: {
worker: '<'
}
});