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

48 lines
1.3 KiB
JavaScript

import ngModule from '../../module';
import './style.scss';
import Component from 'core/lib/component';
class Controller extends Component {
constructor($element, $, vnToken) {
super($element, $);
this.accessToken = vnToken.token;
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.$translate.instant('Thermograph deleted'));
this.$.model.remove(this.thermographIndex);
this.thermographIndex = null;
});
}
}
Controller.$inject = ['$element', '$scope', 'vnToken'];
ngModule.component('vnTravelThermographIndex', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnTravelCard'
},
bindings: {
travel: '<'
}
});