feat: seperate dishes by menu sections

This commit is contained in:
Rainer Killinger
2022-12-06 18:10:33 +01:00
parent 33e6a76dbd
commit 400c6b8d8c
7 changed files with 110 additions and 82 deletions

97
package-lock.json generated
View File

@@ -3868,18 +3868,18 @@
}
},
"@openstapps/api": {
"version": "0.44.0",
"resolved": "https://registry.npmjs.org/@openstapps/api/-/api-0.44.0.tgz",
"integrity": "sha512-ZVSt5JiN2ESgTxrNR0IRPbeMtmXATdytAeXMbtDFeKgwFb9uJAt6jZIto9sHQHZg2kJG6Ka9ycFaMstflZjLOg==",
"version": "0.45.0",
"resolved": "https://registry.npmjs.org/@openstapps/api/-/api-0.45.0.tgz",
"integrity": "sha512-lF1TIxbtqQlRYCvSyS3EDjQiwVK7BmZ3/HQ01MhlUR1ucfvMTk1GyIPx5E8HmrKSi3Pv8shurCObSwStQJjK+Q==",
"requires": {
"@krlwlfrt/async-pool": "0.7.0",
"@openstapps/core": "0.71.0",
"@openstapps/core": "0.72.0",
"@openstapps/core-tools": "0.32.0",
"@openstapps/logger": "1.0.1",
"@openstapps/logger": "1.1.1",
"@types/cli-progress": "3.11.0",
"@types/express": "4.17.14",
"@types/morgan": "1.9.3",
"@types/node": "14.18.32",
"@types/node": "14.18.34",
"@types/traverse": "0.6.32",
"@types/uuid": "8.3.4",
"@types/wait-on": "5.3.1",
@@ -3897,35 +3897,10 @@
"wait-on": "6.0.1"
},
"dependencies": {
"@openstapps/core": {
"version": "0.71.0",
"resolved": "https://registry.npmjs.org/@openstapps/core/-/core-0.71.0.tgz",
"integrity": "sha512-5RpbidtKknzx8/zmHUfppNHH1UuJSevO4Sr444HmW9voULSnlaghzIGyjUuuAjCm/LCG30WVhKTe3/nWZAnCbg==",
"requires": {
"@openstapps/core-tools": "0.32.0",
"@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30",
"@types/json-schema": "7.0.11",
"@types/node": "14.18.24",
"fast-deep-equal": "3.1.3",
"http-status-codes": "2.2.0",
"json-patch": "0.7.0",
"json-schema": "0.4.0",
"rfdc": "1.3.0",
"ts-optchain": "0.1.8"
},
"dependencies": {
"@types/node": {
"version": "14.18.24",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.24.tgz",
"integrity": "sha512-aJdn8XErcSrfr7k8ZDDfU6/2OgjZcB2Fu9d+ESK8D7Oa5mtsv8Fa8GpcwTA0v60kuZBaalKPzuzun4Ov1YWO/w=="
}
}
},
"@types/node": {
"version": "14.18.32",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.32.tgz",
"integrity": "sha512-Y6S38pFr04yb13qqHf8uk1nHE3lXgQ30WZbv1mLliV9pt0NjvqdWttLcrOYLnXbOafknVYRHZGoMSpR9UwfYow=="
"version": "14.18.34",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.34.tgz",
"integrity": "sha512-hcU9AIQVHmPnmjRK+XUUYlILlr9pQrsqSrwov/JK1pnf3GTQowVBhx54FbvM0AU/VXGH4i3+vgXS5EguR7fysA=="
}
}
},
@@ -3967,9 +3942,9 @@
}
},
"@openstapps/core": {
"version": "0.71.1",
"resolved": "https://registry.npmjs.org/@openstapps/core/-/core-0.71.1.tgz",
"integrity": "sha512-cch/bGqIcCQz6B/TYQ1+8Wa1gKUFGP4k1Er9o+n/i9tMIlILM6IwQu5hiJ1ro8q6scn+0AwxdLQxlBQymCcBiQ==",
"version": "0.72.0",
"resolved": "https://registry.npmjs.org/@openstapps/core/-/core-0.72.0.tgz",
"integrity": "sha512-bT22CWKf0Do32FwJLf+rWxbQTHTiPbJEzm3dd3Sk5utGgNTAeFequaNea2csvCOA1dRaVrRVQ7Ed9prVdep9ow==",
"requires": {
"@openstapps/core-tools": "0.32.0",
"@types/geojson": "1.0.6",
@@ -4111,9 +4086,9 @@
}
},
"@openstapps/logger": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-1.0.1.tgz",
"integrity": "sha512-ekiqaj07NG2JKUdJBSoLTYJTz1sEtzJsGoz0F19s0h2A9fxP2duWD7bIcqfOcxj5Wggxr88zX/AK8cZG4Gda4g==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-1.1.1.tgz",
"integrity": "sha512-hPLqV0nKXgbwRxbRCAzSvQzlHfWfpDGxbo/nJLY94zbVwzpHCW3favh+MFmEV536ZvprIOLkE8DfzBUC0a83ww==",
"requires": {
"@types/node": "14.18.32",
"@types/nodemailer": "6.4.6",
@@ -4300,14 +4275,14 @@
}
},
"@types/cacheable-request": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz",
"integrity": "sha512-B3xVo+dlKM6nnKTcmm5ZtY/OL8bOAOd2Olee9M1zft65ox50OzjEHW91sDiU9j6cvW8Ejg1/Qkf4xd2kugApUA==",
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz",
"integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==",
"requires": {
"@types/http-cache-semantics": "*",
"@types/keyv": "*",
"@types/keyv": "^3.1.4",
"@types/node": "*",
"@types/responselike": "*"
"@types/responselike": "^1.0.0"
}
},
"@types/cli-progress": {
@@ -4493,11 +4468,11 @@
"dev": true
},
"@types/keyv": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-4.2.0.tgz",
"integrity": "sha512-xoBtGl5R9jeKUhc8ZqeYaRDx04qqJ10yhhXYGmJ4Jr8qKpvMsDQQrNUvF/wUJ4klOtmJeJM+p2Xo3zp9uaC3tw==",
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz",
"integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==",
"requires": {
"keyv": "*"
"@types/node": "*"
}
},
"@types/leaflet": {
@@ -11007,9 +10982,9 @@
"dev": true
},
"joi": {
"version": "17.6.4",
"resolved": "https://registry.npmjs.org/joi/-/joi-17.6.4.tgz",
"integrity": "sha512-tPzkTJHZQjSFCc842QpdVpOZ9LI2txApboNUbW70qgnRB14Lzl+oWQOPdF2N4yqyiY14wBGe8lc7f/2hZxbGmw==",
"version": "17.7.0",
"resolved": "https://registry.npmjs.org/joi/-/joi-17.7.0.tgz",
"integrity": "sha512-1/ugc8djfn93rTE3WRKdCzGGt/EtiYKxITMO4Wiv6q5JL1gl9ePt4kBsl1S499nbosspfctIQTpYIhSmHA3WAg==",
"requires": {
"@hapi/hoek": "^9.0.0",
"@hapi/topo": "^5.0.0",
@@ -11457,9 +11432,9 @@
}
},
"keyv": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.0.tgz",
"integrity": "sha512-2YvuMsA+jnFGtBareKqgANOEKe1mk3HKiXu2fRmAfyxG0MJAywNhi5ttWA3PMjl4NmpyjZNbFifR2vNjW1znfA==",
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.2.tgz",
"integrity": "sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g==",
"requires": {
"json-buffer": "3.0.1"
}
@@ -11988,9 +11963,9 @@
"dev": true
},
"loupe": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz",
"integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==",
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz",
"integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==",
"requires": {
"get-func-name": "^2.0.0"
}
@@ -17507,9 +17482,9 @@
},
"dependencies": {
"rxjs": {
"version": "7.5.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz",
"integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==",
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.6.0.tgz",
"integrity": "sha512-DDa7d8TFNUalGC9VqXvQ1euWNN7sc63TrUCuM9J998+ViviahMIjKSOU7rfcgFOF+FCD71BhDRv4hrFz+ImDLQ==",
"requires": {
"tslib": "^2.1.0"
}

View File

@@ -84,9 +84,9 @@
"@ionic/storage-angular": "3.0.6",
"@ngx-translate/core": "14.0.0",
"@ngx-translate/http-loader": "7.0.0",
"@openstapps/api": "0.44.0",
"@openstapps/api": "0.45.0",
"@openstapps/configuration": "0.33.0",
"@openstapps/core": "0.71.1",
"@openstapps/core": "0.72.0",
"@transistorsoft/capacitor-background-fetch": "1.0.0",
"capacitor-secure-storage-plugin": "0.8.0",
"cordova-plugin-calendar": "5.1.6",

View File

@@ -22,6 +22,7 @@ import {Router} from '@angular/router';
import {Subscription} from 'rxjs';
import {IonRouterOutlet} from '@ionic/angular';
import {DataRoutingService} from '../../../../data-routing.service';
import {groupBy} from 'src/app/_helpers/collections/group-by';
/**
* TODO
@@ -36,8 +37,9 @@ export class PlaceMensaDetailComponent implements AfterViewInit, OnDestroy {
/**
* Map of dishes for each day
*/
// eslint-disable-next-line unicorn/no-null
dishes: Promise<Record<SCISO8601Date, SCDish[]>> | null = null;
dishes: Promise<Record<SCISO8601Date, Record<string, SCDish[]>>> | null =
// eslint-disable-next-line unicorn/no-null
null;
/**
* number of days to display mensa menus for
@@ -79,15 +81,6 @@ export class PlaceMensaDetailComponent implements AfterViewInit, OnDestroy {
* TODO
*/
ngAfterViewInit() {
this.dishes = this.mensaService.getAllDishes(this.item, this.displayRange);
this.dishes.then(result => {
for (const [key, value] of Object.entries(result)) {
if (value.length === 0) {
delete result[key];
}
}
this.selectedDay = Object.keys(result)[0];
});
if (!this.openAsModal) {
this.subscriptions.push(
this.dataRoutingService.itemSelectListener().subscribe(item => {
@@ -95,6 +88,36 @@ export class PlaceMensaDetailComponent implements AfterViewInit, OnDestroy {
}),
);
}
const dishesByDay = this.mensaService.getAllDishes(
this.item,
this.displayRange,
);
dishesByDay.then(result => {
for (const [key, value] of Object.entries(result)) {
if (value.length === 0) {
delete result[key];
}
}
this.selectedDay = Object.keys(result)[0];
});
this.dishes = new Promise(async (resolve, reject) => {
try {
const dishesBySections: Record<string, Record<string, SCDish[]>> = {};
for (const [key, value] of Object.entries(await dishesByDay)) {
dishesBySections[key] = groupBy(
value,
x => x.menuSection?.name ?? '',
);
}
resolve(dishesBySections);
} catch {
// eslint-disable-next-line unicorn/no-null
reject(null);
}
});
}
/**

View File

@@ -16,14 +16,32 @@
</ion-segment>
<ng-container [ngSwitch]="selectedDay">
<ng-container *ngFor="let date of dishes | keyvalue">
<ion-list *ngSwitchCase="date.key">
<ng-container *ngFor="let dish of date.value; index as i">
<stapps-data-list-item
[item]="dish"
[hideThumbnail]="true"
></stapps-data-list-item>
</ng-container>
</ion-list>
<ng-container *ngIf="(date.value | json) !== '{}'; else empty">
<ion-list *ngSwitchCase="date.key">
<ng-container *ngFor="let section of date.value | keyvalue">
<ion-list-header
*ngIf="section.value[0].menuSection"
lines="inset"
>
<ion-label class="title">
{{
'data.types.dish.detail.' +
section.value[0].menuSection.name
| translate
| titlecase
}}
{{ section.value[0].menuSection.servingHours }}
</ion-label>
</ion-list-header>
<ng-container *ngFor="let dish of section.value; index as j">
<stapps-data-list-item
[item]="dish"
[hideThumbnail]="true"
></stapps-data-list-item>
</ng-container>
</ng-container>
</ion-list>
</ng-container>
</ng-container>
</ng-container>
</ng-container>

View File

@@ -17,3 +17,9 @@ ion-segment {
flex: 1 0 100px;
}
}
ion-list-header {
ion-label {
color: var(--ion-color-medium-shade);
}
}

View File

@@ -150,6 +150,9 @@
"CHARACTERISTICS": "Zutaten",
"EMPTY_DISHES": "Keine Angebote verfügbar",
"detail": {
"breakfast": "Frühstück",
"dinner": "Abendessen",
"lunch": "Mittagessen",
"AVG_NUTRITION_INFO": "Durchschnittliche Nährwertangaben",
"CALORIES": "Brennwert",
"FAT_TOTAL": "Fett",

View File

@@ -150,6 +150,9 @@
"CHARACTERISTICS": "Ingredients",
"EMPTY_DISHES": "No Offers Available",
"detail": {
"breakfast": "Breakfast",
"dinner": "Dinner",
"lunch": "Lunch",
"AVG_NUTRITION_INFO": "Average Nutrition Facts",
"CALORIES": "Calories",
"FAT_TOTAL": "Fat",