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 10 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-search, feature-map, feature-dataviz, feature-editor, feature-auth, common-domain, api-metadata-converter, ui-search, common-fixtures, util-shared, ui-elements, feature-notifications, ui-catalog, 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!

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I must be thinking too complicated, but what would this look like? An additional method in the service or facade to delete one filter by its key? Also, date ranges don't use their value as a key in the object.

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hum, I've started with one component in the beginning, but afterwards I felt it became more readable, especially for understanding which field is targeted with a separate component.

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 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, good point! I've moved it. I would've liked to separate logic and UI more to make it more reusable, but could not get it done. Maybe something for the future.

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I gave it a try, but had some difficulties with the fact that the field names do not always correspond to the ES field names in the filters. I'm also wondering if it is not more intuitive from a user perspective to only display the summary badges for the filters visible in the filter component above. For example, on the myRecords page the filter { owner: user.id } should always be present.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, I'll add more translations for this, I think.

@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