From 1f5a9a4b7f6c2a4352793dd9c0c6e5202015cc85 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Tue, 17 Dec 2024 15:12:07 -0800 Subject: [PATCH] Add primary language filtering to useBaseSearch. Allow language selection logic to be reused. --- .../assets/src/composables/useContentLink.js | 5 + .../assets/src/views/LibraryPage/index.vue | 84 +++++--- .../assets/src/views/TopicsPage/index.vue | 16 +- .../assets/test/views/library-page.spec.js | 22 +- .../kolibri-common/components/SearchChips.vue | 17 +- .../AccordionSelectGroup.vue | 26 +-- .../SearchFiltersPanel/LanguageSelector.vue | 65 ++++++ .../SearchFiltersPanel/SelectGroup.vue | 54 ++--- .../components/SearchFiltersPanel/index.vue | 6 +- .../composables/useBaseSearch.js | 194 ++++++++++++++---- packages/kolibri/utils/i18n.js | 26 ++- 11 files changed, 372 insertions(+), 143 deletions(-) create mode 100644 packages/kolibri-common/components/SearchFiltersPanel/LanguageSelector.vue diff --git a/kolibri/plugins/learn/assets/src/composables/useContentLink.js b/kolibri/plugins/learn/assets/src/composables/useContentLink.js index d5bce334591..00447fa62f6 100644 --- a/kolibri/plugins/learn/assets/src/composables/useContentLink.js +++ b/kolibri/plugins/learn/assets/src/composables/useContentLink.js @@ -2,6 +2,7 @@ import { get } from '@vueuse/core'; import isEmpty from 'lodash/isEmpty'; import pick from 'lodash/pick'; import { computed, getCurrentInstance } from 'vue'; +import { primaryLanguageKey } from 'kolibri-common/composables/useBaseSearch'; import { ExternalPagePaths, PageNames } from '../constants'; function _decodeBackLinkQuery(query) { @@ -17,6 +18,10 @@ export default function useContentLink(store) { function _makeNodeLink(id, isResource, query, deviceId) { const params = get(route).params; + const oldQuery = get(route).query || {}; + if (!isResource && oldQuery[primaryLanguageKey]) { + query[primaryLanguageKey] = oldQuery[primaryLanguageKey]; + } return { name: isResource ? PageNames.TOPICS_CONTENT : PageNames.TOPICS_TOPIC, params: pick({ id, deviceId: deviceId || params.deviceId }, ['id', 'deviceId']), diff --git a/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue b/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue index b0499ab0f87..4a9e997c1b8 100644 --- a/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue +++ b/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue @@ -49,9 +49,16 @@ v-else-if="!displayingSearchResults && !rootNodesLoading" data-test="channels" > -

- {{ channelsLabel }} -

+ + +

+ {{ channelsLabel }} +

+
+ + + +

@@ -122,6 +130,7 @@ v-model="searchTerms" data-test="side-panel" :width="`${sidePanelWidth}px`" + :showLanguages="displayingSearchResults" /> @@ -176,20 +185,22 @@ diff --git a/packages/kolibri-common/components/SearchFiltersPanel/SelectGroup.vue b/packages/kolibri-common/components/SearchFiltersPanel/SelectGroup.vue index cf26123bff5..0a94c833d44 100644 --- a/packages/kolibri-common/components/SearchFiltersPanel/SelectGroup.vue +++ b/packages/kolibri-common/components/SearchFiltersPanel/SelectGroup.vue @@ -1,16 +1,9 @@