import ngModule from '../../module'; import Component from 'core/lib/component'; import './style.scss'; class Controller extends Component { constructor($element, $, vnFile) { super($element, $); this.vnFile = vnFile; this.filter = { include: { relation: 'dms', scope: { fields: [ 'dmsTypeFk', 'reference', 'hardCopyNumber', 'workerFk', 'description', 'hasFile', 'file', 'created', 'companyFk', 'warehouseFk', ], include: [ { relation: 'dmsType', scope: { fields: ['name'], }, }, { relation: 'worker', scope: { fields: ['id'], include: { relation: 'user', scope: { fields: ['name'], }, }, }, }, ], }, }, }; } deleteDms(index) { const workerDmsId = this.workerDms[index].dmsFk; return this.$http.post(`WorkerDms/${workerDmsId}/removeFile`) .then(() => { this.$.model.remove(index); this.vnApp.showSuccess(this.$t('Data saved!')); }); } downloadFile(dmsId, isDocuware) { if (isDocuware) return this.vnFile.download(`api/workerDms/${dmsId}/docuwareDownload`); this.vnFile.download(`api/workerDms/${dmsId}/downloadFile`); } async openDocuware() { const url = await this.vnApp.getUrl(`WebClient`, 'docuware'); if (url) window.open(url).focus(); } } Controller.$inject = ['$element', '$scope', 'vnFile']; ngModule.vnComponent('vnWorkerDmsIndex', { template: require('./index.html'), controller: Controller, });