feat: show menu for multiple days for canteens and cafes

Closes #19, #79
This commit is contained in:
Wieland Schöbl
2021-01-19 13:50:51 +00:00
committed by Jovan Krunić
parent 66b8720da0
commit 3c079cd189
27 changed files with 1347 additions and 523 deletions

View File

@@ -20,8 +20,9 @@ import {
SCThingType,
SCTranslations,
} from '@openstapps/core';
import {MenuService} from '../menu.service';
import {ContextMenuService} from './context-menu.service';
import {FilterContext, SortContext, SortContextOption} from './context-type';
import {Subscription} from 'rxjs';
/**
* The context menu
@@ -68,30 +69,45 @@ export class ContextMenuComponent {
*/
translator: SCThingTranslator;
/**
* Array of all Subscriptions
*/
subscriptions: Subscription[] = [];
constructor(private translateService: TranslateService,
private readonly menuService: MenuService) {
private readonly contextMenuService: ContextMenuService) {
this.language = this.translateService.currentLang as keyof SCTranslations<SCLanguage>;
this.translator = new SCThingTranslator(this.language);
this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.subscriptions.push(this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.language = event.lang as keyof SCTranslations<SCLanguage>;
this.translator = new SCThingTranslator(this.language);
});
}));
this.menuService.filterContextChanged$.subscribe((filterContext) => {
this.subscriptions.push(this.contextMenuService.filterContextChanged$.subscribe((filterContext) => {
this.filterOption = filterContext;
});
}));
this.menuService.sortOptions.subscribe((sortContext) => {
this.subscriptions.push(this.contextMenuService.sortOptions.subscribe((sortContext) => {
this.sortOption = sortContext;
});
}));
}
/**
* Unsubscribe from Observables
*/
ngOnDestroy() {
for (let sub of this.subscriptions) {
sub.unsubscribe();
}
}
/**
* Sets selected filter options and updates listener
*/
filterChanged = () => {
this.menuService.contextFilterChanged(this.filterOption);
this.contextMenuService.contextFilterChanged(this.filterOption);
}
/**
@@ -117,7 +133,7 @@ export class ContextMenuComponent {
option.options.forEach((filterFacet) => filterFacet.buckets.forEach((filterBucket) => {
filterBucket.checked = false;
}));
this.menuService.contextFilterChanged(this.filterOption);
this.contextMenuService.contextFilterChanged(this.filterOption);
}
/**
@@ -134,6 +150,6 @@ export class ContextMenuComponent {
option.reversed = false;
}
}
this.menuService.contextSortChanged(option);
this.contextMenuService.contextSortChanged(option);
}
}