diff --git a/client/src/views/LearningPathView.vue b/client/src/views/LearningPathView.vue index 59f53dad..0cd084e5 100644 --- a/client/src/views/LearningPathView.vue +++ b/client/src/views/LearningPathView.vue @@ -12,6 +12,7 @@ export default { return { count: 0, learningPathData: {}, + learningPathContents: {}, circles: [], learningSequences: [], } @@ -23,19 +24,50 @@ export default { url: `/learnpath/api/learningpath/${this.learningPathSlug}/`, }).then((response) => { log.debug(response.data); - this.learningPathData = response.data; + this.learningPathData = response.data + + + let learningPathContents = { topics: [] } + let topic = { + id : 0, + title : '', + slug : '', + type : 'learnpath.Topic', + translation_key : '', + is_visible : false, + cirlces : [] + } + + response.data.children.forEach((child) => { + console.log(child, '////') + if (child.type === 'learnpath.Topic') { + if (topic.id != 0){ + learningPathContents.topics.push(topic) + } + + topic = child + topic.circles = [] + } + if (child.type === 'learnpath.Circle') { + console.log(child) + topic.circles.push(child) + } + }); + learningPathContents.topics.push(topic) + + + this.learningPathContents = learningPathContents; + console.log(learningPathContents) // extract cirlces - this.learningPathData.children.forEach((child) => { - if (child.type === 'learnpath.Circle') { - this.circles.push(child); - } - }); + }); } } + +