Fix learningPath and topics loading

This commit is contained in:
Daniel Egger 2022-07-04 16:38:56 +02:00
parent dc0c12a347
commit 1753ce0de4
1 changed files with 10 additions and 14 deletions

View File

@ -33,32 +33,28 @@ export const useLearningPathStore = defineStore({
if (this.learningPath) {
this.learningPath.topics = [];
this.learningPath.circles = [];
const emptyTopic: Topic = {
id: 0,
title: '',
slug: '',
type: 'learnpath.Topic',
translation_key: '',
is_visible: false,
circles: []
}
let topic = Object.assign({}, emptyTopic);
let topic: Topic | undefined;
this.learningPath.children.forEach((page) => {
if (page.type === 'learnpath.Topic') {
if (topic.id !== 0) {
if (topic) {
this.learningPath.topics.push(topic);
}
topic = Object.assign({}, emptyTopic, page);
topic = Object.assign(page, {circles: []});
}
if (page.type === 'learnpath.Circle') {
const circle = Circle.fromJson(page);
circle.parseCompletionData(completionData);
topic.circles.push(circle);
if (topic) {
topic.circles.push(circle);
}
this.learningPath.circles.push(circle);
}
this.learningPath.topics.push(topic);
})
this.learningPath.topics.push(topic);
console.log('#######################');
console.log(this.learningPath);
}
return this.learningPath;