salix/modules/agency/front/exclusions/index.js

45 lines
1.1 KiB
JavaScript

import ngModule from '../module';
import Section from 'core/lib/section';
class Controller extends Section {
constructor($el, $, $t, $http, $state) {
super($el, $, $t, $http, $state);
this.$http.get(`/api/Zones/${this.$stateParams.id}/events`)
.then(res => this.$.events = res.data);
this.path = `/api/Zones/${this.$stateParams.id}/exclusions`;
this.refresh();
}
refresh() {
this.$http.get(this.path)
.then(res => this.$.data = res.data);
}
onCreate($days) {
this.$http.post(this.path, {day: $days[0]})
.then(() => this.refresh());
}
onDelete(id) {
this.$.confirm.show();
this.deleteId = id;
}
delete(response) {
if (response != 'ACCEPT') return;
if (!this.deleteId) return;
this.$http.delete(`${this.path}/${this.deleteId}`)
.then(() => {
this.refresh();
this.deleteId = null;
});
}
}
ngModule.component('vnZoneExclusions', {
template: require('./index.html'),
controller: Controller
});