Add first mutation
This commit is contained in:
parent
424e1c7f48
commit
f3a383d8dd
|
|
@ -122,7 +122,7 @@
|
|||
saveContentBlock() {
|
||||
this.$store.dispatch('saveContentBlock', {
|
||||
title: this.title,
|
||||
elements: this.elements
|
||||
contents: this.elements
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue