mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-03-15 11:12:22 +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
@@ -13,6 +13,9 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* tslint:disable */
|
||||
|
||||
import moment from 'moment'
|
||||
|
||||
export const sampleResources = [{
|
||||
'errorNames': [],
|
||||
"instance": {
|
||||
@@ -981,8 +984,8 @@ export const sampleResources = [{
|
||||
'offers': [
|
||||
{
|
||||
'availability': 'in stock',
|
||||
'availabilityStarts': '2017-01-30T00:00:00.000Z',
|
||||
'availabilityEnds': '2017-01-30T23:59:59.999Z',
|
||||
'availabilityStarts': moment().startOf('day').add(2,'days').toISOString(),
|
||||
'availabilityEnds': moment().endOf('day').add(2,'days').toISOString(),
|
||||
'prices': {
|
||||
'default': 6.5,
|
||||
'student': 5,
|
||||
@@ -1101,8 +1104,8 @@ export const sampleResources = [{
|
||||
'offers': [
|
||||
{
|
||||
'availability': 'in stock',
|
||||
'availabilityStarts': '2017-01-30T00:00:00.000Z',
|
||||
'availabilityEnds': '2017-01-30T23:59:59.999Z',
|
||||
'availabilityStarts': moment().startOf('day').toISOString(),
|
||||
'availabilityEnds': moment().endOf('day').add(2,'days').toISOString(),
|
||||
'prices': {
|
||||
'default': 4.85,
|
||||
'student': 2.85,
|
||||
@@ -1117,7 +1120,7 @@ export const sampleResources = [{
|
||||
'type': 'remote'
|
||||
},
|
||||
'type': 'organization',
|
||||
'uid': '3b9b3df6-3a7a-58cc-922f-c7335c002634'
|
||||
'uid': 'b7206fb5-bd77-5572-928f-16aa70910f64'
|
||||
},
|
||||
'inPlace': {
|
||||
'geo': {
|
||||
@@ -1138,7 +1141,7 @@ export const sampleResources = [{
|
||||
'alternateNames': [
|
||||
'MensaHardenberg'
|
||||
],
|
||||
'uid': '72fbc8a3-ebd1-58f9-9526-ad65cba2e402',
|
||||
'uid': 'b7206fb5-bd77-5572-928f-16aa70910f64',
|
||||
'address': {
|
||||
'addressCountry': 'Germany',
|
||||
'addressLocality': 'Berlin',
|
||||
@@ -1191,8 +1194,8 @@ export const sampleResources = [{
|
||||
'uid': '3b9b3df6-3a7a-58cc-922f-c7335c002634'
|
||||
},
|
||||
'availability': 'in stock',
|
||||
'availabilityStarts': '2017-01-30T00:00:00.000Z',
|
||||
'availabilityEnds': '2017-01-30T23:59:59.999Z',
|
||||
'availabilityStarts': moment().startOf('day').add(2,'days').toISOString(),
|
||||
'availabilityEnds': moment().endOf('day').add(2,'days').toISOString(),
|
||||
'inPlace': {
|
||||
'geo': {
|
||||
'point': {
|
||||
@@ -1264,8 +1267,8 @@ export const sampleResources = [{
|
||||
],
|
||||
'offers': [
|
||||
{
|
||||
'availabilityEnds': '2017-03-27T23:59:59.000Z',
|
||||
'availabilityStarts': '2017-03-27T00:00:00.000Z',
|
||||
'availabilityEnds': moment().endOf('day').toISOString(),
|
||||
'availabilityStarts': moment().startOf('day').toISOString(),
|
||||
'availability': 'in stock',
|
||||
'inPlace': {
|
||||
'type': 'room',
|
||||
@@ -1273,7 +1276,7 @@ export const sampleResources = [{
|
||||
'categories': [
|
||||
'cafe'
|
||||
],
|
||||
'uid': 'e5492c9c-064e-547c-8633-c8fc8955cfcf',
|
||||
'uid': 'b7206fb5-bd77-5572-928f-16aa70910f64',
|
||||
'alternateNames': [
|
||||
'Cafeteria LEVEL'
|
||||
],
|
||||
@@ -1306,7 +1309,7 @@ export const sampleResources = [{
|
||||
'type': 'remote'
|
||||
},
|
||||
'type': 'organization',
|
||||
'uid': '3b9b3df6-3a7a-58cc-922f-c7335c002634'
|
||||
'uid': 'b7206fb5-bd77-5572-928f-16aa70910f64'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -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