Repository navigation
[Port dspace-10_x] Support multiple search instances on a single page - #5740
alijaber-atmire wants to merge 14 commits into
Conversation
…with searchInstanceId
Adds support for running multiple search components on a single page by
prefixing all search-related route and query parameters with a unique
search instance id (${searchInstanceId}.${parameterName}). Previously only
sort and pagination parameters were scoped; configuration, fixedFilterQuery,
scope, query, dsoType, view and filter queries (f.xxx) are now scoped too.
…w2p-141627_search-instance-params-10.x_contribute # Conflicts: # src/app/search-navbar/search-navbar.component.spec.ts # src/app/search-navbar/search-navbar.component.ts # src/app/search-page/search-page.component.ts # src/app/shared/object-collection/object-collection.component.ts # src/app/shared/search-form/search-form.component.ts # src/app/shared/search/search-configuration.service.spec.ts # src/app/shared/search/search-configuration.service.ts # src/app/shared/search/search-results/search-results.component.ts
|
Hi @alijaber-atmire, thank you for this contribution! One request, would you be able to change this PR to be against the |
…refixed params on load
|
@lgeggleston thank you for the comment and sorry for the late response , i will create a new PR against main. |
…to w2p-141627_search-instance-params-10.x_contribute
…onents to use scoped config service
…to w2p-141627_search-instance-params-10.x_contribute # Conflicts: # src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.spec.ts # src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.ts # src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.spec.ts # src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.ts # src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-selected-option/search-facet-selected-option.component.spec.ts # src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-selected-option/search-facet-selected-option.component.ts # src/app/shared/search/search-labels/search-label/search-label.component.spec.ts # src/app/shared/search/search-labels/search-label/search-label.component.ts
|
Hi @alijaber-atmire, |
The collapsed/expanded state and facet page of search filters were stored by filter name only, so multiple searches on the same page (e.g. exhibit search blocks) shared that state. Resetting the filters of one search re-initialized the filter panels of every other search with the same filter names, hiding their selected values. The state keys are now prefixed with the search instance id. Also pass inPlaceSearch to the small-screen search sidebar, so its filter and "Reset filters" links stay on the current page instead of going to /search.
…earch-instance-params-10.x_contribute # Conflicts: # src/app/search-navbar/search-navbar.component.ts
|
Hi @alijaber-atmire, |
…earch-instance-params-10.x_contribute # Conflicts: # src/app/core/testing/pagination-service.stub.ts
References
Description
Extends the per-search-instance prefixing (currently only applied to
sortandpagination) to all remaining search route and query parameters, so multiple search components can coexist on a single page without interfering with each other.Instructions for Reviewers
This builds on the existing mechanism that prefixes
sort/paginationparams with a unique search-instance identifier, and applies the same approach to every other search parameter.List of changes in this PR:
searchInstanceIdtoSearchConfigurationServiceand helper methods to build/read instance-scoped parameters:getSearchInstanceParam,getCurrentSearchInstanceParam,getCurrentSearchInstanceQueryParam,getSearchInstanceFilterParam,getCurrentSearchInstanceFilterParam, andgetSearchInstanceFilterParamPrefix.getCurrentConfiguration,getCurrentScope,getCurrentQuery, andgetCurrentDSOTypeto resolve their values from instance-prefixed route/query parameters (with a fallback to the legacy unprefixed parameter for backwards compatibility).SearchFilterServiceandSearchServiceto read/write thef.xxxfilter parameters andviewusing the instance prefix.search.component,search-form.component,search-results.component,search-settings.component,search-switch-configuration.component,search-navbar.component,search-page.component,configuration-search-page.component,themed(-configuration)-search.component, the facet/range filter option components, andobject-collection.component— to use the instance-prefixed parameter names.recent-item-list,my-dspace-configuration.service, andmy-dspace.guardto use the new instance-scoped params.search-configuration-service/pagination-servicetest stubs accordingly.How to test (multiple search instances):
yarn start/npm start).SearchConfigurationServiceinjection, so use two separateConfigurationSearchPageComponent/SearchPageComponentinstances — not twoSearchComponentinstances sharing a singleSearchConfigurationService. BecausesearchInstanceIdis stored as an instance variable on the service, twoSearchComponents backed by the same service would overwrite each other's id.searchInstanceIdby explicitly passing it in (e.g.[searchInstanceId]="'first'"and[searchInstanceId]="'second'"), since the components default to the same id otherwise.dsoType, and apply facet/range filters.first.query,first.f.author,first.configuration) and that the second instance is unaffected, and vice versa.How to test (backwards compatibility of legacy URLs):
/search?query=cats&f.author=Smith,equals&view=list), as produced by older versions / external links / bookmarks.spc.query=cats&spc.f.author=Smith,equals&spc.view=list) and the search results, active filters, and view mode reflect those values.Checklist
mainbranch of code — N/A: this is a version-specific PR targetingdspace-10_x(the bug is being fixed on the 7.6/9.x/10.x lines).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.