79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
import ngModule from '../../module';
|
|
import './style.scss';
|
|
|
|
class Controller {
|
|
constructor($stateParams, $scope, $http, $translate, vnToken, vnApp) {
|
|
this.$stateParams = $stateParams;
|
|
this.$ = $scope;
|
|
this.$http = $http;
|
|
this.$translate = $translate;
|
|
this.accessToken = vnToken.token;
|
|
this.vnApp = vnApp;
|
|
this.filter = {
|
|
include: {
|
|
relation: 'dms',
|
|
scope: {
|
|
fields: [
|
|
'dmsTypeFk',
|
|
'workerFk',
|
|
'reference',
|
|
'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.ticketDms[this.dmsIndex].dmsFk;
|
|
const query = `/api/TicketDms/${dmsFk}/removeFile`;
|
|
this.$http.post(query).then(() => {
|
|
this.$.model.remove(this.dmsIndex);
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnToken', 'vnApp'];
|
|
|
|
ngModule.component('vnTicketDmsIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
});
|