2019-09-25 18:06:42 +00:00
|
|
|
import ngModule from '../module';
|
2019-10-01 11:45:43 +00:00
|
|
|
import Section from 'core/lib/section';
|
2019-09-25 18:06:42 +00:00
|
|
|
|
2019-10-01 11:45:43 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
constructor($el, $, $t, $http, $state) {
|
|
|
|
super($el, $, $t, $http, $state);
|
2019-09-25 18:06:42 +00:00
|
|
|
|
2019-10-01 11:45:43 +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);
|
|
|
|
}
|
|
|
|
|
2019-10-01 11:45:43 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-10-01 11:45:43 +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
|
|
|
|
});
|