1781-zoneHoliday #994

Merged
joan merged 49 commits from 1781-zoneHoliday into dev 2022-08-03 06:41:31 +00:00
2 changed files with 32 additions and 31 deletions
Showing only changes of commit dd65f4a468 - Show all commits

View File

@ -202,7 +202,8 @@
vn-id="excludeDialog"
on-response="$ctrl.onExcludeResponse($response)"
message="{{$ctrl.isNew ? 'Exclusion' : 'Edit exclusion'}}"
on-open="$ctrl.onSearch($params)">
on-open="$ctrl.onSearch($params)"
on-close="$ctrl.resetExclusions()">
<tpl-body>
<vn-date-picker
label="Day"

View File

@ -7,8 +7,8 @@ class Controller extends Section {
super($element, $);
this.vnWeekDays = vnWeekDays;
this.editMode = 'exclude';
this.exclusions = null;
this.exclusionsGeo = null;
this.exclusions = [];
vicent marked this conversation as resolved Outdated

this is undefined anyways

this is undefined anyways
this.exclusionsGeo = [];
}
$onInit() {
@ -64,28 +64,31 @@ class Controller extends Section {
onSelection(days, type, weekday, events, exclusions, exclusionsGeo) {
if (this.editMode == 'include') {
if (events.length)
this.editInclusion(events[0]);
else
this.createInclusion(type, days, weekday);
} else {
return this.editInclusion(events[0]);
return this.createInclusion(type, days, weekday);
}
if (this.editMode == 'exclude') {
if (exclusionsGeo.length) {
this.exclusionsGeo = exclusionsGeo;
this.editExclusion();
} else if (exclusions.length) {
return this.editExclusion();
}
if (exclusions.length) {
this.exclusions = exclusions;
this.editExclusion();
} else
this.createExclusion(days);
return this.editExclusion();
}
return this.createExclusion(days);
}
}
editExclusion() {
this.isNew = false;
if (this.exclusionsGeo && this.exclusionsGeo.length) {
if (this.exclusionsGeo.length) {
this.excludeSelected = angular.copy(this.exclusionsGeo[0]);
this.excludeSelected.type = 'specificLocations';
}
if (this.exclusions && this.exclusions.length) {
if (this.exclusions.length) {
this.excludeSelected = angular.copy(this.exclusions[0]);
this.excludeSelected.type = 'all';
}
@ -179,14 +182,12 @@ class Controller extends Section {
case 'accept': {
if (type == 'all')
return this.exclusionCreate();
else
return this.exclusionGeoCreate();
return this.exclusionGeoCreate();
}
case 'delete':
if (type == 'all')
return this.exclusionDelete(this.exclusions);
if (type == 'specificLocations')
return this.exclusionGeoDelete(this.exclusionsGeo);
return this.exclusionGeoDelete(this.exclusionsGeo);
}
}
@ -214,12 +215,10 @@ class Controller extends Section {
if (this.isNew)
req = this.$http.post(this.exclusionsPath, [{dated}]);
else
if (!this.isNew)
req = this.$http.put(`${this.exclusionsPath}/${excludeSelected.id}`, {dated});
return req.then(() => {
this.excludeSelected = null;
this.isNew = null;
this.refresh();
});
}
@ -268,46 +267,47 @@ class Controller extends Section {
}
}
return req.then(() => {
this.excludeSelected = null;
this.isNew = null;
this.refresh();
});
}
exclusionDelete(exclusions) {
let reqs = [];
const reqs = [];
for (let exclusion of exclusions) {
if (!exclusion.id) continue;
let path = `${this.exclusionsPath}/${exclusion.id}`;
const path = `${this.exclusionsPath}/${exclusion.id}`;
reqs.push(this.$http.delete(path));
}
this.$q.all(reqs)
.then(() => {
this.excludeSelected = null;
this.exclusions = null;
this.refresh();
});
}
exclusionGeoDelete(exclusionsGeo) {
let reqs = [];
const reqs = [];
for (let exclusionGeo of exclusionsGeo) {
if (!exclusionGeo.id) continue;
let path = `${this.exclusionsPath}/${exclusionGeo.zoneExclusionFk}`;
const path = `${this.exclusionsPath}/${exclusionGeo.zoneExclusionFk}`;
reqs.push(this.$http.delete(path));
}
this.$q.all(reqs)
.then(() => {
this.excludeSelected = null;
this.exclusionsGeo = null;
this.refresh();
});
}
resetExclusions() {
this.excludeSelected = null;
this.isNew = null;
this.exclusions = [];
this.exclusionsGeo = [];
}
set excludeSearch(value) {
this._excludeSearch = value;
if (!value) this.onSearch();