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

77 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-11-22 09:42:05 +00:00
import ngModule from '../../module';
2019-11-22 12:46:38 +00:00
import Component from 'core/lib/component';
2019-11-22 09:42:05 +00:00
import './style.scss';
2019-11-22 12:46:38 +00:00
class Controller extends Component {
constructor($element, $, vnToken) {
super($element, $);
2019-11-22 09:42:05 +00:00
this.accessToken = vnToken.token;
this.filter = {
include: {
relation: 'dms',
scope: {
fields: [
'dmsTypeFk',
'reference',
'hardCopyNumber',
'workerFk',
'description',
'hasFile',
'file',
'created',
],
include: [{
relation: 'dmsType',
scope: {
fields: ['name']
}
},
{
relation: 'worker',
scope: {
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
},
}
}]
},
}
};
}
showWorkerDescriptor(event, workerFk) {
event.preventDefault();
event.stopImmediatePropagation();
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.workerFk = workerFk;
this.$.workerDescriptor.show();
}
showDeleteConfirm(index) {
this.dmsIndex = index;
this.$.confirm.show();
}
deleteDms(response) {
if (response === 'accept') {
const dmsFk = this.workerDms[this.dmsIndex].dmsFk;
2019-11-22 12:46:38 +00:00
const query = `WorkerDms/${dmsFk}/removeFile`;
2019-11-22 09:42:05 +00:00
this.$http.post(query).then(() => {
this.$.model.remove(this.dmsIndex);
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
}
}
2019-11-22 12:46:38 +00:00
Controller.$inject = ['$element', '$scope', 'vnToken'];
2019-11-22 09:42:05 +00:00
ngModule.component('vnWorkerDmsIndex', {
template: require('./index.html'),
controller: Controller,
});