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

36 lines
901 B
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-10-09 22:47:29 +00:00
if (!id) return;
this.$http.delete(`${this.path}/${id}`)
.then(() => this.refresh());
2019-09-25 18:06:42 +00:00
}
}
ngModule.component('vnZoneExclusions', {
template: require('./index.html'),
controller: Controller
});