96 lines
2.7 KiB
JavaScript
96 lines
2.7 KiB
JavaScript
import ngModule from '../module';
|
|
import Descriptor from 'salix/components/descriptor';
|
|
|
|
class Controller extends Descriptor {
|
|
constructor($element, $, $rootScope) {
|
|
super($element, $);
|
|
this.$rootScope = $rootScope;
|
|
}
|
|
|
|
get worker() {
|
|
return this.entity;
|
|
}
|
|
|
|
set worker(value) {
|
|
this.entity = value;
|
|
|
|
if (value)
|
|
this.getIsExcluded();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
return this.getData(`Workers/${this.id}`, {filter})
|
|
.then(res => this.entity = res.data);
|
|
}
|
|
|
|
onUploadResponse() {
|
|
const timestamp = Date.vnNew().getTime();
|
|
const src = this.$rootScope.imagePath('user', '520x520', this.worker.id);
|
|
const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id);
|
|
const newSrc = `${src}&t=${timestamp}`;
|
|
const newZoomSrc = `${zoomSrc}&t=${timestamp}`;
|
|
|
|
this.$.photo.setAttribute('src', newSrc);
|
|
this.$.photo.setAttribute('zoom-image', newZoomSrc);
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$element', '$scope', '$rootScope'];
|
|
|
|
ngModule.vnComponent('vnWorkerDescriptor', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
worker: '<'
|
|
}
|
|
});
|