do the save to drafts/save to drafts and close

This commit is contained in:
Henry Jameson 2025-01-08 21:02:52 +02:00
parent ad8579af99
commit c0875ee34e
5 changed files with 21 additions and 6 deletions

View file

@ -102,6 +102,7 @@ const PostStatusForm = {
'disablePreview',
'disableDraft',
'hideDraft',
'closeable',
'placeholder',
'maxHeight',
'postHandler',
@ -234,6 +235,9 @@ const PostStatusForm = {
showAllScopes () {
return !this.mergedConfig.minimalScopesMode
},
hideExtraActions () {
return this.disableDraft || this.hideDraft
},
emojiUserSuggestor () {
return suggestor({
emoji: [
@ -355,10 +359,12 @@ const PostStatusForm = {
}
},
safeToSaveDraft () {
return this.newStatus.status ||
return (
this.newStatus.status ||
this.newStatus.spoilerText ||
this.newStatus.files?.length ||
this.newStatus.hasPoll
) && this.saveable
},
...mapGetters(['mergedConfig']),
...mapState({
@ -762,6 +768,7 @@ const PostStatusForm = {
this.newStatus.id = id
}
this.saveable = false
this.clearStatus()
this.$emit('draft-done')
})
} else if (this.newStatus.id) {
@ -769,6 +776,7 @@ const PostStatusForm = {
return this.abandonDraft()
.then(() => {
this.saveable = false
this.clearStatus()
this.$emit('draft-done')
})
}

View file

@ -316,13 +316,12 @@
</template>
</button>
<Popover
v-if="!hideDraft"
v-if="!hideExtraActions"
class="more-post-actions"
:normal-button="true"
trigger="click"
placement="bottom"
:offset="{ y: 5 }"
:bound-to="{ x: 'container' }"
>
<template #trigger>
<FAIcon
@ -336,7 +335,7 @@
role="menu"
>
<button
v-if="!hideDraft"
v-if="!hideDraft || !disableDraft"
class="menu-item dropdown-item dropdown-item-icon"
role="menu"
:disabled="!safeToSaveDraft && saveable"
@ -344,7 +343,12 @@
@click.prevent="saveDraft"
@click="close"
>
{{ $t('post_status.save_to_drafts_button') }}
<template v-if="closeable">
{{ $t('post_status.save_to_drafts_and_close_button') }}
</template>
<template v-else>
{{ $t('post_status.save_to_drafts_button') }}
</template>
</button>
</div>
</template>

View file

@ -14,6 +14,7 @@
<PostStatusForm
class="panel-body"
v-bind="params"
:closeable="true"
@posted="resetAndClose"
@draft-done="resetAndClose"
/>

View file

@ -598,6 +598,7 @@
<PostStatusForm
ref="postStatusForm"
class="reply-body"
:closeable="true"
:reply-to="status.id"
:attentions="status.attentions"
:replied-user="status.user"

View file

@ -321,7 +321,8 @@
"auto_save_nothing_new": "Nothing new to save.",
"auto_save_saved": "Saved.",
"auto_save_saving": "Saving...",
"save_to_drafts_button": "Save to drafts"
"save_to_drafts_button": "Save to drafts",
"save_to_drafts_and_close_button": "Save to drafts and close"
},
"registration": {
"bio_optional": "Bio (optional)",