salix/modules/travel/front/thermograph/index/index.js

52 lines
1.3 KiB
JavaScript

import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
constructor($element, $, vnFile) {
super($element, $);
this.vnFile = vnFile;
this.filter = {
include:
{relation: 'warehouse',
scope: {
fields: ['id', 'name']
}
}
};
}
showDeleteConfirm(index) {
this.thermographIndex = index;
this.$.confirm.show();
}
deleteThermograph() {
const data = this.travelThermographs;
const thermographId = data[this.thermographIndex].id;
const query = `Travels/deleteThermograph?id=${thermographId}`;
this.$http.delete(query).then(() => {
this.vnApp.showSuccess(this.$t('Thermograph deleted'));
this.$.model.remove(this.thermographIndex);
this.thermographIndex = null;
});
}
downloadFile(dmsId) {
this.vnFile.download(`api/dms/${dmsId}/downloadFile`);
}
}
Controller.$inject = ['$element', '$scope', 'vnFile'];
ngModule.component('vnTravelThermographIndex', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnTravelCard'
},
bindings: {
travel: '<'
}
});