diff --git a/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.ts b/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.ts index 9fa59a0c1e..7a6a51e99d 100644 --- a/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.ts +++ b/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.ts @@ -22,12 +22,30 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy { * A single value for this component */ @Input() filterValue: FacetValue; + + /** + * The filter configuration for this facet option + */ @Input() filterConfig: SearchFilterConfig; + + /** + * Emits the active values for this filter + */ @Input() selectedValues$: Observable; + /** + * Emits true when this option should be visible and false when it should be invisible + */ isVisible: Observable; + /** + * UI parameters when this filter is added + */ addQueryParams; + + /** + * Subscription to unsubscribe from on destroy + */ sub: Subscription; constructor(protected searchService: SearchService, @@ -64,7 +82,7 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy { /** * Calculates the parameters that should change if a given value for this filter would be added to the active filters - * @param {string} value The value that is added for this filter + * @param {string[]} selectedValues The values that are currently selected for this filter */ private updateAddParams(selectedValues: string[]): void { this.addQueryParams = { @@ -73,6 +91,9 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy { }; } + /** + * Make sure the subscription is unsubscribed from when this component is destroyed + */ ngOnDestroy(): void { if (hasValue(this.sub)) { this.sub.unsubscribe(); diff --git a/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.ts b/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.ts index 2f6a49f8b9..22e6f04d9a 100644 --- a/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.ts +++ b/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.ts @@ -21,18 +21,32 @@ const rangeDelimiter = '-'; }) /** - * Represents a single option in a filter facet + * Represents a single option in a range filter facet */ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy { /** * A single value for this component */ @Input() filterValue: FacetValue; + + /** + * The filter configuration for this facet option + */ @Input() filterConfig: SearchFilterConfig; + /** + * Emits true when this option should be visible and false when it should be invisible + */ isVisible: Observable; + /** + * UI parameters when this filter is changed + */ changeQueryParams; + + /** + * Subscription to unsubscribe from on destroy + */ sub: Subscription; constructor(protected searchService: SearchService, @@ -68,7 +82,6 @@ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy { /** * Calculates the parameters that should change if a given values for this range filter would be changed - * @param {string} value The values that are changed for this filter */ updateChangeParams(): void { const parts = this.filterValue.value.split(rangeDelimiter); @@ -81,6 +94,9 @@ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy { }; } + /** + * Make sure the subscription is unsubscribed from when this component is destroyed + */ ngOnDestroy(): void { if (hasValue(this.sub)) { this.sub.unsubscribe(); diff --git a/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-selected-option/search-facet-selected-option.component.ts b/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-selected-option/search-facet-selected-option.component.ts index 55030a4a84..2eb17681df 100644 --- a/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-selected-option/search-facet-selected-option.component.ts +++ b/src/app/+search-page/search-filters/search-filter/search-facet-filter-options/search-facet-selected-option/search-facet-selected-option.component.ts @@ -21,13 +21,17 @@ import { SearchConfigurationService } from '../../../../search-service/search-co }) /** - * Represents a single option in a filter facet + * Represents a single selected option in a filter facet */ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy { /** - * A single value for this component + * The value for this component */ @Input() selectedValue: string; + + /** + * The filter configuration for this facet option + */ @Input() filterConfig: SearchFilterConfig; /** @@ -35,7 +39,14 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy { */ @Input() selectedValues$: Observable; + /** + * UI parameters when this filter is removed + */ removeQueryParams; + + /** + * Subscription to unsubscribe from on destroy + */ sub: Subscription; constructor(protected searchService: SearchService, @@ -64,8 +75,7 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy { /** * Calculates the parameters that should change if a given value for this filter would be removed from the active filters - * @param {string} value The value that is removed for this filter - * @returns {Observable} The changed filter parameters + * @param {string[]} selectedValues The values that are currently selected for this filter */ private updateRemoveParams(selectedValues: string[]): void { this.removeQueryParams = { @@ -74,6 +84,9 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy { }; } + /** + * Make sure the subscription is unsubscribed from when this component is destroyed + */ ngOnDestroy(): void { if (hasValue(this.sub)) { this.sub.unsubscribe(); diff --git a/src/app/+search-page/search-filters/search-filter/search-facet-filter-wrapper/search-facet-filter-wrapper.component.ts b/src/app/+search-page/search-filters/search-filter/search-facet-filter-wrapper/search-facet-filter-wrapper.component.ts index 5b733b52cb..6369a7691e 100644 --- a/src/app/+search-page/search-filters/search-filter/search-facet-filter-wrapper/search-facet-filter-wrapper.component.ts +++ b/src/app/+search-page/search-filters/search-filter/search-facet-filter-wrapper/search-facet-filter-wrapper.component.ts @@ -20,6 +20,9 @@ export class SearchFacetFilterWrapperComponent implements OnInit { */ @Input() filterConfig: SearchFilterConfig; + /** + * The constructor of the search facet filter that should be rendered, based on the filter config's type + */ searchFilter: GenericConstructor; /** * Injector to inject a child component with the @Input parameters diff --git a/src/app/+search-page/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts b/src/app/+search-page/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts index 62275ee3c4..367947a377 100644 --- a/src/app/+search-page/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts +++ b/src/app/+search-page/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts @@ -73,6 +73,10 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy { * State of the requested facets used to time the animation */ animationState = 'loading'; + + /** + * Emits all current search options available in the search URL + */ searchOptions$: Observable; constructor(protected searchService: SearchService, @@ -207,6 +211,10 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy { ) } + /** + * On click, set the input's value to the clicked data + * @param data The value of the option that was clicked + */ onClick(data: any) { this.filter = data; } diff --git a/src/app/+search-page/search-filters/search-filter/search-filter.actions.ts b/src/app/+search-page/search-filters/search-filter/search-filter.actions.ts index 838597e03d..f7f80eefff 100644 --- a/src/app/+search-page/search-filters/search-filter/search-filter.actions.ts +++ b/src/app/+search-page/search-filters/search-filter/search-filter.actions.ts @@ -64,7 +64,7 @@ export class SearchFilterToggleAction extends SearchFilterAction { } /** - * Used to set the initial state of a filter to collapsed + * Used to set the initial state of a filter */ export class SearchFilterInitializeAction extends SearchFilterAction { type = SearchFilterActionTypes.INITIALIZE; diff --git a/src/app/+search-page/search-filters/search-filter/search-filter.component.ts b/src/app/+search-page/search-filters/search-filter/search-filter.component.ts index eaf318655f..3a5e4bfc55 100644 --- a/src/app/+search-page/search-filters/search-filter/search-filter.component.ts +++ b/src/app/+search-page/search-filters/search-filter/search-filter.component.ts @@ -28,9 +28,20 @@ export class SearchFilterComponent implements OnInit { * True when the filter is 100% collapsed in the UI */ closed = true; + + /** + * Emits true when the filter is currently collapsed in the store + */ collapsed$: Observable; + /** + * Emits all currently selected values for this filter + */ selectedValues$: Observable; + + /** + * Emits true when the current filter is supposed to be shown + */ active$: Observable; constructor(private filterService: SearchFilterService, private searchService: SearchService, private searchConfigService: SearchConfigurationService) { diff --git a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts index 0bc30676c1..ebdb797500 100644 --- a/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts +++ b/src/app/+search-page/search-filters/search-filter/search-range-filter/search-range-filter.component.ts @@ -1,9 +1,4 @@ -import { - of as observableOf, - combineLatest as observableCombineLatest, - Observable, - Subscription -} from 'rxjs'; +import { combineLatest as observableCombineLatest, Subscription } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; import { isPlatformBrowser } from '@angular/common'; import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core'; @@ -23,15 +18,26 @@ import { RouteService } from '../../../../shared/services/route.service'; import { hasValue } from '../../../../shared/empty.util'; import { SearchConfigurationService } from '../../../search-service/search-configuration.service'; +/** + * The suffix for a range filters' minimum in the frontend URL + */ +export const RANGE_FILTER_MIN_SUFFIX = '.min'; + +/** + * The suffix for a range filters' maximum in the frontend URL + */ +export const RANGE_FILTER_MAX_SUFFIX = '.max'; + +/** + * The date formats that are possible to appear in a date filter + */ +const dateFormats = ['YYYY', 'YYYY-MM', 'YYYY-MM-DD']; + /** * This component renders a simple item page. * The route parameter 'id' is used to request the item it represents. * All fields of the item that should be displayed, are defined in its template. */ -export const RANGE_FILTER_MIN_SUFFIX = '.min'; -export const RANGE_FILTER_MAX_SUFFIX = '.max'; -const dateFormats = ['YYYY', 'YYYY-MM', 'YYYY-MM-DD']; - @Component({ selector: 'ds-search-range-filter', styleUrls: ['./search-range-filter.component.scss'], @@ -130,8 +136,4 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple this.sub.unsubscribe(); } } - - out(call) { - console.log(call); - } } diff --git a/src/app/core/cache/object-cache.service.ts b/src/app/core/cache/object-cache.service.ts index 1fdc2eaaf8..483de65b98 100644 --- a/src/app/core/cache/object-cache.service.ts +++ b/src/app/core/cache/object-cache.service.ts @@ -22,11 +22,18 @@ import { import { CacheableObject, ObjectCacheEntry, ObjectCacheState } from './object-cache.reducer'; import { AddToSSBAction } from './server-sync-buffer.actions'; +/** + * The base selector function to select the object cache in the store + */ const objectCacheSelector = createSelector( coreSelector, (state: CoreState) => state['cache/object'] ); +/** + * Selector function to select an object entry by self link from the cache + * @param selfLink The self link of the object + */ const entryFromSelfLinkSelector = (selfLink: string): MemoizedSelector => createSelector( objectCacheSelector, diff --git a/src/app/core/core.selectors.ts b/src/app/core/core.selectors.ts index 2ad701eba1..60365be7c2 100644 --- a/src/app/core/core.selectors.ts +++ b/src/app/core/core.selectors.ts @@ -1,4 +1,7 @@ import { createFeatureSelector } from '@ngrx/store'; import { CoreState } from './core.reducers'; +/** + * Base selector to select the core state from the store + */ export const coreSelector = createFeatureSelector('core'); diff --git a/src/app/core/data/request.service.ts b/src/app/core/data/request.service.ts index c85a0ff423..97bc4ea1a2 100644 --- a/src/app/core/data/request.service.ts +++ b/src/app/core/data/request.service.ts @@ -28,11 +28,18 @@ import { RestRequestMethod } from './rest-request-method'; import { AddToIndexAction, RemoveFromIndexBySubstringAction } from '../index/index.actions'; import { coreSelector } from '../core.selectors'; +/** + * The base selector function to select the request state in the store + */ const requestCacheSelector = createSelector( coreSelector, (state: CoreState) => state['data/request'] ); +/** + * Selector function to select a request entry by uuid from the cache + * @param uuid The uuid of the request + */ const entryFromUUIDSelector = (uuid: string): MemoizedSelector => createSelector( requestCacheSelector, (state: RequestState) => { @@ -67,6 +74,9 @@ const getUuidsFromHrefSubstring = (state: IndexState, href: string): string[] => return result; }; +/** + * A service to interact with the request state in the store + */ @Injectable() export class RequestService { private requestsOnTheirWayToTheStore: string[] = []; diff --git a/src/app/shared/services/route.service.ts b/src/app/shared/services/route.service.ts index 6350605bce..3e62064d91 100644 --- a/src/app/shared/services/route.service.ts +++ b/src/app/shared/services/route.service.ts @@ -8,12 +8,19 @@ import { import { isNotEmpty } from '../empty.util'; import { detect } from 'rxjs-spy'; +/** + * Service to keep track of the current query parameters + */ @Injectable() export class RouteService { constructor(private route: ActivatedRoute) { } + /** + * Retrieves all query parameter values based on a parameter name + * @param paramName The name of the parameter to look for + */ getQueryParameterValues(paramName: string): Observable { return this.route.queryParamMap.pipe( map((params) => [...params.getAll(paramName)]), @@ -21,6 +28,10 @@ export class RouteService { ); } + /** + * Retrieves a single query parameter values based on a parameter name + * @param paramName The name of the parameter to look for + */ getQueryParameterValue(paramName: string): Observable { return this.route.queryParamMap.pipe( map((params) => params.get(paramName)), @@ -28,6 +39,10 @@ export class RouteService { ); } + /** + * Checks if the query parameter currently exists in the route + * @param paramName The name of the parameter to look for + */ hasQueryParam(paramName: string): Observable { return this.route.queryParamMap.pipe( map((params) => params.has(paramName)), @@ -35,6 +50,11 @@ export class RouteService { ); } + /** + * Checks if the query parameter with a specific value currently exists in the route + * @param paramName The name of the parameter to look for + * @param paramValue The value of the parameter to look for + */ hasQueryParamWithValue(paramName: string, paramValue: string): Observable { return this.route.queryParamMap.pipe( map((params) => params.getAll(paramName).indexOf(paramValue) > -1), @@ -42,6 +62,10 @@ export class RouteService { ); } + /** + * Retrieves all query parameters of which the parameter name starts with the given prefix + * @param prefix The prefix of the parameter name to look for + */ getQueryParamsWithPrefix(prefix: string): Observable { return this.route.queryParamMap.pipe( map((qparams) => {