2019-09-20 03:27:37 +10:00
|
|
|
import PostStatusForm from '../post_status_form/post_status_form.vue'
|
2019-10-18 22:05:01 +11:00
|
|
|
import Modal from '../modal/modal.vue'
|
2019-09-29 06:35:39 +10:00
|
|
|
import get from 'lodash/get'
|
2019-09-20 03:27:37 +10:00
|
|
|
|
|
|
|
const PostStatusModal = {
|
|
|
|
components: {
|
2019-10-18 22:05:01 +11:00
|
|
|
PostStatusForm,
|
|
|
|
Modal
|
2019-09-20 03:27:37 +10:00
|
|
|
},
|
2019-09-29 06:35:39 +10:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
resettingForm: false
|
|
|
|
}
|
|
|
|
},
|
2019-09-20 03:27:37 +10:00
|
|
|
computed: {
|
2020-06-13 21:42:53 +10:00
|
|
|
isLoggedIn () {
|
|
|
|
return !!this.$store.state.users.currentUser
|
|
|
|
},
|
2019-09-29 06:35:39 +10:00
|
|
|
modalActivated () {
|
|
|
|
return this.$store.state.postStatus.modalActivated
|
|
|
|
},
|
|
|
|
isFormVisible () {
|
|
|
|
return this.isLoggedIn && !this.resettingForm && this.modalActivated
|
2019-09-20 03:27:37 +10:00
|
|
|
},
|
|
|
|
params () {
|
2019-09-20 04:38:55 +10:00
|
|
|
return this.$store.state.postStatus.params || {}
|
2019-09-20 03:27:37 +10:00
|
|
|
}
|
|
|
|
},
|
2019-09-20 03:52:54 +10:00
|
|
|
watch: {
|
2019-09-29 06:35:39 +10:00
|
|
|
params (newVal, oldVal) {
|
|
|
|
if (get(newVal, 'repliedUser.id') !== get(oldVal, 'repliedUser.id')) {
|
|
|
|
this.resettingForm = true
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.resettingForm = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
isFormVisible (val) {
|
2019-09-20 03:52:54 +10:00
|
|
|
if (val) {
|
2019-09-29 06:35:39 +10:00
|
|
|
this.$nextTick(() => this.$el && this.$el.querySelector('textarea').focus())
|
2019-09-20 03:52:54 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-09-20 03:27:37 +10:00
|
|
|
methods: {
|
|
|
|
closeModal () {
|
|
|
|
this.$store.dispatch('closePostStatusModal')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PostStatusModal
|