mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-10 02:42:47 +00:00
feat: show menu for multiple days for canteens and cafes
Closes #19, #79
This commit is contained in:
committed by
Jovan Krunić
parent
66b8720da0
commit
3c079cd189
@@ -14,10 +14,13 @@
|
||||
*/
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {SCAcademicEvent, SCArticle, SCBook, SCBuilding, SCCatalog,
|
||||
SCDateSeries, SCDish, SCFavorite, SCMessage, SCPerson, SCRoom,
|
||||
SCThing, SCThingOriginType, SCThingType, SCToDo, SCToDoPriority} from '@openstapps/core';
|
||||
import {
|
||||
SCAcademicEvent, SCArticle, SCBook, SCBuilding, SCCatalog,
|
||||
SCDateSeries, SCDish, SCFavorite, SCMessage, SCPerson, SCRoom, SCSearchFilter,
|
||||
SCThing, SCThingOriginType, SCThingType, SCToDo, SCToDoPriority,
|
||||
} from '@openstapps/core';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {checkFilter} from '../fakesearch/filters';
|
||||
import {sampleResources} from './resources/test-resources';
|
||||
|
||||
// tslint:disable:no-magic-numbers
|
||||
@@ -339,7 +342,7 @@ const sampleDateSeries: SCDateSeries[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const sampleThingsMap: {[key in SCThingType | string]: SCThing[]} = {
|
||||
export const sampleThingsMap: { [key in SCThingType | string]: SCThing[] } = {
|
||||
'academic event': sampleAcademicEvents,
|
||||
article: sampleArticles,
|
||||
book: sampleBooks,
|
||||
@@ -364,35 +367,6 @@ export const sampleThingsMap: {[key in SCThingType | string]: SCThing[]} = {
|
||||
tour: [],
|
||||
video: [],
|
||||
};
|
||||
// tslint:enable:no-magic-numbers
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* provides all or certain sample things to be used in tests or backendless development
|
||||
*/
|
||||
export function getSampleThings(...uids: string[]): SCThing[] {
|
||||
const sampleThings: SCThing[] = [];
|
||||
if (typeof uids !== 'undefined' && uids.length > 0) {
|
||||
uids.forEach((uid) => {
|
||||
Object.keys(sampleThingsMap)
|
||||
.forEach((key) => {
|
||||
sampleThingsMap[key].forEach((thing) => {
|
||||
if (thing.uid === uid) {
|
||||
sampleThings.push(thing);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Object.keys(sampleThingsMap)
|
||||
.forEach((key) => {
|
||||
sampleThings.push(...sampleThingsMap[key]);
|
||||
});
|
||||
}
|
||||
|
||||
return sampleThings;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -407,17 +381,13 @@ export class SampleThings {
|
||||
constructor(http: HttpClient) {
|
||||
this.http = http;
|
||||
}
|
||||
// getSampleThings(): Observable<any> {
|
||||
// return this.http.get('http://localhost:8100/assets/json/joined.json');
|
||||
// // return of(sampleDishes[0]);
|
||||
// }
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
// tslint:disable-next-line:prefer-function-over-method
|
||||
// tslint:disable-next-line:prefer-function-over-method no-any
|
||||
getSampleThing(uid: string): Observable<any[]> {
|
||||
// const jsonContent: any[] = await this.http.get('http://localhost:8100/assets/json/joined.json').toPromise();
|
||||
// tslint:disable-next-line:no-any
|
||||
const sampleThings: any[] = [];
|
||||
for (const resource of sampleResources) {
|
||||
if (resource.instance.uid as SCThingType === uid) {
|
||||
@@ -433,16 +403,18 @@ export class SampleThings {
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
// tslint:disable-next-line:prefer-function-over-method
|
||||
getSampleThings(): Observable<any[]> {
|
||||
// const jsonContent: any[] = await this.http.get('http://localhost:8100/assets/json/joined.json').toPromise();
|
||||
// tslint:disable-next-line:prefer-function-over-method no-any
|
||||
getSampleThings(filter?: SCSearchFilter): Observable<any[]> {
|
||||
// tslint:disable-next-line:no-any
|
||||
const sampleThings: any[] = [];
|
||||
sampleResources.forEach((resource) => {
|
||||
for (const resource of sampleResources) {
|
||||
// tslint:disable-next-line:max-line-length
|
||||
// if ([SCThingType.Video].includes(resource.instance.type as SCThingType)) {
|
||||
if (typeof filter === 'undefined' || checkFilter(resource.instance as SCThing, filter)) {
|
||||
sampleThings.push(resource.instance);
|
||||
}
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
return of(sampleThings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user