diff --git a/client/src/components/NewContentBlockWizard.vue b/client/src/components/NewContentBlockWizard.vue index 476f3eef..48e0b081 100644 --- a/client/src/components/NewContentBlockWizard.vue +++ b/client/src/components/NewContentBlockWizard.vue @@ -122,7 +122,7 @@ saveContentBlock() { this.$store.dispatch('saveContentBlock', { title: this.title, - elements: this.elements + contents: this.elements }); } }, diff --git a/client/src/store/index.js b/client/src/store/index.js index fd1f197c..9d0e66a3 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -1,5 +1,8 @@ import Vue from 'vue' import Vuex from 'vuex' +import apolloClient from '@/graphql/client' + +import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.gql'; Vue.use(Vuex) @@ -36,6 +39,23 @@ export default new Vuex.Store({ }, saveContentBlock({commit, dispatch}, payload) { commit('setNewContentBlock', payload); + apolloClient.mutate({ + mutation: NEW_CONTENT_BLOCK_MUTATION, + variables: { + input: { + contentBlock: { + title: payload.title, + contents: [ + { + type: 'text_block', + text: 'Oh hai' + } + ] + }, + after: 'Q29udGVudEJsb2NrTm9kZToxOQ==' + } + } + }); dispatch('hideModal'); } }, diff --git a/server/book/schema/mutations.py b/server/book/schema/mutations.py index 7d20ff46..8aa8052e 100644 --- a/server/book/schema/mutations.py +++ b/server/book/schema/mutations.py @@ -128,6 +128,7 @@ class AddContentBlock(relay.ClientIDMutation): new_contents = handle_content_blocks(contents) # can only do this after the content block has been saved new_content_block.contents = json.dumps(new_contents) + new_content_block.save() return new_content_block diff --git a/server/book/tests/test_module_mutations.py b/server/book/tests/test_module_mutations.py index 369e4692..44eebadd 100644 --- a/server/book/tests/test_module_mutations.py +++ b/server/book/tests/test_module_mutations.py @@ -46,6 +46,7 @@ class NewContentBlockMutationTest(TestCase): new_content_block = result.get('data').get('addContentBlock').get('newContentBlock') self.assertEqual(new_content_block.get('title'), title) + self.assertEqual(len(new_content_block['contents']), 1) id = new_content_block.get('id') content_block_page = get_object(ContentBlock, id)