-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1015 from geonetwork/me-search-filters
[ME]: Add search filters
- Loading branch information
Showing
24 changed files
with
235 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
13 changes: 13 additions & 0 deletions
13
apps/metadata-editor/src/app/dashboard/search-filters/search-filters.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div | ||
class="flex flex-row py-3 px-4 gap-4 shadow-md shadow-gray-300 border-[1px] border-gray-200 overflow-hidden rounded bg-white grow mx-[32px] my-[16px] text-sm" | ||
> | ||
<mat-icon class="material-symbols-outlined">filter_list</mat-icon> | ||
<gn-ui-filter-dropdown | ||
*ngFor="let filter of searchConfig; let i = index" | ||
[fieldName]="filter.fieldName" | ||
[title]="filter.title | translate" | ||
[style.--gn-ui-button-height]="'32px'" | ||
[style.--gn-ui-multiselect-counter-text-color]="'var(--color-primary)'" | ||
[style.--gn-ui-multiselect-counter-background-color]="'white'" | ||
></gn-ui-filter-dropdown> | ||
</div> |
44 changes: 44 additions & 0 deletions
44
apps/metadata-editor/src/app/dashboard/search-filters/search-filters.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
import { SearchFiltersComponent } from './search-filters.component' | ||
import { MockBuilder } from 'ng-mocks' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
|
||
describe('SearchFiltersComponent', () => { | ||
let component: SearchFiltersComponent | ||
let fixture: ComponentFixture<SearchFiltersComponent> | ||
|
||
beforeEach(() => { | ||
return MockBuilder(SearchFiltersComponent) | ||
}) | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SearchFiltersComponent, TranslateModule.forRoot()], | ||
}).compileComponents() | ||
fixture = TestBed.createComponent(SearchFiltersComponent) | ||
component = fixture.componentInstance | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
describe('searchFields', () => { | ||
it('should correctly read searchFields and create searchConfig', () => { | ||
const searchFields = ['user', 'publisherOrg', 'format', 'isSpatial'] | ||
component.searchFields = searchFields | ||
fixture.detectChanges() | ||
expect(component.searchConfig).toEqual([ | ||
{ fieldName: 'user', title: 'search.filters.user' }, | ||
{ fieldName: 'publisherOrg', title: 'search.filters.publisherOrg' }, | ||
{ fieldName: 'format', title: 'search.filters.format' }, | ||
{ fieldName: 'isSpatial', title: 'search.filters.isSpatial' }, | ||
]) | ||
}) | ||
it('should read empty searchFields and create empty searchConfig', () => { | ||
component.searchFields = [] | ||
fixture.detectChanges() | ||
expect(component.searchConfig).toEqual([]) | ||
}) | ||
}) | ||
}) |
24 changes: 24 additions & 0 deletions
24
apps/metadata-editor/src/app/dashboard/search-filters/search-filters.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Component, Input, OnInit } from '@angular/core' | ||
import { CommonModule } from '@angular/common' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
import { FeatureSearchModule } from '@geonetwork-ui/feature/search' | ||
import { MatIconModule } from '@angular/material/icon' | ||
|
||
@Component({ | ||
selector: 'md-editor-search-filters', | ||
standalone: true, | ||
imports: [CommonModule, TranslateModule, FeatureSearchModule, MatIconModule], | ||
templateUrl: './search-filters.component.html', | ||
styleUrls: ['./search-filters.component.css'], | ||
}) | ||
export class SearchFiltersComponent implements OnInit { | ||
@Input() searchFields: string[] = [] | ||
searchConfig: { fieldName: string; title: string }[] | ||
|
||
ngOnInit(): void { | ||
this.searchConfig = this.searchFields.map((filter) => ({ | ||
fieldName: filter, | ||
title: `search.filters.${filter}`, | ||
})) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.