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

Make filter options customisable #515

Merged
merged 2 commits into from
Jul 5, 2023
Merged

Conversation

Angi-Kinas
Copy link
Collaborator

@Angi-Kinas Angi-Kinas commented Jul 3, 2023

Proposal: Make filter customizable through default.toml. Once this PR is merged, one will be able to decide which advanced filters to include in the application. This can be done by specifiying the "advanced_filters" in the default.toml, like so:
advanced_filters = ['publisher', 'format', 'publicationYear', 'topic', 'isSpatial', 'license']
if advanced_filters are no specified by the user(admin), the one above will be used.
These are the possible filters: 'publisher', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'topic', 'isSpatial', 'license'

Screenshots:
with all filters:
image

customised version:
image

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Affected libs: util-app-config, feature-record, feature-router, feature-map, feature-dataviz, util-i18n, feature-catalog, feature-search, feature-editor, feature-auth, ui-elements, ui-catalog, ui-search, ui-dataviz, ui-inputs,
Affected apps: datahub, metadata-editor, demo, webcomponents, search, map-viewer, metadata-converter, datafeeder,

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

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.

A few things to address and that's it, very good work!

Comment on lines 46 to 52
[ngClass]="
(isOpen ? 'block' : 'hidden') +
' ' +
(filter.fieldName === 'publisher' || filter.fieldName === 'format'
? 'sm:block'
: '')
"
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • I think we should show the two first fields when the block is collapsed, instead of hardcoding field names
  • the logic for building the full class attribute would maybe be better in the TS file, and it would be easier to test as well

switch (filter) {
case 'organisation':
return {
fieldName: 'publisher',
Copy link
Collaborator

Choose a reason for hiding this comment

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

we shouldn't do any mapping with field names here, only the fields service has this power :)

Comment on lines 66 to 67
# available filters: 'organisation', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'topic', 'spatial', 'license'
custom_filters = ['organisation', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'topic', 'spatial', 'license']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# available filters: 'organisation', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'topic', 'spatial', 'license'
custom_filters = ['organisation', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'topic', 'spatial', 'license']
# The advanced search filters available to the user can be customized with this setting.
# The following fields can be used for filtering: 'publisher', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'topic', 'isSpatial', 'license'
# advanced_filters = ['publisher', 'format', 'publicationYear', 'topic', 'spatial', 'license']

Note: since this is an optional key, it should be commented out in the toml file and the default value should be written in the app (datahub in this case).

case 'organisation':
return {
fieldName: 'publisher',
title: 'search.filters.byOrganisation',
Copy link
Collaborator

Choose a reason for hiding this comment

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

use marker for i18n

Copy link
Member

@fgravin fgravin left a comment

Choose a reason for hiding this comment

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

Just a comment without doing a review.
A proposal of the new configuration inputs should be provided in the description of the PR.
The configuration is quite sensitive as it has to be human manageable.
I suggest that everyone time we touch the configuration schema, we propose the change within the PR, so we can discuss it even though we are not looking at the code.
Thanks 🤗

@Angi-Kinas
Copy link
Collaborator Author

@fgravin I updated the description of the PR. Let me know if there is something to change/add.

@fgravin
Copy link
Member

fgravin commented Jul 5, 2023

@fgravin I updated the description of the PR. Let me know if there is something to change/add.

Great thanks.
I wonder if a user add a filter which is not in the list, what would happen ?
BTW, I think that a user should be able to add any field of the domain metadataRecord model as a filter, it should perform a basic term aggregation. I don't know how this is handled right now, could be addressed when the need appear later on though.
👍

@Angi-Kinas
Copy link
Collaborator Author

@fgravin good question. When the user adds a filter that's not in the list, there will be an Error in the console and the app is not usable anymore:
image
@jahow and I decided that this is ok for now. What do you think?

@jahow
Copy link
Collaborator

jahow commented Jul 5, 2023

BTW, I think that a user should be able to add any field of the domain metadataRecord model as a filter, it should perform a basic term aggregation. I don't know how this is handled right now, could be addressed when the need appear later on though.

That might be doable yes, if the need arise we could do it! E.g. filter on uuid, title, links etc.

@fgravin
Copy link
Member

fgravin commented Jul 5, 2023

@jahow and I decided that this is ok for now. What do you think?

I think that it should not happen, shouldn't it ?
An error in the config should not break the application IMO, I don't know what is the behavior for the other fields.
Might not be hard to check for the error and add a warning in the console at least ?

@jahow
Copy link
Collaborator

jahow commented Jul 5, 2023

@jahow and I decided that this is ok for now. What do you think?

I think that it should not happen, shouldn't it ? An error in the config should not break the application IMO, I don't know what is the behavior for the other fields. Might not be hard to check for the error and add a warning in the console at least ?

Hmm, I would say an error in the config should break everything because the configuration is expected to be valid at runtime. At load time we check if every required configuration setting is there, but we cannot know yet if one of the filters is invalid or not. If an invalid field is specified then an error is thrown in the console, the only issue here is that the application still loads and kind of look normal, so an administrator might not realize that they made a mistake in the config.

The best solution IMO would be to have a strong error message showing up like: "WARNING: the configuration is invalid, the application cannot run" or something like that.

@fgravin fgravin added enhancement Proposal for a new feature minor feature labels Jul 5, 2023
@Angi-Kinas Angi-Kinas merged commit 4df70b8 into main Jul 5, 2023
8 checks passed
@Angi-Kinas Angi-Kinas deleted the customise-filter-options branch July 5, 2023 15:14
@fgravin fgravin linked an issue Jul 26, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Proposal for a new feature minor feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Datahub]: Make filters configurable
3 participants