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

45 lines
1.1 KiB
JavaScript
Raw Normal View History

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