add EditCommentForm spec.js

This commit is contained in:
ALau2088 2019-06-27 10:59:53 -07:00
parent 5e9f46405e
commit 912b94d43c
5 changed files with 36 additions and 40 deletions

View File

@ -74,9 +74,6 @@ export default {
session.close()
return commentReturnedWithAuthor
},
UpdateComment: async (object, params, context, resolveInfo) => {
await neo4jgraphql(object, params, context, resolveInfo, false)
},
DeleteComment: async (object, params, context, resolveInfo) => {
const comment = await neo4jgraphql(object, params, context, resolveInfo, false)

View File

@ -9,7 +9,10 @@
color="primary"
size="small"
round
>{{ comments.length }}</ds-tag>&nbsp; Comments
>
{{ comments.length }}
</ds-tag>
&nbsp; Comments
</span>
</h3>
<ds-space margin-bottom="large" />

View File

@ -14,15 +14,14 @@
ghost
class="cancelBtn"
@click.prevent="closeEditWindow"
>{{ $t('actions.cancel') }}</ds-button>
>
{{ $t('actions.cancel') }}
</ds-button>
</ds-flex-item>
<ds-flex-item :width="{ base: '40%', md: '20%', sm: '40%', xs: '40%' }">
<ds-button
type="submit"
:loading="loading"
:disabled="disabled || errors"
primary
>{{ $t('post.comment.submit') }}</ds-button>
<ds-button type="submit" :loading="loading" :disabled="disabled || errors" primary>
{{ $t('post.comment.submit') }}
</ds-button>
</ds-flex-item>
</ds-flex>
</ds-card>
@ -36,26 +35,24 @@ import HcEditor from '~/components/Editor'
export default {
components: {
HcEditor
HcEditor,
},
props: {
post: { type: Object, default: () => {} },
comments: { type: Array, default: () => [] },
comment: {
type: Object,
default() {
return {}
}
}
},
},
},
data() {
return {
disabled: false,
loading: false,
form: {
content: this.comment.contentExcerpt
content: this.comment.contentExcerpt,
},
users: []
users: [],
}
},
methods: {
@ -77,22 +74,21 @@ export default {
this.$apollo
.mutate({
mutation: gql`
mutation($postId: ID, $content: String!, $id: ID!) {
UpdateComment(postId: $postId, content: $content, id: $id) {
mutation($content: String!, $id: ID!) {
UpdateComment(content: $content, id: $id) {
id
content
}
}
`,
variables: {
postId: this.post.id,
content: this.form.content,
id: this.comment.id
}
id: this.comment.id,
},
})
.then(res => {
this.loading = false
this.$root.$emit('refetchPostComments')
this.$toast.success(this.$t('post.comment.updated'))
this.disabled = false
this.$emit('showEditCommentMenu', false)
@ -100,7 +96,7 @@ export default {
.catch(err => {
this.$toast.error(err.message)
})
}
},
},
apollo: {
User: {
@ -114,8 +110,8 @@ export default {
},
result(result) {
this.users = result.data.User
}
}
}
},
},
},
}
</script>