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() {
|
2020-04-30 10:48:52 +00:00
|
|
|
return this.entity;
|
2019-10-21 12:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set worker(value) {
|
2020-04-30 10:48:52 +00:00
|
|
|
this.entity = value;
|
2022-10-18 08:25:54 +00:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
this.getIsExcluded();
|
2020-04-30 10:48:52 +00:00
|
|
|
}
|
2019-10-21 12:21:52 +00:00
|
|
|
|
2022-10-06 08:18:08 +00:00
|
|
|
get excluded() {
|
|
|
|
return this.entity.excluded;
|
|
|
|
}
|
|
|
|
|
|
|
|
set excluded(value) {
|
|
|
|
this.entity.excluded = value;
|
|
|
|
}
|
|
|
|
|
2022-10-18 08:25:54 +00:00
|
|
|
getIsExcluded() {
|
|
|
|
this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => {
|
|
|
|
this.excluded = data.data.exists;
|
|
|
|
});
|
2022-10-06 08:18:08 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 08:25:54 +00:00
|
|
|
handleExcluded() {
|
|
|
|
if (this.excluded) {
|
|
|
|
this.$http.delete(`workerDisableExcludeds/${this.entity.id}`);
|
|
|
|
this.excluded = false;
|
|
|
|
} else {
|
|
|
|
this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
|
|
|
|
this.excluded = true;
|
|
|
|
}
|
2022-10-05 09:52:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48: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
|
|
|
};
|
2020-04-30 10:48: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: '<'
|
|
|
|
}
|
|
|
|
});
|