feat: timetable module - schedule and calendar

This commit is contained in:
Wieland Schöbl
2021-08-13 12:27:40 +00:00
parent e81b2e161d
commit d8ede006df
59 changed files with 3287 additions and 555 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 StApps
* Copyright (C) 2020 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -15,90 +15,17 @@
import {Injectable} from '@angular/core';
import {
SCFacet,
SCFacetBucket,
SCSearchFilter,
SCSearchSort,
SCThingType,
} from '@openstapps/core';
import {Subject} from 'rxjs';
export type ContextType = FilterContext | SortContext;
/**
* A sort context
*/
interface SortContext {
/**
* Name of the context
*/
name: 'sort';
/**
* Reverse option
*/
reversed: boolean;
/**
* sort value
*/
value: string;
/**
* Sort options
*/
values: SortContextOption[];
}
/**
* A sort context option
*/
interface SortContextOption {
/**
* sort option is reversible
*/
reversible: boolean;
/**
* sort option value
*/
value: string;
}
/**
* A filter context
*/
interface FilterContext {
/**
* Compact view of the filter options
*/
compact?: boolean;
/**
* Name of the context
*/
name: 'filter';
/**
* Filter values
*/
options: FilterFacet[];
}
interface FilterFacet extends SCFacet {
/**
* FilterBuckets of a FilterFacet
*/
buckets: FilterBucket[];
/**
* Compact view of the option buckets
*/
compact?: boolean;
}
interface FilterBucket extends SCFacetBucket {
/**
* Sets the Filter active
*/
checked: boolean;
}
import {
FilterBucket,
FilterContext,
FilterFacet,
SortContext,
} from './context-type';
/**
* ContextMenuService provides bidirectional communication of context menu options and search queries
@@ -113,13 +40,11 @@ export class ContextMenuService {
/**
* Container for the filter context
*/
// tslint:disable-next-line:member-ordering
filterOptions = new Subject<FilterContext>();
/**
* Observable filterContext streams
*/
// tslint:disable-next-line:member-ordering
filterContextChanged$ = this.filterOptions.asObservable();
/**
@@ -130,19 +55,21 @@ export class ContextMenuService {
/**
* Observable filterContext streams
*/
// tslint:disable-next-line:member-ordering
filterQueryChanged$ = this.filterQuery.asObservable();
/**
* Forced SCThingTypeFilter
*/
forcedType?: SCThingType;
/**
* Container for the sort context
*/
// tslint:disable-next-line:member-ordering
sortOptions = new Subject<SortContext>();
/**
* Observable SortContext streams
*/
// tslint:disable-next-line:member-ordering
sortContextChanged$ = this.sortOptions.asObservable();
/**
@@ -153,7 +80,6 @@ export class ContextMenuService {
/**
* Observable SortContext streams
*/
// tslint:disable-next-line:member-ordering
sortQueryChanged$ = this.sortQuery.asObservable();
/**
@@ -166,6 +92,16 @@ export class ContextMenuService {
): SCSearchFilter | undefined => {
const filters: SCSearchFilter[] = [];
if (typeof this.forcedType !== 'undefined') {
filters.push({
arguments: {
field: 'type',
value: this.forcedType,
},
type: 'value',
});
}
for (const filterFacet of filterContext.options) {
const optionFilters: SCSearchFilter[] = [];
for (const filterBucket of filterFacet.buckets) {