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() session.close()
return commentReturnedWithAuthor return commentReturnedWithAuthor
}, },
UpdateComment: async (object, params, context, resolveInfo) => {
await neo4jgraphql(object, params, context, resolveInfo, false)
},
DeleteComment: async (object, params, context, resolveInfo) => { DeleteComment: async (object, params, context, resolveInfo) => {
const comment = await neo4jgraphql(object, params, context, resolveInfo, false) const comment = await neo4jgraphql(object, params, context, resolveInfo, false)

View File

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

View File

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