mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
62849: fixed routing issues
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
import { HostWindowService } from '../shared/host-window.service';
|
import { HostWindowService } from '../shared/host-window.service';
|
||||||
import { SearchService } from './search-service/search.service';
|
|
||||||
import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
|
|
||||||
import { SearchPageComponent } from './search-page.component';
|
import { SearchPageComponent } from './search-page.component';
|
||||||
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core';
|
||||||
import { pushInOut } from '../shared/animations/push';
|
import { pushInOut } from '../shared/animations/push';
|
||||||
import { RouteService } from '../shared/services/route.service';
|
import { RouteService } from '../shared/services/route.service';
|
||||||
import { SearchConfigurationService } from './search-service/search-configuration.service';
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { PaginatedSearchOptions } from './paginated-search-options.model';
|
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
||||||
|
import { SearchService } from '../core/shared/search/search.service';
|
||||||
|
import { SearchSidebarService } from '../core/shared/search/search-sidebar.service';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { PaginatedSearchOptions } from '../shared/search/paginated-search-options.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a search page using a configuration as input.
|
* This component renders a search page using a configuration as input.
|
||||||
@@ -39,8 +40,9 @@ export class ConfigurationSearchPageComponent extends SearchPageComponent implem
|
|||||||
protected sidebarService: SearchSidebarService,
|
protected sidebarService: SearchSidebarService,
|
||||||
protected windowService: HostWindowService,
|
protected windowService: HostWindowService,
|
||||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
||||||
protected routeService: RouteService) {
|
protected routeService: RouteService,
|
||||||
super(service, sidebarService, windowService, searchConfigService, routeService);
|
protected router: Router) {
|
||||||
|
super(service, sidebarService, windowService, searchConfigService, routeService, router);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -9,8 +9,9 @@ import { SearchConfigurationService } from '../core/shared/search/search-configu
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { PaginatedSearchOptions } from '../shared/search/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../shared/search/paginated-search-options.model';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
||||||
import { map } from 'rxjs/operators';
|
import { map, take } from 'rxjs/operators';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../shared/empty.util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a simple item page.
|
* This component renders a simple item page.
|
||||||
@@ -56,21 +57,8 @@ export class FilteredSearchPageComponent extends SearchPageComponent implements
|
|||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
}
|
if (hasValue(this.fixedFilterQuery)) {
|
||||||
|
this.routeService.setParameter('filterQuery', this.fixedFilterQuery);
|
||||||
/**
|
}
|
||||||
* Get the current paginated search options after updating the fixed filter using the fixedFilterQuery input
|
|
||||||
* This is to make sure the fixed filter is included in the paginated search options, as it is not part of any
|
|
||||||
* query or route parameters
|
|
||||||
* @returns {Observable<PaginatedSearchOptions>}
|
|
||||||
*/
|
|
||||||
protected getSearchOptions(): Observable<PaginatedSearchOptions> {
|
|
||||||
return this.searchConfigService.paginatedSearchOptions.pipe(
|
|
||||||
map((options: PaginatedSearchOptions) => {
|
|
||||||
const filter = this.fixedFilterQuery || options.fixedFilter;
|
|
||||||
|
|
||||||
return this.routeService.addParameter({ fixedFilter: filter });
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ import { SharedModule } from '../shared/shared.module';
|
|||||||
import { SearchPageRoutingModule } from './search-page-routing.module';
|
import { SearchPageRoutingModule } from './search-page-routing.module';
|
||||||
import { SearchPageComponent } from './search-page.component';
|
import { SearchPageComponent } from './search-page.component';
|
||||||
import { FilteredSearchPageComponent } from './filtered-search-page.component';
|
import { FilteredSearchPageComponent } from './filtered-search-page.component';
|
||||||
|
import { ConfigurationSearchPageGuard } from './configuration-search-page.guard';
|
||||||
|
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
@@ -19,6 +20,7 @@ const components = [
|
|||||||
SharedModule,
|
SharedModule,
|
||||||
CoreModule.forRoot()
|
CoreModule.forRoot()
|
||||||
],
|
],
|
||||||
|
providers: [ConfigurationSearchPageGuard],
|
||||||
declarations: components,
|
declarations: components,
|
||||||
exports: components
|
exports: components
|
||||||
})
|
})
|
||||||
|
@@ -23,7 +23,6 @@ import { NativeWindowRef, NativeWindowService } from './shared/services/window.s
|
|||||||
import { isAuthenticated } from './core/auth/selectors';
|
import { isAuthenticated } from './core/auth/selectors';
|
||||||
import { AuthService } from './core/auth/auth.service';
|
import { AuthService } from './core/auth/auth.service';
|
||||||
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
|
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
|
||||||
import { RouteService } from './shared/services/route.service';
|
|
||||||
import variables from '../styles/_exposed_variables.scss';
|
import variables from '../styles/_exposed_variables.scss';
|
||||||
import { CSSVariableService } from './shared/sass-helper/sass-helper.service';
|
import { CSSVariableService } from './shared/sass-helper/sass-helper.service';
|
||||||
import { MenuService } from './shared/menu/menu.service';
|
import { MenuService } from './shared/menu/menu.service';
|
||||||
|
@@ -98,7 +98,6 @@ import { ENV_CONFIG, GLOBAL_CONFIG, GlobalConfig } from '../../config';
|
|||||||
import { SearchSidebarService } from './shared/search/search-sidebar.service';
|
import { SearchSidebarService } from './shared/search/search-sidebar.service';
|
||||||
import { SearchFilterService } from './shared/search/search-filter.service';
|
import { SearchFilterService } from './shared/search/search-filter.service';
|
||||||
import { SearchFixedFilterService } from './shared/search/search-fixed-filter.service';
|
import { SearchFixedFilterService } from './shared/search/search-fixed-filter.service';
|
||||||
import { FilteredSearchPageGuard } from '../+search-page/filtered-search-page.guard';
|
|
||||||
import { SearchConfigurationService } from './shared/search/search-configuration.service';
|
import { SearchConfigurationService } from './shared/search/search-configuration.service';
|
||||||
import { SelectableListService } from '../shared/object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../shared/object-list/selectable-list/selectable-list.service';
|
||||||
|
|
||||||
@@ -203,7 +202,6 @@ const PROVIDERS = [
|
|||||||
SearchSidebarService,
|
SearchSidebarService,
|
||||||
SearchFilterService,
|
SearchFilterService,
|
||||||
SearchFixedFilterService,
|
SearchFixedFilterService,
|
||||||
FilteredSearchPageGuard,
|
|
||||||
SearchFilterService,
|
SearchFilterService,
|
||||||
SearchConfigurationService,
|
SearchConfigurationService,
|
||||||
SelectableListService,
|
SelectableListService,
|
||||||
|
@@ -125,3 +125,10 @@ export const getFirstOccurrence = () =>
|
|||||||
source.pipe(
|
source.pipe(
|
||||||
map((rd) => Object.assign(rd, { payload: rd.payload.page.length > 0 ? rd.payload.page[0] : undefined }))
|
map((rd) => Object.assign(rd, { payload: rd.payload.page.length > 0 ? rd.payload.page[0] : undefined }))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
export const obsLog = (logString?: string) =>
|
||||||
|
<T>(source: Observable<T>): Observable<T> =>
|
||||||
|
source.pipe(
|
||||||
|
tap((t) => console.log(logString || '', t))
|
||||||
|
);
|
@@ -10,17 +10,17 @@ import {
|
|||||||
Subscription
|
Subscription
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import { filter, flatMap, map, startWith, switchMap, tap } from 'rxjs/operators';
|
import { filter, flatMap, map, startWith, switchMap, tap } from 'rxjs/operators';
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
|
||||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||||
import { SearchOptions } from '../../../shared/search/search-options.model';
|
import { SearchOptions } from '../../../shared/search/search-options.model';
|
||||||
import { PaginatedSearchOptions } from '../../../shared/search/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../../shared/search/paginated-search-options.model';
|
||||||
import { RouteService } from '../../../shared/services/route.service';
|
import { RouteService } from '../../../shared/services/route.service';
|
||||||
import { hasNoValue, hasValue, isNotEmpty, isNotEmptyOperator } from '../../../shared/empty.util';
|
import { hasNoValue, hasValue, isNotEmpty, isNotEmptyOperator } from '../../../shared/empty.util';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
|
||||||
import { getSucceededRemoteData } from '../../core/shared/operators';
|
|
||||||
import { SearchFilter } from '../../../shared/search/search-filter.model';
|
import { SearchFilter } from '../../../shared/search/search-filter.model';
|
||||||
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
|
|
||||||
import { SearchFixedFilterService } from './search-fixed-filter.service';
|
import { SearchFixedFilterService } from './search-fixed-filter.service';
|
||||||
|
import { SortDirection, SortOptions } from '../../cache/models/sort-options.model';
|
||||||
|
import { RemoteData } from '../../data/remote-data';
|
||||||
|
import { getSucceededRemoteData } from '../operators';
|
||||||
|
import { DSpaceObjectType } from '../dspace-object-type.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that performs all actions that have to do with the current search configuration
|
* Service that performs all actions that have to do with the current search configuration
|
||||||
@@ -95,7 +95,7 @@ export class SearchConfigurationService implements OnDestroy {
|
|||||||
protected initDefaults() {
|
protected initDefaults() {
|
||||||
this.defaults
|
this.defaults
|
||||||
.pipe(getSucceededRemoteData())
|
.pipe(getSucceededRemoteData())
|
||||||
.subscribe((defRD) => {
|
.subscribe((defRD: RemoteData<PaginatedSearchOptions>) => {
|
||||||
const defs = defRD.payload;
|
const defs = defRD.payload;
|
||||||
this.paginatedSearchOptions = new BehaviorSubject<PaginatedSearchOptions>(defs);
|
this.paginatedSearchOptions = new BehaviorSubject<PaginatedSearchOptions>(defs);
|
||||||
this.searchOptions = new BehaviorSubject<SearchOptions>(defs);
|
this.searchOptions = new BehaviorSubject<SearchOptions>(defs);
|
||||||
|
@@ -9,13 +9,14 @@ import { DSpaceObject } from '../../../../../../core/shared/dspace-object.model'
|
|||||||
import { PaginationComponentOptions } from '../../../../../pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../../../pagination/pagination-component-options.model';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { hasValue } from '../../../../../empty.util';
|
import { hasValue } from '../../../../../empty.util';
|
||||||
import { concat, map, multicast, switchMap, take, takeWhile } from 'rxjs/operators';
|
import { concat, filter, map, multicast, switchMap, take, takeWhile } from 'rxjs/operators';
|
||||||
import { Router } from '@angular/router';
|
import { NavigationEnd, Router } from '@angular/router';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../../../../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../../../+my-dspace-page/my-dspace-page.component';
|
||||||
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
||||||
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
|
||||||
import { SelectableListState } from '../../../../../object-list/selectable-list/selectable-list.reducer';
|
import { SelectableListState } from '../../../../../object-list/selectable-list/selectable-list.reducer';
|
||||||
import { ListableObject } from '../../../../../object-collection/shared/listable-object.model';
|
import { ListableObject } from '../../../../../object-collection/shared/listable-object.model';
|
||||||
|
import { RouteService } from '../../../../../services/route.service';
|
||||||
|
|
||||||
const RELATION_TYPE_FILTER_PREFIX = 'f.entityType=';
|
const RELATION_TYPE_FILTER_PREFIX = 'f.entityType=';
|
||||||
|
|
||||||
@@ -45,12 +46,15 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
selection: Observable<ListableObject[]>;
|
selection: Observable<ListableObject[]>;
|
||||||
fixedFilter: string;
|
fixedFilter: string;
|
||||||
constructor(public modal: NgbActiveModal, private searchService: SearchService, private router: Router, private selectableListService: SelectableListService, private searchConfigService: SearchConfigurationService) {
|
constructor(public modal: NgbActiveModal, private searchService: SearchService, private router: Router, private selectableListService: SelectableListService, private searchConfigService: SearchConfigurationService, private routeService: RouteService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.resetRoute();
|
this.resetRoute();
|
||||||
this.fixedFilter = RELATION_TYPE_FILTER_PREFIX + this.fieldName;
|
this.fixedFilter = RELATION_TYPE_FILTER_PREFIX + this.fieldName;
|
||||||
|
|
||||||
|
///Throw away, this is just a hack for now
|
||||||
|
this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe((t) => this.routeService.setParameter('filterQuery', this.fixedFilter));
|
||||||
this.selection = this.selectableListService.getSelectableList(this.listId).pipe(map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []));
|
this.selection = this.selectableListService.getSelectableList(this.listId).pipe(map((listState: SelectableListState) => hasValue(listState) && hasValue(listState.selection) ? listState.selection : []));
|
||||||
this.resultsRD$ = this.searchConfigService.paginatedSearchOptions.pipe(
|
this.resultsRD$ = this.searchConfigService.paginatedSearchOptions.pipe(
|
||||||
map((options) => {
|
map((options) => {
|
||||||
|
@@ -8,7 +8,7 @@ import { RemoteData } from '../../../core/data/remote-data';
|
|||||||
import { SearchFilterConfig } from '../search-filter-config.model';
|
import { SearchFilterConfig } from '../search-filter-config.model';
|
||||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||||
import { SearchFilterService } from '../../../core/shared/search/search-filter.service';
|
import { SearchFilterService } from '../../../core/shared/search/search-filter.service';
|
||||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
import { getSucceededRemoteData, obsLog } from '../../../core/shared/operators';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../+my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../+my-dspace-page/my-dspace-page.component';
|
||||||
import { currentPath } from '../../utils/route.utils';
|
import { currentPath } from '../../utils/route.utils';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
@@ -54,9 +54,9 @@ export class SearchFiltersComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
console.log(this.searchConfigService);
|
|
||||||
this.filters = this.searchConfigService.searchOptions.pipe(
|
this.filters = this.searchConfigService.searchOptions.pipe(
|
||||||
switchMap((options) => this.searchService.getConfig(options.scope, options.configuration).pipe(getSucceededRemoteData()))
|
switchMap((options) => this.searchService.getConfig(options.scope, options.configuration).pipe(getSucceededRemoteData())),
|
||||||
|
obsLog('searchoptions')
|
||||||
);
|
);
|
||||||
|
|
||||||
this.clearParams = this.searchConfigService.getCurrentFrontendFilters().pipe(map((filters) => {
|
this.clearParams = this.searchConfigService.getCurrentFrontendFilters().pipe(map((filters) => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<h2 *ngIf="!disableHeader">{{ getTitleKey() | translate }}</h2>
|
<h2 *ngIf="!disableHeader">{{ (configuration ? configuration + '.search.results.head' : 'search.results.head') | translate }}</h2>
|
||||||
<div *ngIf="searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
|
<div *ngIf="searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
[config]="searchConfig.pagination"
|
[config]="searchConfig.pagination"
|
||||||
|
@@ -10,6 +10,8 @@ export const RouteActionTypes = {
|
|||||||
SET_PARAMETERS: type('dspace/core/route/SET_PARAMETERS'),
|
SET_PARAMETERS: type('dspace/core/route/SET_PARAMETERS'),
|
||||||
ADD_QUERY_PARAMETER: type('dspace/core/route/ADD_QUERY_PARAMETER'),
|
ADD_QUERY_PARAMETER: type('dspace/core/route/ADD_QUERY_PARAMETER'),
|
||||||
ADD_PARAMETER: type('dspace/core/route/ADD_PARAMETER'),
|
ADD_PARAMETER: type('dspace/core/route/ADD_PARAMETER'),
|
||||||
|
SET_QUERY_PARAMETER: type('dspace/core/route/SET_QUERY_PARAMETER'),
|
||||||
|
SET_PARAMETER: type('dspace/core/route/SET_PARAMETER'),
|
||||||
RESET: type('dspace/core/route/RESET'),
|
RESET: type('dspace/core/route/RESET'),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,6 +98,52 @@ export class AddParameterAction implements Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ngrx action to set a query parameter
|
||||||
|
*/
|
||||||
|
export class SetQueryParameterAction implements Action {
|
||||||
|
type = RouteActionTypes.SET_QUERY_PARAMETER;
|
||||||
|
payload: {
|
||||||
|
key: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new SetQueryParameterAction
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* the key to set
|
||||||
|
* @param value
|
||||||
|
* the value of this key
|
||||||
|
*/
|
||||||
|
constructor(key: string, value: string) {
|
||||||
|
this.payload = { key, value };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ngrx action to set a parameter
|
||||||
|
*/
|
||||||
|
export class SetParameterAction implements Action {
|
||||||
|
type = RouteActionTypes.SET_PARAMETER;
|
||||||
|
payload: {
|
||||||
|
key: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new SetParameterAction
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* the key to set
|
||||||
|
* @param value
|
||||||
|
* the value of this key
|
||||||
|
*/
|
||||||
|
constructor(key: string, value: string) {
|
||||||
|
this.payload = { key, value };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ngrx action to reset the route state
|
* An ngrx action to reset the route state
|
||||||
*/
|
*/
|
||||||
@@ -113,4 +161,5 @@ export type RouteActions =
|
|||||||
| SetParametersAction
|
| SetParametersAction
|
||||||
| AddQueryParameterAction
|
| AddQueryParameterAction
|
||||||
| AddParameterAction
|
| AddParameterAction
|
||||||
| ResetRouteStateAction;
|
| ResetRouteStateAction
|
||||||
|
| SetParameterAction;
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { map } from 'rxjs/operators';
|
import { filter, map, pairwise } from 'rxjs/operators';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Actions, Effect, ofType } from '@ngrx/effects'
|
import { Actions, Effect, ofType } from '@ngrx/effects'
|
||||||
import * as fromRouter from '@ngrx/router-store';
|
import * as fromRouter from '@ngrx/router-store';
|
||||||
|
import { RouterNavigationAction } from '@ngrx/router-store';
|
||||||
import { ResetRouteStateAction } from './route.actions';
|
import { ResetRouteStateAction } from './route.actions';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RouteEffects {
|
export class RouteEffects {
|
||||||
@@ -13,10 +15,17 @@ export class RouteEffects {
|
|||||||
@Effect() routeChange$ = this.actions$
|
@Effect() routeChange$ = this.actions$
|
||||||
.pipe(
|
.pipe(
|
||||||
ofType(fromRouter.ROUTER_NAVIGATION),
|
ofType(fromRouter.ROUTER_NAVIGATION),
|
||||||
|
pairwise(),
|
||||||
|
map((actions: RouterNavigationAction[]) =>
|
||||||
|
actions.map((navigateAction) => {
|
||||||
|
const urlTree = this.router.parseUrl(navigateAction.payload.routerState.url);
|
||||||
|
return urlTree.root.children['primary'].segments.map(it => it.path).join('/');
|
||||||
|
})),
|
||||||
|
filter((actions: string[]) => actions[0] !== actions[1]),
|
||||||
map(() => new ResetRouteStateAction())
|
map(() => new ResetRouteStateAction())
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(private actions$: Actions) {
|
constructor(private actions$: Actions, private router: Router) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,11 @@ import {
|
|||||||
AddParameterAction,
|
AddParameterAction,
|
||||||
AddQueryParameterAction,
|
AddQueryParameterAction,
|
||||||
RouteActions,
|
RouteActions,
|
||||||
RouteActionTypes, SetParametersAction, SetQueryParametersAction
|
RouteActionTypes,
|
||||||
|
SetParameterAction,
|
||||||
|
SetParametersAction,
|
||||||
|
SetQueryParameterAction,
|
||||||
|
SetQueryParametersAction
|
||||||
} from './route.actions';
|
} from './route.actions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,19 +37,23 @@ export function routeReducer(state = initialState, action: RouteActions): RouteS
|
|||||||
return initialState
|
return initialState
|
||||||
}
|
}
|
||||||
case RouteActionTypes.SET_PARAMETERS: {
|
case RouteActionTypes.SET_PARAMETERS: {
|
||||||
console.log('set', action);
|
|
||||||
return setParameters(state, action as SetParametersAction, 'params');
|
return setParameters(state, action as SetParametersAction, 'params');
|
||||||
}
|
}
|
||||||
case RouteActionTypes.SET_QUERY_PARAMETERS: {
|
case RouteActionTypes.SET_QUERY_PARAMETERS: {
|
||||||
return setParameters(state, action as SetQueryParametersAction, 'queryParams');
|
return setParameters(state, action as SetQueryParametersAction, 'queryParams');
|
||||||
}
|
}
|
||||||
case RouteActionTypes.ADD_PARAMETER: {
|
case RouteActionTypes.ADD_PARAMETER: {
|
||||||
console.log('add', action);
|
|
||||||
return addParameter(state, action as AddParameterAction, 'params');
|
return addParameter(state, action as AddParameterAction, 'params');
|
||||||
}
|
}
|
||||||
case RouteActionTypes.ADD_QUERY_PARAMETER: {
|
case RouteActionTypes.ADD_QUERY_PARAMETER: {
|
||||||
return addParameter(state, action as AddQueryParameterAction, 'queryParams');
|
return addParameter(state, action as AddQueryParameterAction, 'queryParams');
|
||||||
}
|
}
|
||||||
|
case RouteActionTypes.SET_PARAMETER: {
|
||||||
|
return setParameter(state, action as SetParameterAction, 'params');
|
||||||
|
}
|
||||||
|
case RouteActionTypes.SET_QUERY_PARAMETER: {
|
||||||
|
return setParameter(state, action as SetQueryParameterAction, 'queryParams');
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -62,7 +70,7 @@ function addParameter(state: RouteState, action: AddParameterAction | AddQueryPa
|
|||||||
const subState = state[paramType];
|
const subState = state[paramType];
|
||||||
const existingValues = subState[action.payload.key] || [];
|
const existingValues = subState[action.payload.key] || [];
|
||||||
const newValues = [...existingValues, action.payload.value];
|
const newValues = [...existingValues, action.payload.value];
|
||||||
const newSubstate = Object.assign(subState, { [action.payload.key]: newValues });
|
const newSubstate = Object.assign({}, subState, { [action.payload.key]: newValues });
|
||||||
return Object.assign({}, state, { [paramType]: newSubstate });
|
return Object.assign({}, state, { [paramType]: newSubstate });
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -74,3 +82,15 @@ function addParameter(state: RouteState, action: AddParameterAction | AddQueryPa
|
|||||||
function setParameters(state: RouteState, action: SetParametersAction | SetQueryParametersAction, paramType: string): RouteState {
|
function setParameters(state: RouteState, action: SetParametersAction | SetQueryParametersAction, paramType: string): RouteState {
|
||||||
return Object.assign({}, state, { [paramType]: action.payload });
|
return Object.assign({}, state, { [paramType]: action.payload });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a route or query parameter in the store
|
||||||
|
* @param state The current state
|
||||||
|
* @param action The set action to perform on the current state
|
||||||
|
* @param paramType The type of parameter to set: route or query parameter
|
||||||
|
*/
|
||||||
|
function setParameter(state: RouteState, action: SetParameterAction | SetQueryParameterAction, paramType: string): RouteState {
|
||||||
|
const subState = state[paramType];
|
||||||
|
const newSubstate = Object.assign({}, subState, action.payload);
|
||||||
|
return Object.assign({}, state, { [paramType]: newSubstate });
|
||||||
|
}
|
@@ -14,7 +14,12 @@ import { isEqual } from 'lodash';
|
|||||||
|
|
||||||
import { AddUrlToHistoryAction } from '../history/history.actions';
|
import { AddUrlToHistoryAction } from '../history/history.actions';
|
||||||
import { historySelector } from '../history/selectors';
|
import { historySelector } from '../history/selectors';
|
||||||
import { AddParameterAction, SetParametersAction, SetQueryParametersAction } from './route.actions';
|
import {
|
||||||
|
AddParameterAction,
|
||||||
|
SetParameterAction,
|
||||||
|
SetParametersAction,
|
||||||
|
SetQueryParametersAction
|
||||||
|
} from './route.actions';
|
||||||
import { CoreState } from '../../core/core.reducers';
|
import { CoreState } from '../../core/core.reducers';
|
||||||
import { hasValue } from '../empty.util';
|
import { hasValue } from '../empty.util';
|
||||||
import { coreSelector } from '../../core/core.selectors';
|
import { coreSelector } from '../../core/core.selectors';
|
||||||
@@ -117,7 +122,7 @@ export class RouteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRouteParameterValue(paramName: string): Observable<string> {
|
getRouteParameterValue(paramName: string): Observable<string> {
|
||||||
return this.store.pipe(select(routeParameterSelector(paramName)), tap((t) => console.log('test', t)));
|
return this.store.pipe(select(routeParameterSelector(paramName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getRouteDataValue(datafield: string): Observable<any> {
|
getRouteDataValue(datafield: string): Observable<any> {
|
||||||
@@ -157,11 +162,9 @@ export class RouteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public saveRouting(): void {
|
public saveRouting(): void {
|
||||||
combineLatest(this.router.events, this.getRouteParams(), this.route.queryParams)
|
this.router.events
|
||||||
.pipe(filter(([event, params, queryParams]) => event instanceof NavigationEnd))
|
.pipe(filter((event) => event instanceof NavigationEnd))
|
||||||
.subscribe(([event, params, queryParams]: [NavigationEnd, Params, Params]) => {
|
.subscribe((event: NavigationEnd) => {
|
||||||
this.store.dispatch(new SetParametersAction(params));
|
|
||||||
this.store.dispatch(new SetQueryParametersAction(queryParams));
|
|
||||||
this.store.dispatch(new AddUrlToHistoryAction(event.urlAfterRedirects));
|
this.store.dispatch(new AddUrlToHistoryAction(event.urlAfterRedirects));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -187,4 +190,19 @@ export class RouteService {
|
|||||||
public addParameter(key, value) {
|
public addParameter(key, value) {
|
||||||
this.store.dispatch(new AddParameterAction(key, value));
|
this.store.dispatch(new AddParameterAction(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setParameter(key, value) {
|
||||||
|
this.store.dispatch(new SetParameterAction(key, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public setCurrentRouteInfo() {
|
||||||
|
combineLatest(this.getRouteParams(), this.route.queryParams)
|
||||||
|
.subscribe(
|
||||||
|
([params, queryParams]: [Params, Params]) => {
|
||||||
|
this.store.dispatch(new SetParametersAction(params));
|
||||||
|
this.store.dispatch(new SetQueryParametersAction(queryParams));
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -160,6 +160,7 @@ import { SearchFacetSelectedOptionComponent } from './search/search-filters/sear
|
|||||||
import { SearchFacetRangeOptionComponent } from './search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component';
|
import { SearchFacetRangeOptionComponent } from './search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component';
|
||||||
import { SearchSwitchConfigurationComponent } from './search/search-switch-configuration/search-switch-configuration.component';
|
import { SearchSwitchConfigurationComponent } from './search/search-switch-configuration/search-switch-configuration.component';
|
||||||
import { SearchAuthorityFilterComponent } from './search/search-filters/search-filter/search-authority-filter/search-authority-filter.component';
|
import { SearchAuthorityFilterComponent } from './search/search-filters/search-filter/search-authority-filter/search-authority-filter.component';
|
||||||
|
import { ConfigurationSearchPageComponent } from '../+search-page/configuration-search-page.component';
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||||
@@ -303,6 +304,7 @@ const COMPONENTS = [
|
|||||||
SearchFacetRangeOptionComponent,
|
SearchFacetRangeOptionComponent,
|
||||||
SearchSwitchConfigurationComponent,
|
SearchSwitchConfigurationComponent,
|
||||||
SearchAuthorityFilterComponent,
|
SearchAuthorityFilterComponent,
|
||||||
|
ConfigurationSearchPageComponent
|
||||||
];
|
];
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
|
Reference in New Issue
Block a user