Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Ignore search value in filter reset button #1065

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FieldFilters } from '@geonetwork-ui/common/domain/model/search'

class SearchFacadeMock {
searchFilters$ = new BehaviorSubject<FieldFilters>({
any: 'search should be ignored',
format: {},
isSpatial: {},
license: {},
Expand Down Expand Up @@ -94,7 +95,9 @@ describe('SearchFiltersSummaryComponent', () => {

it('should clear filters', () => {
component.clearFilters()
expect(searchService.setFilters).toHaveBeenCalledWith({})
expect(searchService.setFilters).toHaveBeenCalledWith({
any: 'search should be ignored',
})
})
})

Expand Down Expand Up @@ -139,6 +142,7 @@ describe('SearchFiltersSummaryComponent', () => {
it('should clear filters except with keys from FILTER_SUMMARY_IGNORE_LIST', () => {
const filters = {
owner: { 1: true },
any: 'search should be ignored',
format: {},
isSpatial: {},
license: {},
Expand All @@ -150,6 +154,7 @@ describe('SearchFiltersSummaryComponent', () => {
component.clearFilters()
expect(searchService.setFilters).toHaveBeenCalledWith({
owner: { 1: true },
any: 'search should be ignored',
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class SearchFiltersSummaryComponent implements OnInit {
filteredFilters[key] = value
}
}
delete filteredFilters['any'] //ignore search field
return Object.values(filteredFilters).some(
(value) =>
value !== undefined &&
Expand All @@ -62,7 +63,7 @@ export class SearchFiltersSummaryComponent implements OnInit {
map((filters) => {
const newFilters = { ...filters }
Object.keys(newFilters).forEach((key) => {
if (!this.filterSummaryIgnoreList.includes(key)) {
if (!this.filterSummaryIgnoreList.includes(key) && key !== 'any') {
delete newFilters[key]
}
})
Expand Down
Loading