forked from hazza/dspace-angular
added typedoc
This commit is contained in:
@@ -22,12 +22,30 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy {
|
|||||||
* A single value for this component
|
* A single value for this component
|
||||||
*/
|
*/
|
||||||
@Input() filterValue: FacetValue;
|
@Input() filterValue: FacetValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter configuration for this facet option
|
||||||
|
*/
|
||||||
@Input() filterConfig: SearchFilterConfig;
|
@Input() filterConfig: SearchFilterConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits the active values for this filter
|
||||||
|
*/
|
||||||
@Input() selectedValues$: Observable<string[]>;
|
@Input() selectedValues$: Observable<string[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits true when this option should be visible and false when it should be invisible
|
||||||
|
*/
|
||||||
isVisible: Observable<boolean>;
|
isVisible: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI parameters when this filter is added
|
||||||
|
*/
|
||||||
addQueryParams;
|
addQueryParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscription to unsubscribe from on destroy
|
||||||
|
*/
|
||||||
sub: Subscription;
|
sub: Subscription;
|
||||||
|
|
||||||
constructor(protected searchService: SearchService,
|
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
|
* 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 {
|
private updateAddParams(selectedValues: string[]): void {
|
||||||
this.addQueryParams = {
|
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 {
|
ngOnDestroy(): void {
|
||||||
if (hasValue(this.sub)) {
|
if (hasValue(this.sub)) {
|
||||||
this.sub.unsubscribe();
|
this.sub.unsubscribe();
|
||||||
|
@@ -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 {
|
export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy {
|
||||||
/**
|
/**
|
||||||
* A single value for this component
|
* A single value for this component
|
||||||
*/
|
*/
|
||||||
@Input() filterValue: FacetValue;
|
@Input() filterValue: FacetValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter configuration for this facet option
|
||||||
|
*/
|
||||||
@Input() filterConfig: SearchFilterConfig;
|
@Input() filterConfig: SearchFilterConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits true when this option should be visible and false when it should be invisible
|
||||||
|
*/
|
||||||
isVisible: Observable<boolean>;
|
isVisible: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI parameters when this filter is changed
|
||||||
|
*/
|
||||||
changeQueryParams;
|
changeQueryParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscription to unsubscribe from on destroy
|
||||||
|
*/
|
||||||
sub: Subscription;
|
sub: Subscription;
|
||||||
|
|
||||||
constructor(protected searchService: SearchService,
|
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
|
* 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 {
|
updateChangeParams(): void {
|
||||||
const parts = this.filterValue.value.split(rangeDelimiter);
|
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 {
|
ngOnDestroy(): void {
|
||||||
if (hasValue(this.sub)) {
|
if (hasValue(this.sub)) {
|
||||||
this.sub.unsubscribe();
|
this.sub.unsubscribe();
|
||||||
|
@@ -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 {
|
export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy {
|
||||||
/**
|
/**
|
||||||
* A single value for this component
|
* The value for this component
|
||||||
*/
|
*/
|
||||||
@Input() selectedValue: string;
|
@Input() selectedValue: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter configuration for this facet option
|
||||||
|
*/
|
||||||
@Input() filterConfig: SearchFilterConfig;
|
@Input() filterConfig: SearchFilterConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +39,14 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
@Input() selectedValues$: Observable<string[]>;
|
@Input() selectedValues$: Observable<string[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI parameters when this filter is removed
|
||||||
|
*/
|
||||||
removeQueryParams;
|
removeQueryParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscription to unsubscribe from on destroy
|
||||||
|
*/
|
||||||
sub: Subscription;
|
sub: Subscription;
|
||||||
|
|
||||||
constructor(protected searchService: SearchService,
|
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
|
* 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
|
* @param {string[]} selectedValues The values that are currently selected for this filter
|
||||||
* @returns {Observable<any>} The changed filter parameters
|
|
||||||
*/
|
*/
|
||||||
private updateRemoveParams(selectedValues: string[]): void {
|
private updateRemoveParams(selectedValues: string[]): void {
|
||||||
this.removeQueryParams = {
|
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 {
|
ngOnDestroy(): void {
|
||||||
if (hasValue(this.sub)) {
|
if (hasValue(this.sub)) {
|
||||||
this.sub.unsubscribe();
|
this.sub.unsubscribe();
|
||||||
|
@@ -20,6 +20,9 @@ export class SearchFacetFilterWrapperComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() filterConfig: SearchFilterConfig;
|
@Input() filterConfig: SearchFilterConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor of the search facet filter that should be rendered, based on the filter config's type
|
||||||
|
*/
|
||||||
searchFilter: GenericConstructor<SearchFacetFilterComponent>;
|
searchFilter: GenericConstructor<SearchFacetFilterComponent>;
|
||||||
/**
|
/**
|
||||||
* Injector to inject a child component with the @Input parameters
|
* Injector to inject a child component with the @Input parameters
|
||||||
|
@@ -73,6 +73,10 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
* State of the requested facets used to time the animation
|
* State of the requested facets used to time the animation
|
||||||
*/
|
*/
|
||||||
animationState = 'loading';
|
animationState = 'loading';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits all current search options available in the search URL
|
||||||
|
*/
|
||||||
searchOptions$: Observable<SearchOptions>;
|
searchOptions$: Observable<SearchOptions>;
|
||||||
|
|
||||||
constructor(protected searchService: SearchService,
|
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) {
|
onClick(data: any) {
|
||||||
this.filter = data;
|
this.filter = data;
|
||||||
}
|
}
|
||||||
|
@@ -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 {
|
export class SearchFilterInitializeAction extends SearchFilterAction {
|
||||||
type = SearchFilterActionTypes.INITIALIZE;
|
type = SearchFilterActionTypes.INITIALIZE;
|
||||||
|
@@ -28,9 +28,20 @@ export class SearchFilterComponent implements OnInit {
|
|||||||
* True when the filter is 100% collapsed in the UI
|
* True when the filter is 100% collapsed in the UI
|
||||||
*/
|
*/
|
||||||
closed = true;
|
closed = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits true when the filter is currently collapsed in the store
|
||||||
|
*/
|
||||||
collapsed$: Observable<boolean>;
|
collapsed$: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits all currently selected values for this filter
|
||||||
|
*/
|
||||||
selectedValues$: Observable<string[]>;
|
selectedValues$: Observable<string[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits true when the current filter is supposed to be shown
|
||||||
|
*/
|
||||||
active$: Observable<boolean>;
|
active$: Observable<boolean>;
|
||||||
|
|
||||||
constructor(private filterService: SearchFilterService, private searchService: SearchService, private searchConfigService: SearchConfigurationService) {
|
constructor(private filterService: SearchFilterService, private searchService: SearchService, private searchConfigService: SearchConfigurationService) {
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { combineLatest as observableCombineLatest, Subscription } from 'rxjs';
|
||||||
of as observableOf,
|
|
||||||
combineLatest as observableCombineLatest,
|
|
||||||
Observable,
|
|
||||||
Subscription
|
|
||||||
} from 'rxjs';
|
|
||||||
import { map, startWith } from 'rxjs/operators';
|
import { map, startWith } from 'rxjs/operators';
|
||||||
import { isPlatformBrowser } from '@angular/common';
|
import { isPlatformBrowser } from '@angular/common';
|
||||||
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
|
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 { hasValue } from '../../../../shared/empty.util';
|
||||||
import { SearchConfigurationService } from '../../../search-service/search-configuration.service';
|
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.
|
* This component renders a simple item page.
|
||||||
* The route parameter 'id' is used to request the item it represents.
|
* 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.
|
* 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({
|
@Component({
|
||||||
selector: 'ds-search-range-filter',
|
selector: 'ds-search-range-filter',
|
||||||
styleUrls: ['./search-range-filter.component.scss'],
|
styleUrls: ['./search-range-filter.component.scss'],
|
||||||
@@ -130,8 +136,4 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
|
|||||||
this.sub.unsubscribe();
|
this.sub.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out(call) {
|
|
||||||
console.log(call);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
7
src/app/core/cache/object-cache.service.ts
vendored
7
src/app/core/cache/object-cache.service.ts
vendored
@@ -22,11 +22,18 @@ import {
|
|||||||
import { CacheableObject, ObjectCacheEntry, ObjectCacheState } from './object-cache.reducer';
|
import { CacheableObject, ObjectCacheEntry, ObjectCacheState } from './object-cache.reducer';
|
||||||
import { AddToSSBAction } from './server-sync-buffer.actions';
|
import { AddToSSBAction } from './server-sync-buffer.actions';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base selector function to select the object cache in the store
|
||||||
|
*/
|
||||||
const objectCacheSelector = createSelector(
|
const objectCacheSelector = createSelector(
|
||||||
coreSelector,
|
coreSelector,
|
||||||
(state: CoreState) => state['cache/object']
|
(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 =
|
const entryFromSelfLinkSelector =
|
||||||
(selfLink: string): MemoizedSelector<CoreState, ObjectCacheEntry> => createSelector(
|
(selfLink: string): MemoizedSelector<CoreState, ObjectCacheEntry> => createSelector(
|
||||||
objectCacheSelector,
|
objectCacheSelector,
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
import { createFeatureSelector } from '@ngrx/store';
|
import { createFeatureSelector } from '@ngrx/store';
|
||||||
import { CoreState } from './core.reducers';
|
import { CoreState } from './core.reducers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base selector to select the core state from the store
|
||||||
|
*/
|
||||||
export const coreSelector = createFeatureSelector<CoreState>('core');
|
export const coreSelector = createFeatureSelector<CoreState>('core');
|
||||||
|
@@ -28,11 +28,18 @@ import { RestRequestMethod } from './rest-request-method';
|
|||||||
import { AddToIndexAction, RemoveFromIndexBySubstringAction } from '../index/index.actions';
|
import { AddToIndexAction, RemoveFromIndexBySubstringAction } from '../index/index.actions';
|
||||||
import { coreSelector } from '../core.selectors';
|
import { coreSelector } from '../core.selectors';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base selector function to select the request state in the store
|
||||||
|
*/
|
||||||
const requestCacheSelector = createSelector(
|
const requestCacheSelector = createSelector(
|
||||||
coreSelector,
|
coreSelector,
|
||||||
(state: CoreState) => state['data/request']
|
(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<CoreState, RequestEntry> => createSelector(
|
const entryFromUUIDSelector = (uuid: string): MemoizedSelector<CoreState, RequestEntry> => createSelector(
|
||||||
requestCacheSelector,
|
requestCacheSelector,
|
||||||
(state: RequestState) => {
|
(state: RequestState) => {
|
||||||
@@ -67,6 +74,9 @@ const getUuidsFromHrefSubstring = (state: IndexState, href: string): string[] =>
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A service to interact with the request state in the store
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RequestService {
|
export class RequestService {
|
||||||
private requestsOnTheirWayToTheStore: string[] = [];
|
private requestsOnTheirWayToTheStore: string[] = [];
|
||||||
|
@@ -8,12 +8,19 @@ import {
|
|||||||
import { isNotEmpty } from '../empty.util';
|
import { isNotEmpty } from '../empty.util';
|
||||||
import { detect } from 'rxjs-spy';
|
import { detect } from 'rxjs-spy';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service to keep track of the current query parameters
|
||||||
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RouteService {
|
export class RouteService {
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute) {
|
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<string[]> {
|
getQueryParameterValues(paramName: string): Observable<string[]> {
|
||||||
return this.route.queryParamMap.pipe(
|
return this.route.queryParamMap.pipe(
|
||||||
map((params) => [...params.getAll(paramName)]),
|
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<string> {
|
getQueryParameterValue(paramName: string): Observable<string> {
|
||||||
return this.route.queryParamMap.pipe(
|
return this.route.queryParamMap.pipe(
|
||||||
map((params) => params.get(paramName)),
|
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<boolean> {
|
hasQueryParam(paramName: string): Observable<boolean> {
|
||||||
return this.route.queryParamMap.pipe(
|
return this.route.queryParamMap.pipe(
|
||||||
map((params) => params.has(paramName)),
|
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<boolean> {
|
hasQueryParamWithValue(paramName: string, paramValue: string): Observable<boolean> {
|
||||||
return this.route.queryParamMap.pipe(
|
return this.route.queryParamMap.pipe(
|
||||||
map((params) => params.getAll(paramName).indexOf(paramValue) > -1),
|
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<Params> {
|
getQueryParamsWithPrefix(prefix: string): Observable<Params> {
|
||||||
return this.route.queryParamMap.pipe(
|
return this.route.queryParamMap.pipe(
|
||||||
map((qparams) => {
|
map((qparams) => {
|
||||||
|
Reference in New Issue
Block a user