-
Notifications
You must be signed in to change notification settings - Fork 32
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
base: me-date-filter
Are you sure you want to change the base?
Conversation
Affected libs:
|
📷 Screenshots are here! |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
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)) |
There was a problem hiding this comment.
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
<md-editor-search-filters-summary-item | ||
*ngFor="let field of searchFields; let i = index" | ||
[fieldName]="field" | ||
></md-editor-search-filters-summary-item> |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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 ?
@Input() searchFields: string[] = [] | ||
|
||
searchFilterActive$ = this.searchFacade.searchFilters$.pipe( | ||
map((filters) => this.hasNonEmptyValues(filters)) | ||
) |
There was a problem hiding this comment.
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?
marker('search.filters.summaryLabel.user') | ||
marker('search.filters.summaryLabel.changeDate') |
There was a problem hiding this comment.
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.
Thanks for the suggestions @jahow, I'll have a look how to refactor things this way. |
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:
Screenshots
Quality Assurance Checklist
breaking change
labelbackport <release branch>
label