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

96 lines
2.7 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;
if (value)
this.getIsExcluded();
}
2019-10-21 12:21:52 +00:00
getIsExcluded() {
this.$http.get(`WorkerDisableExcludeds/${this.entity.id}/exists`).then(data => {
this.workerExcluded = data.data.exists;
});
}
handleExcluded() {
if (this.workerExcluded)
this.$http.delete(`WorkerDisableExcludeds/${this.entity.id}`);
else
this.$http.post(`WorkerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
this.workerExcluded = !this.workerExcluded;
2022-10-05 09:52:14 +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() {
2023-01-16 14:18:24 +00:00
const timestamp = Date.vnNew().getTime();
2020-11-27 12:10:39 +00:00
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: '<'
}
});