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

Draft: Filter unavailable in Channel view #621

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
WIP
  • Loading branch information
GeorgesStavracas committed Jun 15, 2023
commit 8e4bec936f9fb07d677ebb9cd9e27020d9c96a71
23 changes: 22 additions & 1 deletion packages/template-ui/src/views/ListSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
>
<ChannelHeader :section="section" />

<b-container v-if="false">
<div class="my-4">
<b-form-checkbox
v-model="hideUnavailableItems"
name="check-only-downloaded"
switch
>
Only downloaded items
</b-form-checkbox>
</div>
</b-container>

<div v-if="isInlineLevel">
<template v-if="loadingSubsectionNodes">
<EkCardGridPlaceholder
Expand Down Expand Up @@ -71,6 +83,7 @@ export default {
return {
subsectionNodes: { nodes: [], hasMoreNodes: false, pagination: null },
loadingSubsectionNodes: true,
hideUnavailableItems: window.kolibri.defaultHideUnavailable,
};
},
computed: {
Expand All @@ -92,6 +105,10 @@ export default {
this.loadInlineLevel();
}
},
hideUnavailableItems() {
console.log("Switched again!");
return this.fetchSubsectionNodes();
},
},
mounted() {
if (this.isInlineLevel) {
Expand All @@ -115,6 +132,7 @@ export default {
return window.kolibri.getContentByFilter({
parent: subsection.id,
maxResults: sectionPageSize,
includeUnavailable: !this.hideUnavailableItems,
})
.then((pageResult) => {
this.$set(this.subsectionNodes, subsection.id, {
Expand All @@ -132,7 +150,10 @@ export default {
if (!hasMoreNodes) {
return null;
}
return window.kolibri.getContentPage(pagination).then((pageResult) => {
return window.kolibri.getContentPage({
...pagination,
...(!this.hideUnavailableItems && { no_available_filtering: true }),
}).then((pageResult) => {
this.$set(this.subsectionNodes, sectionId, {
nodes: nodes.concat(pageResult.results),
hasMoreNodes: pageResult.more !== null,
Expand Down