Support editing

This commit is contained in:
tusooa 2023-03-10 19:24:01 -05:00
parent a9f374b18f
commit 8d27c68d5f
No known key found for this signature in database
GPG Key ID: 42AEC43D48433C51
6 changed files with 63 additions and 31 deletions

View File

@ -1,10 +1,12 @@
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import EditStatusForm from 'src/components/edit_status_form/edit_status_form.vue'
import ConfirmModal from 'src/components/confirm_modal/confirm_modal.vue' import ConfirmModal from 'src/components/confirm_modal/confirm_modal.vue'
import StatusContent from 'src/components/status_content/status_content.vue' import StatusContent from 'src/components/status_content/status_content.vue'
const Draft = { const Draft = {
components: { components: {
PostStatusForm, PostStatusForm,
EditStatusForm,
ConfirmModal, ConfirmModal,
StatusContent StatusContent
}, },

View File

@ -46,9 +46,15 @@
</div> </div>
<div v-if="editing"> <div v-if="editing">
<PostStatusForm <PostStatusForm
v-if="draft.type !== 'edit'"
v-bind="postStatusFormProps" v-bind="postStatusFormProps"
@posted="handlePosted" @posted="handlePosted"
/> />
<EditStatusForm
v-else
:params="postStatusFormProps"
@posted="handlePosted"
/>
</div> </div>
<teleport to="#modal"> <teleport to="#modal">
<confirm-modal <confirm-modal

View File

@ -0,0 +1,41 @@
import PostStatusForm from '../post_status_form/post_status_form.vue'
import statusPosterService from '../../services/status_poster/status_poster.service.js'
const EditStatusForm = {
components: {
PostStatusForm
},
props: {
params: {
type: Object,
required: true
}
},
methods: {
doEditStatus ({ status, spoilerText, sensitive, media, contentType, poll }) {
const params = {
store: this.$store,
statusId: this.params.statusId,
status,
spoilerText,
sensitive,
poll,
media,
contentType
}
return statusPosterService.editStatus(params)
.then((data) => {
return data
})
.catch((err) => {
console.error('Error editing status', err)
return {
error: err.message
}
})
}
}
}
export default EditStatusForm

View File

@ -0,0 +1,10 @@
<template>
<PostStatusForm
v-bind="params"
:post-handler="doEditStatus"
:disable-polls="true"
:disable-visibility-selector="true"
/>
</template>
<script src="./edit_status_form.js"></script>

View File

@ -1,11 +1,10 @@
import PostStatusForm from '../post_status_form/post_status_form.vue' import EditStatusForm from '../edit_status_form/edit_status_form.vue'
import Modal from '../modal/modal.vue' import Modal from '../modal/modal.vue'
import statusPosterService from '../../services/status_poster/status_poster.service.js'
import get from 'lodash/get' import get from 'lodash/get'
const EditStatusModal = { const EditStatusModal = {
components: { components: {
PostStatusForm, EditStatusForm,
Modal Modal
}, },
data () { data () {
@ -43,29 +42,6 @@ const EditStatusModal = {
} }
}, },
methods: { methods: {
doEditStatus ({ status, spoilerText, sensitive, media, contentType, poll }) {
const params = {
store: this.$store,
statusId: this.$store.state.editStatus.params.statusId,
status,
spoilerText,
sensitive,
poll,
media,
contentType
}
return statusPosterService.editStatus(params)
.then((data) => {
return data
})
.catch((err) => {
console.error('Error editing status', err)
return {
error: err.message
}
})
},
closeModal () { closeModal () {
this.$store.dispatch('closeEditStatusModal') this.$store.dispatch('closeEditStatusModal')
} }

View File

@ -8,12 +8,9 @@
<div class="panel-heading"> <div class="panel-heading">
{{ $t('post_status.edit_status') }} {{ $t('post_status.edit_status') }}
</div> </div>
<PostStatusForm <EditStatusForm
class="panel-body" class="panel-body"
v-bind="params" :params="params"
:post-handler="doEditStatus"
:disable-polls="true"
:disable-visibility-selector="true"
@posted="closeModal" @posted="closeModal"
/> />
</div> </div>