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

Move pagination into NodePanel where the contents of the topic are actually loaded and displayed. #4674

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,7 @@
@deselect="selected = selected.filter(id => id !== $event)"
@scroll="scroll"
@editTitleDescription="showTitleDescriptionModal"
>
<template #pagination>
<slot name="pagination"></slot>
</template>
</NodePanel>
/>
</DraggableRegion>
</VFadeTransition>
<ResourceDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
/>
</template>
</VList>
<slot name="pagination"></slot>
<div class="pagination-container">
<KButton v-if="more" :disabled="moreLoading" @click="loadMore">
{{ $tr('showMore') }}
</KButton>
</div>
</div>

</template>
Expand Down Expand Up @@ -80,6 +84,8 @@
data() {
return {
loading: false,
more: null,
moreLoading: false,
};
},
computed: {
Expand All @@ -102,12 +108,13 @@
},
created() {
this.loading = true;
this.loadChildren({ parent: this.parentId }).then(() => {
this.loadChildren({ parent: this.parentId }).then(childrenResponse => {
this.loading = false;
this.more = childrenResponse.more || null;
});
},
methods: {
...mapActions('contentNode', ['loadChildren']),
...mapActions('contentNode', ['loadChildren', 'loadContentNodes']),
goToNodeDetail(nodeId) {
if (
this.$route.params.nodeId === this.parentId &&
Expand Down Expand Up @@ -151,12 +158,22 @@
}
}
},
loadMore() {
if (this.more && !this.moreLoading) {
this.moreLoading = true;
this.loadContentNodes(this.more).then(response => {
this.more = response.more || null;
this.moreLoading = false;
});
}
},
},
$trs: {
emptyViewOnlyChannelText: 'Nothing in this channel yet',
emptyTopicText: 'Nothing in this folder yet',
emptyChannelText: 'Click "ADD" to start building your channel',
emptyChannelSubText: 'Create, upload, or import resources from other channels',
showMore: 'Show more',
},
};

Expand All @@ -174,4 +191,10 @@
background-color: var(--v-backgroundColor-base);
}

.pagination-container {
display: flex;
justify-content: flex-start;
margin: 4px;
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@
/>
</div>
</template>
<template #pagination>
<div class="pagination-container">
<KButton v-if="more" :disabled="moreLoading" @click="loadMore">
{{ $tr('showMore') }}
</KButton>
</div>
</template>
</CurrentTopicView>
</VContent>
</TreeViewBase>
Expand Down Expand Up @@ -199,8 +192,6 @@
},
loading: true,
listElevated: false,
more: null,
moreLoading: false,
};
},
computed: {
Expand Down Expand Up @@ -308,16 +299,7 @@
collapseAll: 'COLLAPSE_ALL_EXPANDED',
setExpanded: 'SET_EXPANSION',
}),
...mapActions('contentNode', ['loadAncestors', 'loadChildren', 'loadContentNodes']),
loadMore() {
if (this.more && !this.moreLoading) {
this.moreLoading = true;
this.loadContentNodes(this.more).then(response => {
this.more = response.more || null;
this.moreLoading = false;
});
}
},
...mapActions('contentNode', ['loadAncestors', 'loadChildren']),
verifyContentNodeId(id) {
this.nodeNotFound = false;
return this.$store.dispatch('contentNode/headContentNode', id).catch(() => {
Expand Down Expand Up @@ -414,7 +396,6 @@
openCurrentLocationButton: 'Expand to current folder location',
updatedResourcesReadyForReview: 'Updated resources are ready for review',
closeDrawer: 'Close',
showMore: 'Show more',
},
};

Expand Down Expand Up @@ -462,10 +443,4 @@
}
}

.pagination-container {
display: flex;
justify-content: flex-start;
margin: 4px;
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,10 @@ class Resource extends mix(APIResource, IndexedDBResource) {
}

savePagination(queryString, more) {
if (more) {
return this.transaction({ mode: 'rw' }, PAGINATION_TABLE, () => {
return db[PAGINATION_TABLE].put({ table: this.tableName, queryString, more });
});
}
return Promise.resolve();
return this.transaction({ mode: 'rw' }, PAGINATION_TABLE, () => {
// Always save the pagination even if null, so we know we have fetched it
return db[PAGINATION_TABLE].put({ table: this.tableName, queryString, more });
});
}

loadPagination(queryString) {
Expand Down