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

WIP : Advanced filters #702

Closed
wants to merge 10 commits into from
Closed

WIP : Advanced filters #702

wants to merge 10 commits into from

Conversation

f-necas
Copy link
Collaborator

@f-necas f-necas commented Nov 22, 2023

Allows to implement custom filters based on thesaurus and orgForResource

TODO :

  • Implements new topics codelists : done need merge
  • Add a thesaurus fielter which handle translations coming from index and not gnui i18n package
    • Improve request to retrieve data from a single key (stuck with it)
  • Implement a contact field to retrieve OrgForresource

Copy link
Contributor

github-actions bot commented Nov 22, 2023

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

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

@f-necas f-necas force-pushed the DH-customize-advanced-filters branch from 021b5f0 to 7dba06f Compare November 22, 2023 17:43
@fgravin fgravin added bug Something isn't working enhancement Proposal for a new feature labels Dec 4, 2023
@fgravin fgravin added this to the 2.1.0 milestone Dec 4, 2023
.search(
'bucket',
JSON.stringify(
this.esService.getSearchRequestBody({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doing this degrades the abstraction over the GN4/ElasticSearch backend; this abstraction is still not fully complete but we should be careful not to "open new holes" in it.

If achieving this through the Repository interface is really too far-fetched then I guess keeping this would be acceptable though.

Copy link
Member

Choose a reason for hiding this comment

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

No gn4 api calls should be made but in gn4 repository lib.

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.

Thanks for the work @Angi-Kinas & @f-necas, it was a tough one.
The contact & thesaurus fields work well, congratz.

Nevertheless, we have to refactor your work as it violates many OOP and architectural principles. See my components to understand small issues from here to there !

I am taking over it in #719 to bring a little help on the way 🤟

@@ -913,4 +926,88 @@ export class ToolsApiService {
}
)
}

Copy link
Member

Choose a reason for hiding this comment

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

Never write open API client by hand.
BTW, the registries client already exists in RegistriesApiService

@@ -127,6 +128,57 @@ export class GnUiTranslationSearchField extends SimpleSearchField {
}
}

export class ThesaurusTranslationSearchField extends SimpleSearchField {
Copy link
Member

Choose a reason for hiding this comment

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

Could have extended the GnuiTranslationField, which is almost the same, instead.

Copy link
Member

Choose a reason for hiding this comment

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

The content of the commit has nothing to do with the commit message.

@@ -4,7 +4,7 @@
class="py-[37px] pl-[47px] rounded-lg border bg-white mb-5 card-shadow cursor-pointer"
[figure]="recordsCount$ | async"
[icon]="'folder_open'"
[title]="'catalog.figures.datasets'"
[title]="'catalog.figures.datasets' | translate"
Copy link
Member

Choose a reason for hiding this comment

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

This is useless as the gn-ui-figure already does a translation.

@@ -1,6 +1,6 @@
{
"catalog.figures.datasets": "{count, plural, =0{datasets} one{dataset} other{datasets}}",
Copy link
Member

Choose a reason for hiding this comment

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

This should tells that there is an issue with the translation.
In a previous commit, you added a key which is not recognized by ngx-translate.
Never add key by hand in this file.

return this.version.pipe(
switchMap((version) =>
version == '4.2.2'
? super.getFiltersForValues(values)
Copy link
Member

Choose a reason for hiding this comment

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

Both lines are exactly the same as the default value of esFieldName in getFiltersForValues is this.esFieldName


constructor(public order: 'asc' | 'desc' = 'asc', public injector: Injector) {
super('OrgForResource', order, injector)
this.esFieldName = 'OrgForResourceObject.default'
Copy link
Member

Choose a reason for hiding this comment

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

This override super.esFieldName as well.

.search(
'bucket',
JSON.stringify(
this.esService.getSearchRequestBody({
Copy link
Member

Choose a reason for hiding this comment

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

No gn4 api calls should be made but in gn4 repository lib.

'bucket',
JSON.stringify(
this.esService.getSearchRequestBody({
contactForResource: {
Copy link
Member

Choose a reason for hiding this comment

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

Nice payload 👍

getFiltersForValues(values: FieldValue[]): Observable<FieldFilters> {
getFiltersForValues(
values: FieldValue[],
esFieldName: string = this.esFieldName
Copy link
Member

Choose a reason for hiding this comment

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

If you change the signature, then you don't correctly implements the abstract class.
BTW, implements an abstract is javascript abusive, one should extend a class, and implement an interface. It would have rise a warning there.

@fgravin
Copy link
Member

fgravin commented Dec 11, 2023

Closing: partially done with #719
Just missing contacts filter.

@fgravin fgravin closed this Dec 11, 2023
@jahow jahow deleted the DH-customize-advanced-filters branch January 23, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Proposal for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants