From 22dc16170964c6e2e42dcf5223411f1747a303f6 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Tue, 21 Jan 2025 10:32:40 -0500 Subject: [PATCH] Destructure usebasesearch and fix styles --- .../src/composables/useResourceSelection.js | 35 ++++++++++++------- .../LessonContentCard/index.vue | 11 +++++- .../LessonResourceSelection/index.vue | 1 - 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/composables/useResourceSelection.js b/kolibri/plugins/coach/assets/src/composables/useResourceSelection.js index 48b7edd1b42..3c970d2322b 100644 --- a/kolibri/plugins/coach/assets/src/composables/useResourceSelection.js +++ b/kolibri/plugins/coach/assets/src/composables/useResourceSelection.js @@ -91,27 +91,36 @@ export default function useResourceSelection() { }); }; - const useSearchObject = useBaseSearch({ + const { + searchTerms, + results: searchResults, + searchLoading, + more: searchMoreObject, + moreLoading: searchMoreLoading, + displayingSearchResults, + search, + searchMore, + clearSearch, + removeFilterTag: removeSearchFilterTag, + } = useBaseSearch({ descendant: topic, // As we dont always show the search filters, we dont need to reload the search results // each time the topic changes if not needed reloadOnDescendantChange: false, }); const searchFetch = { - data: useSearchObject.results, - loading: useSearchObject.searchLoading, - hasMore: computed(() => !!useSearchObject.more.value), - loadingMore: useSearchObject.moreLoading, + data: searchResults, + loading: searchLoading, + hasMore: computed(() => !!searchMoreObject.value), + loadingMore: searchMoreLoading, fetchData: async () => { // Make sure that the topic is loaded before searching await waitForTopicLoad(); - return useSearchObject.search(); + return search(); }, - fetchMore: useSearchObject.searchMore, + fetchMore: searchMore, }; - const { displayingSearchResults } = useSearchObject; - const fetchTree = async (params = {}) => { const newTopic = await ContentNodeResource.fetchTree(params); if (topic.value?.id !== newTopic.id) { @@ -188,12 +197,12 @@ export default function useResourceSelection() { searchFetch, selectionRules, selectedResources, - searchTerms: useSearchObject.searchTerms, - displayingSearchResults: useSearchObject.displayingSearchResults, + searchTerms, + displayingSearchResults, selectResources, deselectResources, setSelectedResources, - clearSearch: useSearchObject.clearSearch, - removeSearchFilterTag: useSearchObject.removeFilterTag, + clearSearch, + removeSearchFilterTag, }; } diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonContentCard/index.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonContentCard/index.vue index 3d44ebfce1f..2e87cfd9b59 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonContentCard/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonContentCard/index.vue @@ -105,6 +105,15 @@ headingLevel: { type: Number, default: 3, + validator(value) { + if (value <= 6 && value >= 2) { + return true; + } else { + // eslint-disable-next-line no-console + console.error(`'headingLevel' must be between 2 and 6.`); + return false; + } + }, }, }, computed: { @@ -112,7 +121,7 @@ return !this.content.isLeaf; }, headingElement() { - return this.headingLevel ? `h${this.headingLevel}` : 'h3'; + return `h${this.headingLevel}`; }, }, }; diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/index.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/index.vue index 98da517d4ef..31e33ee524c 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/index.vue @@ -185,7 +185,6 @@ .side-panel-title { margin: 0; - margin-top: 20px; font-size: 18px; }