From d6316fc3284efeb987f89eecc7463372ad37f32e Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 11 Sep 2018 15:09:55 +0200 Subject: [PATCH] Update module query after mutation --- client/src/components/ContentBlock.vue | 1 - .../src/components/NewContentBlockWizard.vue | 85 ++++++++++++------- client/src/pages/module.vue | 41 ++++++--- client/src/store/index.js | 34 +++----- 4 files changed, 92 insertions(+), 69 deletions(-) diff --git a/client/src/components/ContentBlock.vue b/client/src/components/ContentBlock.vue index 82b520de..7e495072 100644 --- a/client/src/components/ContentBlock.vue +++ b/client/src/components/ContentBlock.vue @@ -7,7 +7,6 @@ -

{{contentBlock.title}}

{{contentBlock.id}}

diff --git a/client/src/components/NewContentBlockWizard.vue b/client/src/components/NewContentBlockWizard.vue index 8ae12283..260d169c 100644 --- a/client/src/components/NewContentBlockWizard.vue +++ b/client/src/components/NewContentBlockWizard.vue @@ -43,6 +43,8 @@ import TextForm from '@/components/content-forms/TextForm'; import TrashIcon from '@/components/icons/TrashIcon'; + import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.gql'; + export default { components: { Modal, @@ -120,9 +122,26 @@ this.$store.dispatch('hideModal'); }, saveContentBlock() { - this.$store.dispatch('saveContentBlock', { - title: this.title, - contents: this.elements + this.$apollo.mutate({ + mutation: NEW_CONTENT_BLOCK_MUTATION, + variables: { + input: { + contentBlock: { + title: this.title, + contents: [ + { + type: 'text_block', + text: 'Oh hai' + } + ] + }, + after: 'Q29udGVudEJsb2NrTm9kZToxOQ==' + } + }, + update: () => { + this.$store.dispatch('updateContentBlocks'); + this.$store.dispatch('hideModal'); + } }); } }, @@ -131,36 +150,36 @@ return { title: '', elements: [ - { - type: 'image' - }, - { - type: 'video', - url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' - }, - { - type: 'video', - url: 'https://vimeo.com/267384185' - }, - { - type: 'link' - }, - { - type: 'text' - }, - { - type: 'video' - }, - { - type: 'document' - }, - { - type: 'exercise' - }, - { - type: 'image' - }, - {} + // { + // type: 'image' + // }, + // { + // type: 'video', + // url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + // }, + // { + // type: 'video', + // url: 'https://vimeo.com/267384185' + // }, + // { + // type: 'link' + // }, + // { + // type: 'text' + // }, + // { + // type: 'video' + // }, + // { + // type: 'document' + // }, + // { + // type: 'exercise' + // }, + // { + // type: 'image' + // }, + // {} ] } } diff --git a/client/src/pages/module.vue b/client/src/pages/module.vue index e3615d11..f08df367 100644 --- a/client/src/pages/module.vue +++ b/client/src/pages/module.vue @@ -6,6 +6,8 @@