Skip to content

Commit

Permalink
handles navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanOXDi committed Dec 5, 2024
1 parent 02a953e commit 6191867
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
:currentLesson="currentLesson"
:loading="resources.length === 0"
@removeResource="removeResource"
@navigateToParent="navigateToParent"
/>

<template #bottomNavigation>
Expand Down Expand Up @@ -67,6 +68,11 @@
numberOfSelectedResource$,
};
},
data() {
return {
resources: [],
};
},
computed: {
...mapState('lessonSummary', ['currentLesson', 'workingResources', 'resourceCache']),
lessonOrderListButtonBorder() {
Expand All @@ -77,12 +83,6 @@
};
},
},
data() {
return {
PageNames,
resources: [],
};
},
mounted() {
setTimeout(() => {
this.getResources();
Expand All @@ -92,27 +92,31 @@
removeResource(id) {
this.resources = this.resources.filter(lesson => lesson.id !== id);
},
recipients() {
return this.group
? this.getLearnersForGroups([this.group.id])
: this.getLearnersForLesson(this.currentLesson);
navigateToParent(id) {
this.$router.push({
name: PageNames.LESSONS_ROOT,
params: { classId: this.$route.params.classId, lessonId: id },
});
},
getResources() {
const response = this.workingResources.map(resource => {
const content = this.resourceCache[resource.contentnode_id];
if (!content) {
return this.missingResourceObj(resource.contentnode_id);
}
// const tally = this.getContentStatusTally(content.content_id, this.recipients);
const tally = this.getContentStatusTally(
content.content_id,
this.getLearnersForLesson(this.currentLesson)
);
const tableRow = {
...content,
node_id: content.id,
// hasAssignments: Object.values(tally).reduce((a, b) => a + b, 0),
// tally,
hasAssignments: Object.values(tally).reduce((a, b) => a + b, 0),
tally,
};
const link = {};
const link = this.resourceLink(tableRow);
if (link) {
tableRow.link = link;
}
Expand All @@ -124,9 +128,6 @@
.then(results => {
this.resources = results;
})
.catch(error => {
console.error('An error occurred:', error);
});
},
resourceLink(resource) {
if (resource.hasAssignments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
:key="lesson.id"
:style="lessonOrderListButtonBorder"
>
<KGrid>
<KGrid :style="{ paddingTop: '1em' }">
<KGridItem
:layout12="{ span: 10 }"
:layout8="{ span: 5 }"
Expand Down Expand Up @@ -73,7 +73,7 @@
<span class="add-minus-button">
<KIconButton
icon="emptyTopic"
@click="() => {}"
@click="$emit('navigateToParent',lesson.id)"
/>

<KIconButton
Expand Down

0 comments on commit 6191867

Please sign in to comment.