Fix learningPath and topics loading
This commit is contained in:
parent
dc0c12a347
commit
1753ce0de4
|
|
@ -33,32 +33,28 @@ export const useLearningPathStore = defineStore({
|
||||||
if (this.learningPath) {
|
if (this.learningPath) {
|
||||||
this.learningPath.topics = [];
|
this.learningPath.topics = [];
|
||||||
this.learningPath.circles = [];
|
this.learningPath.circles = [];
|
||||||
const emptyTopic: Topic = {
|
|
||||||
id: 0,
|
let topic: Topic | undefined;
|
||||||
title: '',
|
|
||||||
slug: '',
|
|
||||||
type: 'learnpath.Topic',
|
|
||||||
translation_key: '',
|
|
||||||
is_visible: false,
|
|
||||||
circles: []
|
|
||||||
}
|
|
||||||
let topic = Object.assign({}, emptyTopic);
|
|
||||||
this.learningPath.children.forEach((page) => {
|
this.learningPath.children.forEach((page) => {
|
||||||
if (page.type === 'learnpath.Topic') {
|
if (page.type === 'learnpath.Topic') {
|
||||||
if (topic.id !== 0) {
|
if (topic) {
|
||||||
this.learningPath.topics.push(topic);
|
this.learningPath.topics.push(topic);
|
||||||
}
|
}
|
||||||
topic = Object.assign({}, emptyTopic, page);
|
topic = Object.assign(page, {circles: []});
|
||||||
}
|
}
|
||||||
if (page.type === 'learnpath.Circle') {
|
if (page.type === 'learnpath.Circle') {
|
||||||
const circle = Circle.fromJson(page);
|
const circle = Circle.fromJson(page);
|
||||||
circle.parseCompletionData(completionData);
|
circle.parseCompletionData(completionData);
|
||||||
topic.circles.push(circle);
|
if (topic) {
|
||||||
|
topic.circles.push(circle);
|
||||||
|
}
|
||||||
this.learningPath.circles.push(circle);
|
this.learningPath.circles.push(circle);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.learningPath.topics.push(topic);
|
|
||||||
})
|
})
|
||||||
|
this.learningPath.topics.push(topic);
|
||||||
|
console.log('#######################');
|
||||||
console.log(this.learningPath);
|
console.log(this.learningPath);
|
||||||
}
|
}
|
||||||
return this.learningPath;
|
return this.learningPath;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue