Skip to content

Commit

Permalink
Destructure usebasesearch and fix styles
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Jan 21, 2025
1 parent c13df0e commit 22dc161
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,23 @@
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: {
isTopic() {
return !this.content.isLeaf;
},
headingElement() {
return this.headingLevel ? `h${this.headingLevel}` : 'h3';
return `h${this.headingLevel}`;
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
.side-panel-title {
margin: 0;
margin-top: 20px;
font-size: 18px;
}
Expand Down

0 comments on commit 22dc161

Please sign in to comment.