Skip to content

Commit

Permalink
Merge pull request #9555 from marcellamaki/fix-show-more-of-top-level…
Browse files Browse the repository at this point in the history
…-resources

Fix show more of top level resources
  • Loading branch information
rtibbles authored Jul 11, 2022
2 parents 3496b82 + 68d333c commit 42c7d93
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions kolibri/plugins/learn/assets/src/views/TopicsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,24 @@
</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">
<KButton
v-if="moreResources"
class="more-after-grid"
appearance="basic-link"
@click="handleShowMoreResources"
>
{{ $tr('showMore') }}
</KButton>
<div v-else-if="topicMore" class="end-button-block">
<KButton
v-if="!topicMoreLoading"
:text="coreString('viewMoreAction')"
Expand Down Expand Up @@ -469,6 +477,7 @@
currentViewStyle: 'card',
currentCategory: null,
showSearchModal: false,
showMoreResources: false,
sidePanelIsOpen: false,
sidePanelContent: null,
expandedTopics: {},
Expand Down Expand Up @@ -527,12 +536,18 @@
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
// or if the user has explicitly requested to show more resources
if (!this.topics.length || this.showMoreResources) {
return this.resources;
}
return resources.slice(0, this.childrenToDisplay);
return this.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 +752,9 @@
[topicId]: true,
};
},
handleShowMoreResources() {
this.showMoreResources = true;
},
handleLoadMoreinSubtopic(topicId) {
this.subTopicLoading = topicId;
this.loadMoreContents(topicId).then(() => {
Expand Down

0 comments on commit 42c7d93

Please sign in to comment.