diff --git a/apps/metadata-editor/src/app/dashboard/dashboard-menu/dashboard-menu.component.html b/apps/metadata-editor/src/app/dashboard/dashboard-menu/dashboard-menu.component.html index 389d27da2a..547abf9c4c 100644 --- a/apps/metadata-editor/src/app/dashboard/dashboard-menu/dashboard-menu.component.html +++ b/apps/metadata-editor/src/app/dashboard/dashboard-menu/dashboard-menu.component.html @@ -3,6 +3,7 @@ dashboard.labels.mySpace
+ diff --git a/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts b/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts index 1c3490f5c5..04a219aa90 100644 --- a/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts +++ b/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts @@ -1,9 +1,10 @@ import { CommonModule } from '@angular/common' -import { ChangeDetectionStrategy, Component } from '@angular/core' +import { ChangeDetectionStrategy, Component, ViewChild } from '@angular/core' import { MatIconModule } from '@angular/material/icon' import { LetDirective } from '@ngrx/component' import { FeatureSearchModule, + FuzzySearchComponent, SearchService, } from '@geonetwork-ui/feature/search' import { UiElementsModule } from '@geonetwork-ui/ui/elements' @@ -11,6 +12,7 @@ import { AvatarServiceInterface } from '@geonetwork-ui/api/repository' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' import { TranslateModule } from '@ngx-translate/core' import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' +import { RouterFacade } from '@geonetwork-ui/feature/router' @Component({ selector: 'md-editor-search-header', @@ -30,12 +32,18 @@ import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export class SearchHeaderComponent { public placeholder$ = this.avatarService.getPlaceholder() activeBtn = false + @ViewChild('fuzzySearch') fuzzySearch: FuzzySearchComponent constructor( public platformService: PlatformServiceInterface, private avatarService: AvatarServiceInterface, - private searchService: SearchService - ) {} + private searchService: SearchService, + private routerFacade: RouterFacade + ) { + this.routerFacade.currentRoute$.subscribe(() => { + this.fuzzySearch?.autocomplete?.clear() + }) + } handleItemSelection(item: CatalogRecord) { this.searchService.updateFilters({ any: item.title }) diff --git a/apps/metadata-editor/src/app/records/all-records/all-records.component.ts b/apps/metadata-editor/src/app/records/all-records/all-records.component.ts index 8c0634473b..e5d5804c1c 100644 --- a/apps/metadata-editor/src/app/records/all-records/all-records.component.ts +++ b/apps/metadata-editor/src/app/records/all-records/all-records.component.ts @@ -3,7 +3,6 @@ import { ChangeDetectorRef, Component, ElementRef, - OnInit, TemplateRef, ViewChild, ViewContainerRef, @@ -62,7 +61,7 @@ export const allSearchFields = [ RecordsListComponent, ], }) -export class AllRecordsComponent implements OnInit { +export class AllRecordsComponent { @ViewChild('importRecordButton', { read: ElementRef }) importRecordButton!: ElementRef @ViewChild('template') template!: TemplateRef @@ -85,11 +84,6 @@ export class AllRecordsComponent implements OnInit { private cdr: ChangeDetectorRef ) {} - ngOnInit(): void { - this.searchFacade.setConfigRequestFields(allSearchFields) - this.searchFacade.setPageSize(15) - } - createRecord() { this.router.navigate(['/create']).catch((err) => console.error(err)) } diff --git a/apps/metadata-editor/src/app/records/my-records/my-records.component.ts b/apps/metadata-editor/src/app/records/my-records/my-records.component.ts index 028dcf33f9..cbadf029df 100644 --- a/apps/metadata-editor/src/app/records/my-records/my-records.component.ts +++ b/apps/metadata-editor/src/app/records/my-records/my-records.component.ts @@ -2,7 +2,6 @@ import { ChangeDetectorRef, Component, ElementRef, - OnDestroy, OnInit, TemplateRef, ViewChild, @@ -17,11 +16,10 @@ import { ResultsTableContainerComponent, SearchFacade, } from '@geonetwork-ui/feature/search' -import { Subscription } from 'rxjs' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' import { UiElementsModule } from '@geonetwork-ui/ui/elements' import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' -import { ActivatedRoute, Router } from '@angular/router' +import { Router } from '@angular/router' import { Overlay, OverlayRef } from '@angular/cdk/overlay' import { TemplatePortal } from '@angular/cdk/portal' import { allSearchFields } from '../all-records/all-records.component' @@ -48,10 +46,7 @@ import { ImportRecordComponent } from '@geonetwork-ui/feature/editor' FeatureSearchModule, ], }) -export class MyRecordsComponent implements OnInit, OnDestroy { - private sub: Subscription - ownerId: string - +export class MyRecordsComponent implements OnInit { @ViewChild('importRecordButton', { read: ElementRef }) private importRecordButton!: ElementRef @ViewChild('template') template!: TemplateRef @@ -61,7 +56,6 @@ export class MyRecordsComponent implements OnInit, OnDestroy { constructor( private router: Router, - private activedRoute: ActivatedRoute, protected searchFacade: SearchFacade, private platformService: PlatformServiceInterface, private fieldsService: FieldsService, @@ -74,8 +68,7 @@ export class MyRecordsComponent implements OnInit, OnDestroy { this.searchFacade.setConfigRequestFields(allSearchFields) this.searchFacade.setPageSize(15) - this.sub = this.platformService.getMe().subscribe((user) => { - this.ownerId = user.id + this.platformService.getMe().subscribe((user) => { this.fieldsService .buildFiltersFromFieldValues({ owner: user.id }) .subscribe((filters) => { @@ -132,8 +125,4 @@ export class MyRecordsComponent implements OnInit, OnDestroy { this.cdr.markForCheck() } } - - ngOnDestroy(): void { - this.sub.unsubscribe() - } } diff --git a/apps/metadata-editor/src/app/records/records-list.component.ts b/apps/metadata-editor/src/app/records/records-list.component.ts index 96645eefda..b92e7549f1 100644 --- a/apps/metadata-editor/src/app/records/records-list.component.ts +++ b/apps/metadata-editor/src/app/records/records-list.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common' -import { Component } from '@angular/core' +import { Component, OnInit } from '@angular/core' import { MatIconModule } from '@angular/material/icon' import { Router } from '@angular/router' import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @@ -13,6 +13,7 @@ import { UiElementsModule } from '@geonetwork-ui/ui/elements' import { TranslateModule } from '@ngx-translate/core' import { UiInputsModule } from '@geonetwork-ui/ui/inputs' import { RecordsCountComponent } from './records-count/records-count.component' +import { allSearchFields } from './all-records/all-records.component' @Component({ selector: 'md-editor-records-list', @@ -30,13 +31,18 @@ import { RecordsCountComponent } from './records-count/records-count.component' RecordsCountComponent, ], }) -export class RecordsListComponent { +export class RecordsListComponent implements OnInit { constructor( private router: Router, public searchFacade: SearchFacade, private searchService: SearchService ) {} + ngOnInit(): void { + this.searchFacade.setConfigRequestFields(allSearchFields) + this.searchFacade.setPageSize(15) + } + paginate(page: number) { this.searchService.setPage(page) } diff --git a/libs/feature/router/src/lib/default/state/router.facade.ts b/libs/feature/router/src/lib/default/state/router.facade.ts index c2f9dd2054..1186f2fa18 100644 --- a/libs/feature/router/src/lib/default/state/router.facade.ts +++ b/libs/feature/router/src/lib/default/state/router.facade.ts @@ -3,7 +3,7 @@ import { MdViewActions } from '@geonetwork-ui/feature/record' import { RouterService } from '../router.service' import { RouterReducerState } from '@ngrx/router-store' import { select, Store } from '@ngrx/store' -import { distinctUntilChanged, filter, map, take, tap } from 'rxjs/operators' +import { distinctUntilChanged, filter, map, take } from 'rxjs/operators' import { ROUTER_ROUTE_DATASET, ROUTER_ROUTE_SEARCH,