pleroma-fe/src/components/draft_closer/draft_closer.js

49 lines
943 B
JavaScript
Raw Normal View History

import DialogModal from 'src/components/dialog_modal/dialog_modal.vue'
const DraftCloser = {
2026-01-06 16:22:52 +02:00
data() {
return {
2026-01-06 16:22:52 +02:00
showing: false,
}
},
components: {
2026-01-06 16:22:52 +02:00
DialogModal,
},
2026-01-06 16:22:52 +02:00
emits: ['save', 'discard'],
computed: {
2026-01-06 16:22:52 +02:00
action() {
2023-04-06 15:13:20 -04:00
if (this.$store.getters.mergedConfig.autoSaveDraft) {
return 'save'
} else {
return this.$store.getters.mergedConfig.unsavedPostAction
}
},
2026-01-06 16:22:52 +02:00
shouldConfirm() {
return this.action === 'confirm'
2026-01-06 16:22:52 +02:00
},
},
methods: {
2026-01-06 16:22:52 +02:00
requestClose() {
if (this.shouldConfirm) {
this.showing = true
} else if (this.action === 'save') {
this.save()
} else {
this.discard()
}
},
2026-01-06 16:22:52 +02:00
save() {
this.$emit('save')
this.showing = false
},
2026-01-06 16:22:52 +02:00
discard() {
this.$emit('discard')
this.showing = false
},
2026-01-06 16:22:52 +02:00
cancel() {
this.showing = false
2026-01-06 16:22:52 +02:00
},
},
}
export default DraftCloser