mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Hide CommentForm when an edit is in progress
- Follow @Tirokk PR review
This commit is contained in:
parent
36c4a22b76
commit
c7dc2f6a5c
@ -35,11 +35,8 @@
|
|||||||
@showEditCommentMenu="editCommentMenu"
|
@showEditCommentMenu="editCommentMenu"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-show="!openEditCommentMenu">
|
||||||
v-if="isCollapsed && !openEditCommentMenu"
|
<div v-if="isCollapsed" v-html="comment.contentExcerpt" style="padding-left: 40px;" />
|
||||||
v-html="comment.contentExcerpt"
|
|
||||||
style="padding-left: 40px;"
|
|
||||||
/>
|
|
||||||
<div
|
<div
|
||||||
v-show="comment.content !== comment.contentExcerpt"
|
v-show="comment.content !== comment.contentExcerpt"
|
||||||
style="text-align: right; margin-right: 20px; margin-top: -12px;"
|
style="text-align: right; margin-right: 20px; margin-top: -12px;"
|
||||||
@ -54,6 +51,7 @@
|
|||||||
{{ $t('comment.show.less') }}
|
{{ $t('comment.show.less') }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<ds-space margin-bottom="small" />
|
<ds-space margin-bottom="small" />
|
||||||
</ds-card>
|
</ds-card>
|
||||||
</div>
|
</div>
|
||||||
@ -61,7 +59,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import HcUser from '~/components/User'
|
import HcUser from '~/components/User'
|
||||||
import ContentMenu from '~/components/ContentMenu'
|
import ContentMenu from '~/components/ContentMenu'
|
||||||
import HcEditCommentForm from '~/components/comments/EditCommentForm'
|
import HcEditCommentForm from '~/components/comments/EditCommentForm'
|
||||||
@ -126,11 +124,15 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapMutations({
|
||||||
|
setEditPending: 'editor/SET_EDIT_PENDING',
|
||||||
|
}),
|
||||||
isAuthor(id) {
|
isAuthor(id) {
|
||||||
return this.user.id === id
|
return this.user.id === id
|
||||||
},
|
},
|
||||||
editCommentMenu(showMenu) {
|
editCommentMenu(showMenu) {
|
||||||
this.openEditCommentMenu = showMenu
|
this.openEditCommentMenu = showMenu
|
||||||
|
this.setEditPending(showMenu)
|
||||||
},
|
},
|
||||||
async deleteCommentCallback() {
|
async deleteCommentCallback() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-form v-model="form" @submit="handleSubmit">
|
<ds-form v-show="!editPending" v-model="form" @submit="handleSubmit">
|
||||||
<template slot-scope="{ errors }">
|
<template slot-scope="{ errors }">
|
||||||
<ds-card>
|
<ds-card>
|
||||||
<hc-editor ref="editor" :users="users" :value="form.content" @input="updateEditorContent" />
|
<hc-editor ref="editor" :users="users" :value="form.content" @input="updateEditorContent" />
|
||||||
@ -27,6 +27,7 @@ import gql from 'graphql-tag'
|
|||||||
import HcEditor from '~/components/Editor/Editor'
|
import HcEditor from '~/components/Editor/Editor'
|
||||||
import PostCommentsQuery from '~/graphql/PostCommentsQuery.js'
|
import PostCommentsQuery from '~/graphql/PostCommentsQuery.js'
|
||||||
import CommentMutations from '~/graphql/CommentMutations.js'
|
import CommentMutations from '~/graphql/CommentMutations.js'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -46,6 +47,11 @@ export default {
|
|||||||
users: [],
|
users: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
editPending: 'editor/editPending',
|
||||||
|
}),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateEditorContent(value) {
|
updateEditorContent(value) {
|
||||||
const content = value.replace(/<(?:.|\n)*?>/gm, '').trim()
|
const content = value.replace(/<(?:.|\n)*?>/gm, '').trim()
|
||||||
|
|||||||
@ -40,6 +40,7 @@ describe('CommentForm.vue', () => {
|
|||||||
'editor/placeholder': () => {
|
'editor/placeholder': () => {
|
||||||
return 'some cool placeholder'
|
return 'some cool placeholder'
|
||||||
},
|
},
|
||||||
|
'editor/editPending': () => false,
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
getters,
|
getters,
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
import HcEditor from '~/components/Editor/Editor'
|
import HcEditor from '~/components/Editor/Editor'
|
||||||
|
import { mapMutations } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -56,6 +57,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapMutations({
|
||||||
|
setEditPending: 'editor/SET_EDIT_PENDING',
|
||||||
|
}),
|
||||||
updateEditorContent(value) {
|
updateEditorContent(value) {
|
||||||
const content = value.replace(/<(?:.|\n)*?>/gm, '').trim()
|
const content = value.replace(/<(?:.|\n)*?>/gm, '').trim()
|
||||||
if (content.length < 1) {
|
if (content.length < 1) {
|
||||||
@ -92,6 +96,7 @@ export default {
|
|||||||
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)
|
||||||
|
this.setEditPending(false)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
this.$toast.error(err.message)
|
this.$toast.error(err.message)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
export const state = () => {
|
export const state = () => {
|
||||||
return {
|
return {
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
|
editPending: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8,10 +9,16 @@ export const getters = {
|
|||||||
placeholder(state) {
|
placeholder(state) {
|
||||||
return state.placeholder
|
return state.placeholder
|
||||||
},
|
},
|
||||||
|
editPending(state) {
|
||||||
|
return state.editPending
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
SET_PLACEHOLDER_TEXT(state, text) {
|
SET_PLACEHOLDER_TEXT(state, text) {
|
||||||
state.placeholder = text
|
state.placeholder = text
|
||||||
},
|
},
|
||||||
|
SET_EDIT_PENDING(state, boolean) {
|
||||||
|
state.editPending = boolean
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user