Allow confirmation on closing reply form
This commit is contained in:
parent
b27f696d77
commit
fb87477298
11 changed files with 170 additions and 14 deletions
48
src/components/draft_closer/draft_closer.js
Normal file
48
src/components/draft_closer/draft_closer.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import DialogModal from 'src/components/dialog_modal/dialog_modal.vue'
|
||||
|
||||
const DraftCloser = {
|
||||
data () {
|
||||
return {
|
||||
showing: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
DialogModal
|
||||
},
|
||||
emits: [
|
||||
'save',
|
||||
'discard'
|
||||
],
|
||||
computed: {
|
||||
action () {
|
||||
return this.$store.getters.mergedConfig.unsavedPostAction
|
||||
},
|
||||
shouldConfirm () {
|
||||
return this.action === 'confirm'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
requestClose () {
|
||||
if (this.shouldConfirm) {
|
||||
this.showing = true
|
||||
} else if (this.action === 'save') {
|
||||
this.save()
|
||||
} else {
|
||||
this.discard()
|
||||
}
|
||||
},
|
||||
save () {
|
||||
this.$emit('save')
|
||||
this.showing = false
|
||||
},
|
||||
discard () {
|
||||
this.$emit('discard')
|
||||
this.showing = false
|
||||
},
|
||||
cancel () {
|
||||
this.showing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default DraftCloser
|
||||
43
src/components/draft_closer/draft_closer.vue
Normal file
43
src/components/draft_closer/draft_closer.vue
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<template>
|
||||
<teleport to="#modal">
|
||||
<dialog-modal
|
||||
v-if="showing"
|
||||
v-body-scroll-lock="true"
|
||||
class="confirm-modal"
|
||||
:on-cancel="cancel"
|
||||
>
|
||||
<template #header>
|
||||
<span>
|
||||
{{ $t('post_status.close_confirm_title') }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
{{ $t('post_status.close_confirm') }}
|
||||
|
||||
<template #footer>
|
||||
<button
|
||||
class="btn button-default"
|
||||
@click.prevent="save"
|
||||
>
|
||||
{{ $t('post_status.close_confirm_save_button') }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="btn button-default"
|
||||
@click.prevent="discard"
|
||||
>
|
||||
{{ $t('post_status.close_confirm_discard_button') }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="btn button-default"
|
||||
@click.prevent="cancel"
|
||||
>
|
||||
{{ $t('post_status.close_confirm_continue_composing_button') }}
|
||||
</button>
|
||||
</template>
|
||||
</dialog-modal>
|
||||
</teleport>
|
||||
</template>
|
||||
|
||||
<script src="./draft_closer.js"></script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue