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: Add a search filters summary component #1037

Draft
wants to merge 7 commits into
base: me-date-filter
Choose a base branch
from

Conversation

tkohr
Copy link
Collaborator

@tkohr tkohr commented Nov 13, 2024

Description

This PR introduces components to display currently selected search filter values in a zone below the search filters. It is still WIP.

To-dos:

  • format date
  • format user
  • finish UI
  • tests

Screenshots

image

Quality Assurance Checklist

  • Commit history is devoid of any merge commits and readable to facilitate reviews
  • If new logic ⚙️ is introduced: unit tests were added
  • If new user stories 🤏 are introduced: E2E tests were added
  • If new UI components 🕹️ are introduced: corresponding stories in Storybook were created
  • If breaking changes 🪚 are introduced: add the breaking change label
  • If bugs 🐞 are fixed: add the backport <release branch> label
  • The documentation website 📚 has received the love it deserves

Copy link
Contributor

github-actions bot commented Nov 13, 2024

Affected libs: api-repository, feature-catalog, feature-record, feature-router, feature-editor, feature-search, feature-map, feature-dataviz, feature-auth, common-domain, api-metadata-converter, ui-search, common-fixtures, ui-elements, feature-notifications, ui-catalog, util-shared, ui-widgets, ui-inputs, ui-layout, ui-map, ui-dataviz,
Affected apps: metadata-editor, datahub, demo, webcomponents, map-viewer, search, datafeeder, metadata-converter, data-platform,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

Copy link
Contributor

github-actions bot commented Nov 13, 2024

📷 Screenshots are here!

@jahow jahow added this to the 2.4.0 milestone Nov 14, 2024
Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I did put some comments on what's already there, I'm not 100% sure what is the best way, let me know if you have better ideas!

*ngFor="let fieldValue of dateRange$ | async"
[removable]="true"
(badgeRemoveClicked)="removeFilterValue(fieldValue)"
>{{ fieldValue['start'] }} - >{{ fieldValue['end'] }}</gn-ui-badge
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be encapsulated in a "getReadableValue" method to avoid having a ngIf in the template

Comment on lines +72 to +82
const currentFieldValues: (FieldValue | DateRange)[] = await firstValueFrom(
this.fieldValues$
)
const updatedFieldValues = currentFieldValues.filter(
(value: string | DateRange) => value !== fieldValue
)
this.fieldsService
.buildFiltersFromFieldValues({
[this.fieldName]: updatedFieldValues as FieldValue[],
})
.subscribe((filters) => this.searchService.updateFilters(filters))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about directly modifying the current filters instead of going from filters to values and then values to filters? simply deleting the corresponding key in the filters should be enough

Comment on lines 5 to 8
<md-editor-search-filters-summary-item
*ngFor="let field of searchFields; let i = index"
[fieldName]="field"
></md-editor-search-filters-summary-item>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest avoiding creating a separate "summary-item" component, and do everything in the search-filters-summary component. Do you think that would be doable?

import { TranslateModule } from '@ngx-translate/core'

@Component({
selector: 'md-editor-search-filters-summary',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can maybe go in the feature-search lib ?

Comment on lines +16 to +20
@Input() searchFields: string[] = []

searchFilterActive$ = this.searchFacade.searchFilters$.pipe(
map((filters) => this.hasNonEmptyValues(filters))
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if instead of taking a list of filters as input we can simply listen for the search filters and show everyone of them. This means that if another filter (which does not appear in the advanced filters above) is active then it will also show up. What do you think?

Comment on lines +42 to +43
marker('search.filters.summaryLabel.user')
marker('search.filters.summaryLabel.changeDate')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about marking labels for all fields? It might make more sense taken from outside I think. Another approach would be to use the field normal label if a summaryLabel is not available.

@tkohr
Copy link
Collaborator Author

tkohr commented Nov 14, 2024

Thanks for the suggestions @jahow, I'll have a look how to refactor things this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants