diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
index 5b76e1b93..07e5185ad 100644
--- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
+++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
@@ -272,10 +272,6 @@ describe('dashboard (authenticated)', () => {
cy.get('md-editor-dashboard-menu').find('a').eq(5).click()
cy.get('gn-ui-autocomplete').should('have.value', '')
})
- it('should hide the search input when navigating to my drafts', () => {
- cy.get('md-editor-dashboard-menu').find('a').eq(4).click()
- cy.get('gn-ui-autocomplete').should('not.exist')
- })
})
describe('myRecords search input', () => {
beforeEach(() => {
@@ -293,6 +289,14 @@ describe('dashboard (authenticated)', () => {
cy.get('md-editor-dashboard-menu').find('a').first().click()
cy.get('gn-ui-autocomplete').should('have.value', '')
})
+ it('should allow to search in the entire catalog', () => {
+ cy.get('gn-ui-autocomplete').type('mat{enter}')
+ cy.get('gn-ui-interactive-table')
+ .find('[data-cy="table-row"]')
+ .should('have.length', '1')
+ cy.url().should('include', '/search?q=mat')
+ cy.url().should('not.include', 'owner')
+ })
})
})
describe('search filters', () => {
diff --git a/apps/metadata-editor/src/app/dashboard/dashboard-page.component.html b/apps/metadata-editor/src/app/dashboard/dashboard-page.component.html
index a01307fce..b0bee6b00 100644
--- a/apps/metadata-editor/src/app/dashboard/dashboard-page.component.html
+++ b/apps/metadata-editor/src/app/dashboard/dashboard-page.component.html
@@ -7,6 +7,9 @@
+
diff --git a/apps/metadata-editor/src/app/records/all-records/all-records.component.html b/apps/metadata-editor/src/app/records/all-records/all-records.component.html
index 3cd22212c..29ac1b8ca 100644
--- a/apps/metadata-editor/src/app/records/all-records/all-records.component.html
+++ b/apps/metadata-editor/src/app/records/all-records/all-records.component.html
@@ -1,6 +1,3 @@
-
diff --git a/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts b/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts
index a1bc98c57..c33a1b77d 100644
--- a/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts
+++ b/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts
@@ -6,7 +6,7 @@ import {
} from '@geonetwork-ui/feature/search'
import { ChangeDetectionStrategy } from '@angular/core'
import { TranslateModule } from '@ngx-translate/core'
-import { BehaviorSubject, of } from 'rxjs'
+import { BehaviorSubject, firstValueFrom, of } from 'rxjs'
import { barbieUserFixture } from '@geonetwork-ui/common/fixtures'
import { ActivatedRoute, Router } from '@angular/router'
import { AllRecordsComponent } from './all-records.component'
@@ -25,6 +25,7 @@ describe('AllRecordsComponent', () => {
const searchFilters = new BehaviorSubject({
any: 'hello world',
+ owner: {},
})
let component: AllRecordsComponent
@@ -34,6 +35,7 @@ describe('AllRecordsComponent', () => {
let searchFacade: SearchFacade
let platformService: PlatformServiceInterface
let fieldsService: FieldsService
+ let searchService: SearchService
beforeEach(() => {
return MockBuilder(AllRecordsComponent)
@@ -76,6 +78,7 @@ describe('AllRecordsComponent', () => {
router = TestBed.inject(Router)
searchFacade = TestBed.inject(SearchFacade)
+ searchService = TestBed.inject(SearchService)
platformService = TestBed.inject(PlatformServiceInterface)
fieldsService = TestBed.inject(FieldsService)
@@ -103,6 +106,8 @@ describe('AllRecordsComponent', () => {
searchFacade.setPageSize = jest.fn(() => this)
searchFacade.setConfigRequestFields = jest.fn(() => this)
+ searchService.setFilters = jest.fn(() => this)
+
component = fixture.componentInstance
fixture.detectChanges()
@@ -119,6 +124,35 @@ describe('AllRecordsComponent', () => {
})
})
+ describe('when updating the search filters', () => {
+ beforeEach(() => {
+ searchFilters.next({ any: 'new search', owner: { 1: true } })
+ })
+
+ it('updates the search text', async () => {
+ const searchText = await firstValueFrom(component.searchText$)
+ expect(searchText).toBe('new search')
+ })
+ it('resets the owner filter', () => {
+ expect(searchService.setFilters).toHaveBeenCalledWith({
+ any: 'new search',
+ })
+ })
+ })
+
+ describe('when destroying the component', () => {
+ beforeEach(() => {
+ component.ngOnDestroy()
+ })
+
+ it('resets the search filters', () => {
+ expect(searchFacade.updateFilters).toHaveBeenCalledWith({ any: '' })
+ })
+ it('unsubscribes from component subscription', () => {
+ expect(component.subscription.closed).toBe(true)
+ })
+ })
+
describe('when clicking createRecord', () => {
beforeEach(() => {
component.createRecord()
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 4b68e87f5..7a025b0ee 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,32 +3,24 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
+ OnDestroy,
+ OnInit,
TemplateRef,
ViewChild,
ViewContainerRef,
} from '@angular/core'
-import {
- ResultsTableContainerComponent,
- SearchFacade,
- SearchService,
-} from '@geonetwork-ui/feature/search'
+import { SearchFacade, SearchService } from '@geonetwork-ui/feature/search'
import { TranslateModule } from '@ngx-translate/core'
import { Router } from '@angular/router'
import { RecordsCountComponent } from '../records-count/records-count.component'
-import { Observable } from 'rxjs'
+import { Observable, Subscription } from 'rxjs'
import { UiElementsModule } from '@geonetwork-ui/ui/elements'
import { UiInputsModule } from '@geonetwork-ui/ui/inputs'
-import {
- CdkConnectedOverlay,
- CdkOverlayOrigin,
- Overlay,
- OverlayRef,
-} from '@angular/cdk/overlay'
+import { CdkOverlayOrigin, Overlay, OverlayRef } from '@angular/cdk/overlay'
import { TemplatePortal } from '@angular/cdk/portal'
import { ImportRecordComponent } from '@geonetwork-ui/feature/editor'
import { RecordsListComponent } from '../records-list.component'
-import { map } from 'rxjs/operators'
-import { SearchHeaderComponent } from '../../dashboard/search-header/search-header.component'
+import { map, take } from 'rxjs/operators'
import { SearchFiltersComponent } from '../../dashboard/search-filters/search-filters.component'
import {
NgIconComponent,
@@ -50,14 +42,11 @@ import {
CommonModule,
TranslateModule,
RecordsCountComponent,
- ResultsTableContainerComponent,
UiElementsModule,
UiInputsModule,
ImportRecordComponent,
CdkOverlayOrigin,
- CdkConnectedOverlay,
RecordsListComponent,
- SearchHeaderComponent,
SearchFiltersComponent,
NgIconComponent,
],
@@ -72,16 +61,14 @@ import {
}),
],
})
-export class AllRecordsComponent {
+export class AllRecordsComponent implements OnInit, OnDestroy {
@ViewChild('importRecordButton', { read: ElementRef })
importRecordButton!: ElementRef
@ViewChild('template') template!: TemplateRef
private overlayRef!: OverlayRef
searchFields = ['user', 'changeDate']
- searchText$: Observable =
- this.searchFacade.searchFilters$.pipe(
- map((filters) => ('any' in filters ? (filters['any'] as string) : null))
- )
+ searchText$: Observable
+ subscription: Subscription
isImportMenuOpen = false
@@ -94,6 +81,31 @@ export class AllRecordsComponent {
private cdr: ChangeDetectorRef
) {}
+ ngOnInit() {
+ this.subscription = this.searchFacade.searchFilters$
+ .pipe(
+ map((filters) => {
+ if ('owner' in filters) {
+ const { owner, ...rest } = filters
+ return rest
+ }
+ return filters
+ }),
+ take(1)
+ )
+ .subscribe((filters) => {
+ this.searchService.setFilters(filters)
+ })
+ this.searchText$ = this.searchFacade.searchFilters$.pipe(
+ map((filters) => ('any' in filters ? (filters['any'] as string) : null))
+ )
+ }
+
+ ngOnDestroy() {
+ this.searchFacade.updateFilters({ any: '' })
+ this.subscription.unsubscribe()
+ }
+
createRecord() {
this.router.navigate(['/create']).catch((err) => console.error(err))
}
diff --git a/apps/metadata-editor/src/app/records/my-draft/my-draft.component.html b/apps/metadata-editor/src/app/records/my-draft/my-draft.component.html
index f65d41a99..fdfb8f206 100644
--- a/apps/metadata-editor/src/app/records/my-draft/my-draft.component.html
+++ b/apps/metadata-editor/src/app/records/my-draft/my-draft.component.html
@@ -1,7 +1,6 @@
-
-
+
dashboard.records.myDraft
diff --git a/apps/metadata-editor/src/app/records/my-draft/my-draft.component.ts b/apps/metadata-editor/src/app/records/my-draft/my-draft.component.ts
index 2cf263ff8..5d59d4e53 100644
--- a/apps/metadata-editor/src/app/records/my-draft/my-draft.component.ts
+++ b/apps/metadata-editor/src/app/records/my-draft/my-draft.component.ts
@@ -12,7 +12,7 @@ import { startWith, switchMap } from 'rxjs'
import { RecordsCountComponent } from '../records-count/records-count.component'
import { RecordsListComponent } from '../records-list.component'
@Component({
- selector: 'md-editor-my-my-draft',
+ selector: 'md-editor-my-draft',
templateUrl: './my-draft.component.html',
styleUrls: ['./my-draft.component.css'],
standalone: true,
diff --git a/apps/metadata-editor/src/app/records/my-records/my-records.component.html b/apps/metadata-editor/src/app/records/my-records/my-records.component.html
index 2864f6a74..2ee7cfac9 100644
--- a/apps/metadata-editor/src/app/records/my-records/my-records.component.html
+++ b/apps/metadata-editor/src/app/records/my-records/my-records.component.html
@@ -1,28 +1,13 @@
-
-
-
- dashboard.records.search
-
-
-
-
-
-
-
+
+
dashboard.records.myRecords
-
+
{
owner: user.id,
})
})
-
- it('should map search filters to searchText$', (done) => {
- component.searchText$.subscribe((text) => {
- expect(text).toBe('hello world')
- done()
- })
- })
})
})
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 de10855ff..e255dff1d 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
@@ -24,8 +24,6 @@ import { TemplatePortal } from '@angular/cdk/portal'
import { RecordsCountComponent } from '../records-count/records-count.component'
import { ButtonComponent } from '@geonetwork-ui/ui/inputs'
import { ImportRecordComponent } from '@geonetwork-ui/feature/editor'
-import { SearchHeaderComponent } from '../../dashboard/search-header/search-header.component'
-import { map, Observable } from 'rxjs'
import { SearchFiltersComponent } from '../../dashboard/search-filters/search-filters.component'
import {
NgIconComponent,
@@ -54,7 +52,6 @@ const FILTER_OWNER = 'owner'
ButtonComponent,
ImportRecordComponent,
FeatureSearchModule,
- SearchHeaderComponent,
SearchFiltersComponent,
NgIconComponent,
],
@@ -76,7 +73,6 @@ export class MyRecordsComponent implements OnInit {
@ViewChild('template') template!: TemplateRef
private overlayRef!: OverlayRef
searchFields = ['changeDate']
- searchText$: Observable
isImportMenuOpen = false
@@ -100,10 +96,6 @@ export class MyRecordsComponent implements OnInit {
this.searchFacade.updateFilters(filters)
})
})
-
- this.searchText$ = this.searchFacade.searchFilters$.pipe(
- map((filters) => ('any' in filters ? (filters['any'] as string) : null))
- )
}
createRecord() {