And now also get rid of edges

This commit is contained in:
Pawel Kowalski 2018-08-18 00:40:30 +02:00
parent de14c02f0a
commit d6d8d60c9b
6 changed files with 9 additions and 7 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="chapter"> <div class="chapter">
<h3>{{chapter.title}}</h3> <h3>{{chapter.title}}</h3>
<content-block :contentBlock="contentBlock" :key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks.edges"> <content-block :contentBlock="contentBlock" :key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks">
</content-block> </content-block>
</div> </div>

View File

@ -8,9 +8,9 @@
</div> </div>
<h3>Lernziele</h3> <h3>Lernziele</h3>
<objective-group v-for="group in module.objectivegroupSet.edges" :key="group.id" :group="group"></objective-group> <objective-group v-for="group in module.objectivegroupSet" :key="group.id" :group="group"></objective-group>
<chapter :chapter="chapter" v-for="chapter in module.chapters.edges" :key="chapter.id"></chapter> <chapter :chapter="chapter" v-for="chapter in module.chapters" :key="chapter.id"></chapter>
<h3>1.1 Lehrbeginn</h3> <h3>1.1 Lehrbeginn</h3>
<h4>Das Interview</h4> <h4>Das Interview</h4>
<h4>Tipp</h4> <h4>Tipp</h4>

View File

@ -3,7 +3,7 @@
<h4>{{group.title}}</h4> <h4>{{group.title}}</h4>
<ul class="objective-group__objective-list"> <ul class="objective-group__objective-list">
<li class="objective-group__objective" v-for="objective in group.objectiveSet.edges" :key="objective.id"> <li class="objective-group__objective" v-for="objective in group.objectiveSet" :key="objective.id">
{{objective.text}} {{objective.text}}
</li> </li>
</ul> </ul>

View File

@ -19,10 +19,11 @@ EdgesNodePlugin.install = function (Vue, options) {
if (typeof collection === 'object') { if (typeof collection === 'object') {
let newObj = {} let newObj = {}
for (const k in collection) { for (const k in collection) {
if (k === 'node') { if (k === 'edges' || k === 'node') {
newObj = getRidOfEdges(collection[k]) newObj = getRidOfEdges(collection[k])
} else { } else {
newObj[k] = getRidOfEdges(collection[k]) newObj[k] = getRidOfEdges(collection[k])
delete newObj[k]['__typename']
} }
} }
return newObj return newObj

View File

@ -16,6 +16,7 @@
</template> </template>
<script> <script>
import Vue from 'vue'
import ALL_MODULES from '@/graphql/gql/allModules.gql' import ALL_MODULES from '@/graphql/gql/allModules.gql'
export default { export default {
@ -32,7 +33,7 @@
manual: true, manual: true,
result({data, loading, networkStatus}) { result({data, loading, networkStatus}) {
if (!loading) { if (!loading) {
this.modules = data.modules.edges.map(node => node.node); this.modules = Vue.getRidOfEdges(data).modules
} }
} }
} }

View File

@ -19,7 +19,7 @@
result({data, loading, networkStatus}) { result({data, loading, networkStatus}) {
if (!loading) { if (!loading) {
const purgedData = Vue.getRidOfEdges(data) const purgedData = Vue.getRidOfEdges(data)
this.module = purgedData.modules.edges[0] this.module = purgedData.modules[0]
} }
} }
} }