Update client with new api data model

This commit is contained in:
Daniel Egger 2022-06-01 22:24:49 +02:00
parent f480665537
commit 65ecf77a59
3 changed files with 23 additions and 9 deletions

View File

@ -8,8 +8,8 @@ defineProps(['learningSequence'])
<h3 class="mb-2 text-xl">{{ learningSequence.title }}</h3> <h3 class="mb-2 text-xl">{{ learningSequence.title }}</h3>
<div class="bg-white p-4 border border-slate-300 border-l-4 border-l-blue-500"> <div class="bg-white p-4 border border-slate-300 border-l-4 border-l-blue-500">
<div v-for="learningPackage in learningSequence.learning_packages"> <div v-for="learningUnit in learningSequence.learningUnits">
<h3>{{ learningPackage.id }}</h3> {{ learningUnit.title }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,17 +11,31 @@ export default {
data() { data() {
return { return {
count: 0, count: 0,
circleData: {} circleData: {},
learningSequences: [],
} }
}, },
mounted() { mounted() {
log.debug('CircleAnalyseExampleView mounted', this.circleSlug); log.debug('CircleAnalyseExampleView mounted', this.circleSlug);
axios({ axios({
method: 'get', method: 'get',
url: `/wagtailapi/v2/pages/?type=learnpath.Circle&slug=${this.circleSlug}&fields=title,description,learning_sequences(title,learning_packages(title,my_title,learning_units(title)))`, url: `/learnpath/api/circle/${this.circleSlug}/`,
}).then((response) => { }).then((response) => {
log.debug(response.data.items[0]); log.debug(response.data);
this.circleData = response.data.items[0]; this.circleData = response.data;
let learningSequence = { learningUnits: [] };
this.circleData.children.forEach((child) => {
if (child.type === 'learnpath.LearningSequence') {
if (learningSequence.learningUnits.length) {
this.learningSequences.push(learningSequence);
}
learningSequence = Object.assign(child, { learningUnits: [] });
} else {
learningSequence.learningUnits.push(child);
}
});
log.debug(this.learningSequences);
}); });
} }
@ -61,7 +75,7 @@ export default {
</div> </div>
<div class="flex-auto bg-gray-100 px-4 py-8"> <div class="flex-auto bg-gray-100 px-4 py-8">
<div v-for="learningSequence in circleData.learning_sequences"> <div v-for="learningSequence in learningSequences">
<LearningSequence :learning-sequence="learningSequence"></LearningSequence> <LearningSequence :learning-sequence="learningSequence"></LearningSequence>
</div> </div>

View File

@ -18,7 +18,7 @@ from vbv_lernwelt.core.middleware.auth import django_view_authentication_exempt
from vbv_lernwelt.core.views import ( from vbv_lernwelt.core.views import (
rate_limit_exceeded_view, rate_limit_exceeded_view,
permission_denied_view, permission_denied_view,
check_rate_limit, cypress_reset_view, check_rate_limit, cypress_reset_view, vue_home,
) )
from .wagtail_api import wagtail_api_router from .wagtail_api import wagtail_api_router
@ -112,5 +112,5 @@ if settings.DEBUG:
# serve everything else via the vue app # serve everything else via the vue app
# urlpatterns += [re_path(r'^.*$', vue_home, name='home')] urlpatterns += [re_path(r'^.*$', vue_home, name='home')]