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

[Search page]: Filter last records carousel by producer #128

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cmoinier
Copy link
Contributor

@cmoinier cmoinier commented Feb 14, 2025

This PR adds a filtering on the last records carousel by producer.

Key features

  • Last created cards are filtered by producer if the catalog is (through URL or filter btn)
  • Favorite cards, if they exist, are not affected by this change and are displayed normally
  • Other filters are not filtering the last record carousel
  • The file search.cy has had a .only statement left, so most tests were failing when I removed it. They are now fixed but that's why the file has many changes. Removed the quality score test because this filter is not being used.

@cmoinier cmoinier force-pushed the optional-producer-filter branch from 07b526a to bab1cf6 Compare February 14, 2025 14:51
@cmoinier cmoinier force-pushed the optional-producer-filter branch from bab1cf6 to df2c44c Compare February 17, 2025 06:28
@cmoinier cmoinier force-pushed the optional-producer-filter branch from 7e181b5 to 83f40a0 Compare February 17, 2025 11:43
@cmoinier cmoinier force-pushed the optional-producer-filter branch from c3b48e7 to f8f30d0 Compare February 18, 2025 08:03
Copy link
Member

@tkohr tkohr left a comment

Choose a reason for hiding this comment

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

Thanks, @cmoinier, the implementation works really well!

I'm just wondering if it's the right approach to filter the results in the search-header.component and than pass them down to the list. In this case, there is no need to keep the headerSearch state, I think.

However, I have the impression it could be simpler and cleaner to just pass down the filter values to the headerSearch state and than let the result-list handle the synchronization of the producer filter values. Not sure if this is feasable. WDYT?

@@ -16,6 +16,7 @@ <h1 class="flex mel-page-title md:mb-12" translate="">
</div>
<div class="h-64" gnUiSearchStateContainer="headerSearch">
<mel-datahub-results-list-carousel
[records]="records$ | async"
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if you could just pass the filter values from the mainSearch search state down to the results-list.comonent (which has its own headerSearch search state) here and then make the results-list.component listen to the producer changes.

JSON.stringify(currentProducerFilter) !==
JSON.stringify(previousProducerFilter)
)
}
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if all the logic in this component is necessary and if it's the component's responsibility to handle this. Maybe we can leverage the separate headerSearch state and achieve to only synchronize the producer filter of the mainSearch state with it by passing down its value as mentioned above. WDYT?

Copy link
Member

@tkohr tkohr 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 rework @cmoinier ! I really prefer this solution :-) I think there are still some leftovers in the code, but everything still seems to work fine.

) {}

producerHasChanged$ = this.searchFacade.searchFilters$.pipe(
distinctUntilChanged(),
debounceTime(100),
Copy link
Member

Choose a reason for hiding this comment

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

Is the debounce (still) needed here?

@@ -19,6 +19,7 @@ <h1 class="flex justify-center mel-page-title" translate="">
</div>
</div>
<mel-datahub-results-list-carousel
[records]="records"
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed, I think.

@@ -27,6 +27,7 @@ import { SortByField } from 'geonetwork-ui/libs/common/domain/src/lib/model/sear
})
export class HomeHeaderComponent {
HREF_ROUTE_SEARCH = `${DATAHUB_ROOT}/${DATAHUB_ROUTE_SEARCH}`
@Input() records: CatalogRecord[] = []
Copy link
Member

Choose a reason for hiding this comment

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

Same here, shouldn't be needed anymore.

Comment on lines +1 to +3
<mel-datahub-home-header
[records]="searchFacade.results$ | async"
></mel-datahub-home-header>
Copy link
Member

Choose a reason for hiding this comment

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

Can also be reverted, right?

Comment on lines +10 to +12
export class HomePageComponent {
constructor(protected searchFacade: SearchFacade) {}
}
Copy link
Member

Choose a reason for hiding this comment

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

And this one as well.

Comment on lines +10 to +11
export class ResultsListCarouselComponent extends ResultsListComponent {
}
Copy link
Member

Choose a reason for hiding this comment

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

Formatting?

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