other catering can be selected
This commit is contained in:
1 parent
4b090939d8
commit
c3bee1e8f2
5 files changed
+55
-56
No files matched your search
@@ -8,6 +8,7 @@ export enum Timeframe {
|
||||
export enum Restaurant {
|
||||
OASE = 0,
|
||||
Timeout = 1,
|
||||
Other = 2,
|
||||
}
|
||||
|
||||
export interface TimeframeSelection {
|
||||
|
||||
@@ -43,21 +43,12 @@ export class CoronarestaurantPage implements OnInit {
|
||||
* @param frame timeframe of restaurant visit
|
||||
*/
|
||||
public selectTimeframe(frame: Timeframe): void {
|
||||
if (!this.cateringService.getSelection(this.date)) {
|
||||
this.cateringService.selectTimeframeAsync(this.restaurant, frame, this.date)
|
||||
.then(_ => {
|
||||
this.loadQueues();
|
||||
this.loadRecommendedNb();
|
||||
this.loadSelection();
|
||||
}).catch(error => SoapApiHelper.handleError(this.toastController, error));
|
||||
} else {
|
||||
this.cateringService.changeTimeframeAsync(this.restaurant, frame, this.date)
|
||||
.then(_ => {
|
||||
this.loadQueues();
|
||||
this.loadRecommendedNb();
|
||||
this.loadSelection();
|
||||
}).catch(error => SoapApiHelper.handleError(this.toastController, error));
|
||||
}
|
||||
this.cateringService.selectTimeframeAsync(this.restaurant, frame, this.date)
|
||||
.then(_ => {
|
||||
this.loadQueues();
|
||||
this.loadRecommendedNb();
|
||||
this.loadSelection();
|
||||
}).catch(error => SoapApiHelper.handleError(this.toastController, error));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</ion-button>
|
||||
<ion-button fill="outline" color="dark" (click)="presentRestaurantModal(1)">Timeout
|
||||
</ion-button>
|
||||
<ion-button fill="outline" color="dark" (click)="goToSlide(0)">Other
|
||||
<ion-button fill="outline" color="dark" (click)="selectOtherCatering()">Other
|
||||
</ion-button>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
@@ -43,7 +43,7 @@ export class PsicheckinPage implements OnInit {
|
||||
this.checkSelections();
|
||||
}
|
||||
|
||||
public selectDay(day) {
|
||||
public selectDay(day: string) {
|
||||
let today = new Date(new Date().toDateString());
|
||||
if (day === 'today') {
|
||||
this.selectedDate = today;
|
||||
@@ -52,7 +52,7 @@ export class PsicheckinPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
public goToSlide(slide) {
|
||||
public goToSlide(slide: number) {
|
||||
this.slides.slideTo(slide, 500);
|
||||
this.slides.lockSwipeToPrev(false);
|
||||
}
|
||||
@@ -93,7 +93,6 @@ export class PsicheckinPage implements OnInit {
|
||||
return await modal.present();
|
||||
}
|
||||
|
||||
|
||||
public checkSelections() {
|
||||
let today = new Date();
|
||||
let tomorrow = new Date(Date.now() + 24 * 60 * 60 * 1000);
|
||||
@@ -115,6 +114,12 @@ export class PsicheckinPage implements OnInit {
|
||||
.catch(error => SoapApiHelper.handleError(this.toastController, error));
|
||||
}
|
||||
|
||||
public selectOtherCatering(): void {
|
||||
this.cateringService.selectOtherAsync(this.selectedDate)
|
||||
.then(_ => this.goToSlide(0))
|
||||
.catch(error => SoapApiHelper.handleError(this.toastController, error));
|
||||
}
|
||||
|
||||
async presentHelpModal() {
|
||||
const modal = await this.modalController.create({
|
||||
component: CoronahelppageComponent
|
||||
|
||||
@@ -17,45 +17,23 @@ export class CoronaCateringService {
|
||||
/**
|
||||
* Sets a timeframe and restaurant selection for the specified date.
|
||||
*
|
||||
* @param restaruant restaurant
|
||||
* @param timeframe timeframe of visit
|
||||
* @param date date of visit
|
||||
*/
|
||||
public async selectTimeframeAsync(restaruant: Restaurant, timeframe: Timeframe, date: Date): Promise<void> {
|
||||
date = new Date(date.toDateString()); // make sure hours, minutes and seconds are removed
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.isTimeframeSelected(date)) {
|
||||
reject('You already selected a timeframe for this date.');
|
||||
return;
|
||||
}
|
||||
this.addGuest(restaruant, timeframe, date)
|
||||
.subscribe(
|
||||
_ => {
|
||||
this.saveSelection(restaruant, timeframe, date);
|
||||
resolve();
|
||||
},
|
||||
error => reject(error)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the timeframe and restaurant selection of a specific date.
|
||||
*
|
||||
* @param restaurant restaurant
|
||||
* @param timeframe timeframe of visit
|
||||
* @param date date of visit
|
||||
*/
|
||||
public async changeTimeframeAsync(restaurant: Restaurant, timeframe: Timeframe, date: Date): Promise<void> {
|
||||
public async selectTimeframeAsync(restaurant: Restaurant, timeframe: Timeframe, date: Date): Promise<void> {
|
||||
date = new Date(date.toDateString()); // make sure hours, minutes and seconds are removed
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.isTimeframeSelected(date)) {
|
||||
reject('Can not change selection. No timeframe is selected yet for this date.');
|
||||
return;
|
||||
}
|
||||
let selection = this.getSelection(date);
|
||||
this.removeGuest(selection.restaurant, selection.timeframe, selection.date)
|
||||
.subscribe(
|
||||
_ => {
|
||||
this.addGuest(restaurant, timeframe, date)
|
||||
.subscribe(_ => {
|
||||
this.saveSelection(restaurant, timeframe, date);
|
||||
resolve();
|
||||
}, error => reject(error));
|
||||
} else {
|
||||
let selection = this.getSelection(date);
|
||||
this.removeGuest(selection.restaurant, selection.timeframe, selection.date)
|
||||
.subscribe(_ => {
|
||||
this.addGuest(restaurant, timeframe, date)
|
||||
.subscribe(
|
||||
__ => {
|
||||
@@ -65,8 +43,30 @@ export class CoronaCateringService {
|
||||
error => reject(error)
|
||||
);
|
||||
},
|
||||
error => reject(error)
|
||||
);
|
||||
error => reject(error)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the other selection for today.
|
||||
*
|
||||
* @param date date of travel
|
||||
*/
|
||||
public selectOtherAsync(date: Date): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (this.isTimeframeSelected(date)) {
|
||||
let selection = this.getSelection(date);
|
||||
this.removeGuest(selection.restaurant, selection.timeframe, date)
|
||||
.subscribe(_ => {
|
||||
this.saveSelection(Restaurant.Other, Timeframe.slot_11_00_11_45, date);
|
||||
resolve();
|
||||
}, error => reject(error));
|
||||
} else {
|
||||
this.saveSelection(Restaurant.Other, Timeframe.slot_11_00_11_45, date);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -130,8 +130,10 @@ export class CoronaCateringService {
|
||||
*
|
||||
* @param date date of visit
|
||||
*/
|
||||
private isTimeframeSelected(date: Date): boolean {
|
||||
return this.loadSelections().findIndex(selection => selection.date.getTime() === date.getTime()) >= 0;
|
||||
public isTimeframeSelected(date: Date): boolean {
|
||||
return this.loadSelections()
|
||||
.filter(row => row.restaurant != Restaurant.Other)
|
||||
.findIndex(selection => selection.date.getTime() === date.getTime()) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user