Skip to content

Commit

Permalink
resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
GarvitSinghal47 committed Feb 13, 2024
2 parents e9861ab + 18a9f32 commit 5a5b538
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useFetchTree from './useFetchTree';
import { QuizExercise } from './quizCreationSpecs.js';

const logger = logging.getLogger(__filename);

const _loadingMore = ref(false);
/**
* @typedef {Object} QuizResourcesConfig
* @property { computed <string|null|undefined> } topicId - The id of the root node to fetch the
Expand Down Expand Up @@ -115,11 +115,15 @@ export default function useQuizResources({ topicId } = {}) {
*/
async function fetchMoreQuizResources() {
set(_loading, true);
set(_loadingMore, true);
return fetchMore().then(async results => {
set(_resources, [...get(_resources), ...results]);
return annotateTopicsWithDescendantCounts(
results.filter(({ kind }) => kind === ContentNodeKinds.TOPIC).map(topic => topic.id)
).then(() => set(_loading, false));
).then(() => {
set(_loading, false);
set(_loadingMore, false);
});
});
}

Expand All @@ -139,6 +143,7 @@ export default function useQuizResources({ topicId } = {}) {
setResources,
resources: computed(() => get(_resources)),
loading: computed(() => get(_loading) || get(treeLoading)),
loadingMore: computed(() => get(_loadingMore)),
fetchQuizResources,
fetchMoreQuizResources,
hasCheckbox,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
<template>

<div class="select-resource">
<div v-if="loading">
<div v-if="loading && !loadingMore">
<KCircularLoader />
</div>
<div v-else>
<h5
class="title-style"
>
{{ /* selectFoldersOrExercises$() */ }}
</h5>
<KGrid class="align-select-folder-style">
<KGridItem
:layout12="{ span: 1 }"
:layout8="{ span: 1 }"
>
<KIconButton
icon="back"
@click="goBack()"
/>
</KGridItem>

<KGridItem
:layout12="{ span: 11 }"
:layout8="{ span: 7 }"
>
<h5 class="select-folder-style">
{{ selectFoldersOrExercises$() }}
</h5>
</KGridItem>
</KGrid>

<div v-if="!isTopicIdSet && bookmarks.length && !showBookmarks">

Expand Down Expand Up @@ -51,6 +66,7 @@
:contentCardMessage="selectionMetadata"
:contentCardLink="contentLink"
:selectAllIndeterminate="selectAllIndeterminate"
:loadingMoreState="loadingMore"
@changeselectall="toggleTopicInWorkingResources"
@change_content_card="toggleSelected"
@moreresults="fetchMoreQuizResources"
Expand Down Expand Up @@ -83,9 +99,9 @@
</div>
</div>

</template>


</template>


<script>
import uniqWith from 'lodash/uniqWith';
Expand Down Expand Up @@ -125,7 +141,7 @@
sectionSettings$,
selectFromBookmarks$,
numberOfSelectedBookmarks$,
//selectFoldersOrExercises$,
selectFoldersOrExercises$,
numberOfSelectedResources$,
numberOfResources$,
selectedResourcesInformation$,
Expand Down Expand Up @@ -190,6 +206,7 @@
hasMore,
annotateTopicsWithDescendantCounts,
setResources,
loadingMore,
} = useQuizResources({ topicId });
const _loading = ref(true);
Expand Down Expand Up @@ -274,14 +291,15 @@
hasCheckbox,
loading,
hasMore,
loadingMore,
fetchMoreQuizResources,
resetWorkingResourcePool,
contentPresentInWorkingResourcePool,
//contentList,
sectionSettings$,
selectFromBookmarks$,
numberOfSelectedBookmarks$,
//selectFoldersOrExercises$,
selectFoldersOrExercises$,
numberOfSelectedResources$,
numberOfResources$,
windowIsSmall,
Expand Down Expand Up @@ -352,6 +370,9 @@
focusFirstEl() {
this.$refs.textbox.focus();
},
goBack() {
return this.$router.go(-1);
},
contentLink(content) {
if (this.showBookmarks) {
return this.$route;
Expand Down Expand Up @@ -429,9 +450,9 @@
},
};
</script>


</script>


<style scoped lang="scss">
@import '~kolibri-design-system/lib/styles/definitions';
Expand Down Expand Up @@ -506,4 +527,13 @@
}
}
</style>
.select-folder-style {
margin-top: 0.5em;
font-size: 18px;
}
.align-select-folder-style {
margin-top: 2em;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@

<template>
<KButton
v-if="showButton"
v-if="showButton && !loadingMoreState"
:text="coreString('viewMoreAction')"
:primary="false"
@click="$emit('moreresults')"
/>
<KCircularLoader
v-if="viewMoreButtonState === ViewMoreButtonStates.LOADING"
v-if="viewMoreButtonState === ViewMoreButtonStates.LOADING & loadingMoreState"
:delay="false"
/>
<!-- TODO introduce messages in next version -->
Expand All @@ -59,9 +59,9 @@
</template>
</div>

</template>


</template>


<script>
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
Expand Down Expand Up @@ -128,6 +128,10 @@
type: Function, // ContentNode => Route
required: true,
},
loadingMoreState: {
type: Boolean,
default: false,
},
},
computed: {
Expand All @@ -153,9 +157,9 @@
},
};
</script>


</script>


<style lang="scss" scoped>
@import './LessonContentCard/card';
Expand Down Expand Up @@ -183,4 +187,4 @@
margin-left: $checkbox-offset;
}
</style>
</style>

0 comments on commit 5a5b538

Please sign in to comment.