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

Fix show more of top level resources #9555

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions kolibri/plugins/learn/assets/src/views/TopicsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,23 @@
</KButton>
<KCircularLoader v-if="t.id === subTopicLoading" />
</div>
<!-- search results -->
<!-- resources that are not in a folder -->
<HybridLearningCardGrid
v-if="resources.length"
:contents="resources"
:contents="resourcesDisplayed"
:numCols="numCols"
:genContentLink="genContentLink"
cardViewStyle="card"
@toggleInfoPanel="toggleInfoPanel"
/>
<div v-if="topicMore" class="end-button-block">
marcellamaki marked this conversation as resolved.
Show resolved Hide resolved
<KButton
v-if="!topicMoreLoading"
:text="coreString('viewMoreAction')"
appearance="raised-button"
:disabled="topicMoreLoading"
@click="handleLoadMoreInTopic"
/>
<KCircularLoader v-else />
</div>
<KButton
v-if="moreResources"
class="more-after-grid"
appearance="basic-link"
@click="handleShowMoreResources"
>
{{ $tr('showMore') }}
</KButton>
</div>
<div v-else-if="!searchLoading">
<h2 class="results-title">
Expand Down Expand Up @@ -469,6 +467,7 @@
currentViewStyle: 'card',
currentCategory: null,
showSearchModal: false,
showMoreResources: false,
sidePanelIsOpen: false,
sidePanelContent: null,
expandedTopics: {},
Expand Down Expand Up @@ -527,12 +526,23 @@
return this.channel.name;
},
resources() {
const resources = this.contents.filter(content => content.kind !== ContentNodeKinds.TOPIC);
// If there are no topics, then just display all resources we have loaded.
if (!this.topics.length) {
return resources;
return this.contents.filter(content => content.kind !== ContentNodeKinds.TOPIC);
},
resourcesDisplayed() {
// if no folders are shown at this level, show more resources to fill the space
if (this.topics.length == 0 && !this.showMoreResources) {
return this.resources.slice(0, this.childrenToDisplay * 2);
// if there are topics, and the user has not clicked show more
// default to just the preview number
} else if (this.topics.length > 0 && !this.showMoreResources) {
marcellamaki marked this conversation as resolved.
Show resolved Hide resolved
return this.resources.slice(0, this.childrenToDisplay);
// otherwise display all resources
} else {
return this.resources;
marcellamaki marked this conversation as resolved.
Show resolved Hide resolved
}
return resources.slice(0, this.childrenToDisplay);
},
moreResources() {
return this.resourcesDisplayed.length < this.resources.length;
},
topics() {
return this.contents.filter(content => content.kind === ContentNodeKinds.TOPIC);
Expand Down Expand Up @@ -737,6 +747,9 @@
[topicId]: true,
};
},
handleShowMoreResources() {
this.showMoreResources = true;
},
handleLoadMoreinSubtopic(topicId) {
this.subTopicLoading = topicId;
this.loadMoreContents(topicId).then(() => {
Expand Down