Get clear working properly

This commit is contained in:
Matt Rider 2019-04-24 20:56:15 -03:00
parent 05d393064a
commit 7fafa1eb6e
2 changed files with 15 additions and 9 deletions

View File

@ -154,7 +154,10 @@
</ds-button> </ds-button>
</div> </div>
</editor-floating-menu> </editor-floating-menu>
<editor-content :editor="editor" /> <editor-content
ref="editor"
:editor="editor"
/>
</div> </div>
</template> </template>
@ -445,6 +448,9 @@ export default {
// remove link // remove link
command({ href: null }) command({ href: null })
} }
},
clear() {
this.editor.clearContent(true)
} }
} }
} }

View File

@ -107,7 +107,7 @@
color="primary" color="primary"
size="small" size="small"
round round
>{{ post.commentsCount }}</ds-tag>&nbsp; Comments >{{ comments.length }}</ds-tag>&nbsp; Comments
</span> </span>
</h3> </h3>
</ds-flex-item> </ds-flex-item>
@ -121,6 +121,7 @@
<ds-card> <ds-card>
<no-ssr> <no-ssr>
<hc-editor <hc-editor
ref="editor"
:users="users" :users="users"
:value="form.content" :value="form.content"
@input="updateEditorContent" @input="updateEditorContent"
@ -133,7 +134,7 @@
<ds-button <ds-button
:disabled="loading || disabled" :disabled="loading || disabled"
ghost ghost
@click.prevent="clearEditor" @click.prevent="clear"
> >
{{ $t('actions.cancel') }} {{ $t('actions.cancel') }}
</ds-button> </ds-button>
@ -346,15 +347,13 @@ export default {
} }
this.$refs.commentForm.update('content', value) this.$refs.commentForm.update('content', value)
}, },
clearEditor() { clear() {
this.form.content = ' ' this.$refs.editor.clear()
}, },
addComment(comment) { addComment(comment) {
this.$apollo.queries.CommentByPost.refetch() this.$apollo.queries.CommentByPost.refetch()
}, },
handleSubmit() { handleSubmit() {
const content = this.form.content
this.form.content = ' '
this.$apollo this.$apollo
.mutate({ .mutate({
mutation: gql` mutation: gql`
@ -367,11 +366,12 @@ export default {
`, `,
variables: { variables: {
postId: this.post.id, postId: this.post.id,
content content: this.form.content
} }
}) })
.then(res => { .then(res => {
this.addComment(res.data.CreateComment) this.addComment(res.data.CreateComment)
this.$refs.editor.clear()
this.loading = false this.loading = false
this.disabled = false this.disabled = false
this.$toast.success(this.$t('post.comment.submitted')) this.$toast.success(this.$t('post.comment.submitted'))
@ -395,7 +395,7 @@ export default {
}, },
fetchPolicy: 'cache-and-network' fetchPolicy: 'cache-and-network'
}, },
User: { User: {
query() { query() {
return gql(`{ return gql(`{
User(orderBy: slug_asc) { User(orderBy: slug_asc) {