36 lines
901 B
JavaScript
36 lines
901 B
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) {
|
|
if (!id) return;
|
|
this.$http.delete(`${this.path}/${id}`)
|
|
.then(() => this.refresh());
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnZoneExclusions', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|