mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
solve fixedfilter issue
This commit is contained in:
@@ -10,6 +10,7 @@ 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 } from 'rxjs/operators';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a simple item page.
|
* This component renders a simple item page.
|
||||||
@@ -41,8 +42,9 @@ export class FilteredSearchPageComponent extends SearchPageComponent implements
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +68,8 @@ export class FilteredSearchPageComponent extends SearchPageComponent implements
|
|||||||
return this.searchConfigService.paginatedSearchOptions.pipe(
|
return this.searchConfigService.paginatedSearchOptions.pipe(
|
||||||
map((options: PaginatedSearchOptions) => {
|
map((options: PaginatedSearchOptions) => {
|
||||||
const filter = this.fixedFilterQuery || options.fixedFilter;
|
const filter = this.fixedFilterQuery || options.fixedFilter;
|
||||||
return Object.assign(options, { fixedFilter: filter });
|
|
||||||
|
return this.routeService.addParameter({ fixedFilter: filter });
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,8 @@ import { SearchConfigurationService } from '../core/shared/search/search-configu
|
|||||||
import { getSucceededRemoteData } from '../core/shared/operators';
|
import { getSucceededRemoteData } from '../core/shared/operators';
|
||||||
import { RouteService } from '../shared/services/route.service';
|
import { RouteService } from '../shared/services/route.service';
|
||||||
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 '../shared/utils/route.utils';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
export const SEARCH_ROUTE = '/search';
|
export const SEARCH_ROUTE = '/search';
|
||||||
|
|
||||||
@@ -95,7 +97,8 @@ export class SearchPageComponent implements OnInit {
|
|||||||
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,
|
||||||
|
protected router: Router) {
|
||||||
this.isXsOrSm$ = this.windowService.isXsOrSm();
|
this.isXsOrSm$ = this.windowService.isXsOrSm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +159,7 @@ export class SearchPageComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.service.getSearchLink();
|
return this.service.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -204,7 +204,8 @@ export class SearchConfigurationService implements OnDestroy {
|
|||||||
*/
|
*/
|
||||||
getCurrentFixedFilter(): Observable<string> {
|
getCurrentFixedFilter(): Observable<string> {
|
||||||
return this.routeService.getRouteParameterValue('filter').pipe(
|
return this.routeService.getRouteParameterValue('filter').pipe(
|
||||||
switchMap((f) => this.fixedFilterService.getQueryByFilterName(f))
|
switchMap((f) => this.fixedFilterService.getQueryByFilterName(f)),
|
||||||
|
tap((t) => console.log(t))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,8 @@
|
|||||||
<button class="btn btn-outline-secondary" type="submit">Go</button>
|
<button class="btn btn-outline-secondary" type="submit">Go</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<ds-search-results [searchResults]="resultsRD" [sortConfig]="this.searchConfig.sort"
|
<ds-search-results [searchResults]="resultsRD"
|
||||||
|
[sortConfig]="this.searchConfig?.sort"
|
||||||
[searchConfig]="this.searchConfig"
|
[searchConfig]="this.searchConfig"
|
||||||
[selectable]="true"
|
[selectable]="true"
|
||||||
[selectionConfig]="{ repeatable: repeatable, listId: listId }">
|
[selectionConfig]="{ repeatable: repeatable, listId: listId }">
|
||||||
|
@@ -9,7 +9,7 @@ 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, take, takeWhile } from 'rxjs/operators';
|
import { concat, map, multicast, switchMap, take, takeWhile } from 'rxjs/operators';
|
||||||
import { Router } from '@angular/router';
|
import { 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';
|
||||||
@@ -44,43 +44,43 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
|
|||||||
pageSize: 10
|
pageSize: 10
|
||||||
});
|
});
|
||||||
selection: Observable<ListableObject[]>;
|
selection: Observable<ListableObject[]>;
|
||||||
|
fixedFilter: string;
|
||||||
constructor(public modal: NgbActiveModal, private searchService: SearchService, private router: Router, private selectableListService: SelectableListService) {
|
constructor(public modal: NgbActiveModal, private searchService: SearchService, private router: Router, private selectableListService: SelectableListService, private searchConfigService: SearchConfigurationService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.resetRoute();
|
this.resetRoute();
|
||||||
this.onPaginationChange(this.initialPagination);
|
this.fixedFilter = RELATION_TYPE_FILTER_PREFIX + this.fieldName;
|
||||||
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(
|
||||||
|
map((options) => {
|
||||||
|
return Object.assign(new PaginatedSearchOptions({}), options, { fixedFilter: RELATION_TYPE_FILTER_PREFIX + this.fieldName })
|
||||||
|
}),
|
||||||
|
switchMap((options) => {
|
||||||
|
this.searchConfig = options;
|
||||||
|
return this.searchService.search(options).pipe(
|
||||||
|
/* Make sure to only listen to the first x results, until loading is finished */
|
||||||
|
/* TODO: in Rxjs 6.4.0 and up, we can replace this by takeWhile(predicate, true) - see https://stackoverflow.com/a/44644237 */
|
||||||
|
multicast(
|
||||||
|
() => new ReplaySubject(1),
|
||||||
|
subject => subject.pipe(
|
||||||
|
takeWhile((rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => rd.isLoading),
|
||||||
|
concat(subject.pipe(take(1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) as any
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
search(query: string) {
|
search(query: string) {
|
||||||
this.searchQuery = query;
|
this.searchQuery = query;
|
||||||
this.resetRoute();
|
this.resetRoute();
|
||||||
this.onPaginationChange(this.initialPagination);
|
|
||||||
this.selectableListService.deselectAll(this.listId);
|
this.selectableListService.deselectAll(this.listId);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPaginationChange(pagination: PaginationComponentOptions) {
|
|
||||||
this.searchConfig = new PaginatedSearchOptions({
|
|
||||||
query: this.searchQuery,
|
|
||||||
pagination: pagination,
|
|
||||||
fixedFilter: RELATION_TYPE_FILTER_PREFIX + this.fieldName
|
|
||||||
});
|
|
||||||
this.resultsRD$ = this.searchService.search(this.searchConfig).pipe(
|
|
||||||
/* Make sure to only listen to the first x results, until loading is finished */
|
|
||||||
/* TODO: in Rxjs 6.4.0 and up, we can replace this by takeWhile(predicate, true) - see https://stackoverflow.com/a/44644237 */
|
|
||||||
multicast(
|
|
||||||
() => new ReplaySubject(1),
|
|
||||||
subject => subject.pipe(
|
|
||||||
takeWhile((rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => rd.isLoading),
|
|
||||||
concat(subject.pipe(take(1))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) as any
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.modal.close();
|
this.modal.close();
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ import { hasValue, isNotEmpty } from '../empty.util';
|
|||||||
import { QueryParamsHandling } from '@angular/router/src/config';
|
import { QueryParamsHandling } from '@angular/router/src/config';
|
||||||
import { MYDSPACE_ROUTE } from '../../+my-dspace-page/my-dspace-page.component';
|
import { MYDSPACE_ROUTE } from '../../+my-dspace-page/my-dspace-page.component';
|
||||||
import { SearchService } from '../../core/shared/search/search.service';
|
import { SearchService } from '../../core/shared/search/search.service';
|
||||||
|
import { currentPath } from '../utils/route.utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a simple item page.
|
* This component renders a simple item page.
|
||||||
@@ -87,7 +88,7 @@ export class SearchFormComponent {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
<a *ngIf="isVisible | async" class="d-flex flex-row"
|
<a *ngIf="isVisible | async" class="d-flex flex-row" [routerLink]="[getSearchLink()]"
|
||||||
[routerLink]="[getSearchLink()]"
|
|
||||||
[queryParams]="addQueryParams" queryParamsHandling="merge">
|
[queryParams]="addQueryParams" queryParamsHandling="merge">
|
||||||
<input type="checkbox" [checked]="false" class="my-1 align-self-stretch"/>
|
<input type="checkbox" [checked]="false" class="my-1 align-self-stretch"/>
|
||||||
<span class="filter-value px-1">{{filterValue.value}}</span>
|
<span class="filter-value px-1">{{filterValue.value}}</span>
|
||||||
|
@@ -9,6 +9,7 @@ import { SearchFilterService } from '../../../../../../core/shared/search/search
|
|||||||
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
||||||
import { hasValue } from '../../../../../empty.util';
|
import { hasValue } from '../../../../../empty.util';
|
||||||
import { FilterType } from '../../../../filter-type.model';
|
import { FilterType } from '../../../../filter-type.model';
|
||||||
|
import { currentPath } from '../../../../../utils/route.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-facet-option',
|
selector: 'ds-search-facet-option',
|
||||||
@@ -85,7 +86,7 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import {
|
|||||||
} from '../../search-range-filter/search-range-filter.component';
|
} from '../../search-range-filter/search-range-filter.component';
|
||||||
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
||||||
import { hasValue } from '../../../../../empty.util';
|
import { hasValue } from '../../../../../empty.util';
|
||||||
|
import { currentPath } from '../../../../../utils/route.utils';
|
||||||
|
|
||||||
const rangeDelimiter = '-';
|
const rangeDelimiter = '-';
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ import { hasValue } from '../../../../../empty.util';
|
|||||||
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
|
||||||
import { FacetValue } from '../../../../facet-value.model';
|
import { FacetValue } from '../../../../facet-value.model';
|
||||||
import { FilterType } from '../../../../filter-type.model';
|
import { FilterType } from '../../../../filter-type.model';
|
||||||
|
import { currentPath } from '../../../../../utils/route.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-facet-selected-option',
|
selector: 'ds-search-facet-selected-option',
|
||||||
@@ -71,7 +72,7 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -179,7 +179,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return '';
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Component, Inject, Input, OnInit } from '@angular/core';
|
import { Component, Inject, Input, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map, switchMap } from 'rxjs/operators';
|
import { map, switchMap, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { SearchService } from '../../../core/shared/search/search.service';
|
import { SearchService } from '../../../core/shared/search/search.service';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
@@ -10,6 +10,8 @@ import { SearchConfigurationService } from '../../../core/shared/search/search-c
|
|||||||
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 } 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 { Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-filters',
|
selector: 'ds-search-filters',
|
||||||
@@ -46,11 +48,13 @@ export class SearchFiltersComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
private filterService: SearchFilterService,
|
private filterService: SearchFilterService,
|
||||||
|
private router: Router,
|
||||||
@Inject(SEARCH_CONFIG_SERVICE) private searchConfigService: SearchConfigurationService) {
|
@Inject(SEARCH_CONFIG_SERVICE) private searchConfigService: SearchConfigurationService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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()))
|
||||||
);
|
);
|
||||||
@@ -66,7 +70,7 @@ export class SearchFiltersComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { Component, Inject, Input } from '@angular/core';
|
import { Component, Inject, Input } from '@angular/core';
|
||||||
import { SearchService } from '../../../core/shared/search/search.service';
|
import { SearchService } from '../../../core/shared/search/search.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Params } from '@angular/router';
|
import { Params, Router } from '@angular/router';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { hasValue, isNotEmpty } from '../../empty.util';
|
import { hasValue, isNotEmpty } from '../../empty.util';
|
||||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||||
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 { RouteService } from '../../services/route.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-labels',
|
selector: 'ds-search-labels',
|
||||||
@@ -32,6 +34,7 @@ export class SearchLabelsComponent {
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
|
protected router: Router,
|
||||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
|
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
|
||||||
this.appliedFilters = this.searchConfigService.getCurrentFrontendFilters();
|
this.appliedFilters = this.searchConfigService.getCurrentFrontendFilters();
|
||||||
}
|
}
|
||||||
@@ -60,7 +63,7 @@ export class SearchLabelsComponent {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@ import { PaginatedSearchOptions } from '../paginated-search-options.model';
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||||
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';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-settings',
|
selector: 'ds-search-settings',
|
||||||
@@ -84,7 +85,7 @@ export class SearchSettingsComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.service.getSearchLink();
|
return this.service.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ import { SearchConfigurationService } from '../../../core/shared/search/search-c
|
|||||||
import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type';
|
import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type';
|
||||||
import { SearchConfigurationOption } from './search-configuration-option.model';
|
import { SearchConfigurationOption } from './search-configuration-option.model';
|
||||||
import { SearchService } from '../../../core/shared/search/search.service';
|
import { SearchService } from '../../../core/shared/search/search.service';
|
||||||
|
import { currentPath } from '../../utils/route.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-switch-configuration',
|
selector: 'ds-search-switch-configuration',
|
||||||
@@ -87,7 +88,7 @@ export class SearchSwitchConfigurationComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
@@ -33,12 +33,14 @@ 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: {
|
||||||
|
@@ -14,7 +14,7 @@ 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 { SetParametersAction, SetQueryParametersAction } from './route.actions';
|
import { AddParameterAction, 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 +117,7 @@ export class RouteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRouteParameterValue(paramName: string): Observable<string> {
|
getRouteParameterValue(paramName: string): Observable<string> {
|
||||||
return this.store.pipe(select(routeParameterSelector(paramName)));
|
return this.store.pipe(select(routeParameterSelector(paramName)), tap((t) => console.log('test', t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getRouteDataValue(datafield: string): Observable<any> {
|
getRouteDataValue(datafield: string): Observable<any> {
|
||||||
@@ -183,4 +183,8 @@ export class RouteService {
|
|||||||
map((history: string[]) => history[history.length - 2] || '')
|
map((history: string[]) => history[history.length - 2] || '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addParameter(key, value) {
|
||||||
|
this.store.dispatch(new AddParameterAction(key, value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
6
src/app/shared/utils/route.utils.ts
Normal file
6
src/app/shared/utils/route.utils.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
export function currentPath(router: Router) {
|
||||||
|
const urlTree = router.parseUrl(router.url);
|
||||||
|
return '/' + urlTree.root.children['primary'].segments.map(it => it.path).join('/')
|
||||||
|
}
|
@@ -5,6 +5,9 @@ import { Subscription } from 'rxjs';
|
|||||||
import { SearchService } from '../../core/shared/search/search.service';
|
import { SearchService } from '../../core/shared/search/search.service';
|
||||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||||
import { isEmpty } from '../empty.util';
|
import { isEmpty } from '../empty.util';
|
||||||
|
import { currentPath } from '../utils/route.utils';
|
||||||
|
import { RouteService } from '../services/route.service';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to switch between list and grid views.
|
* Component to switch between list and grid views.
|
||||||
@@ -26,7 +29,7 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy {
|
|||||||
viewModeEnum = ViewMode;
|
viewModeEnum = ViewMode;
|
||||||
private sub: Subscription;
|
private sub: Subscription;
|
||||||
|
|
||||||
constructor(private searchService: SearchService) {
|
constructor(private searchService: SearchService, private router: Router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -58,7 +61,7 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public getSearchLink(): string {
|
public getSearchLink(): string {
|
||||||
if (this.inPlaceSearch) {
|
if (this.inPlaceSearch) {
|
||||||
return './';
|
return currentPath(this.router);
|
||||||
}
|
}
|
||||||
return this.searchService.getSearchLink();
|
return this.searchService.getSearchLink();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user