2026-06-04 18:35:20 +03:00
|
|
|
import { defineAsyncComponent } from 'vue'
|
2026-03-24 21:42:22 +02:00
|
|
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
2026-02-13 14:26:39 +02:00
|
|
|
|
2023-04-06 14:15:57 -04:00
|
|
|
const DraftCloser = {
|
2026-01-06 16:22:52 +02:00
|
|
|
data() {
|
2023-04-06 14:15:57 -04:00
|
|
|
return {
|
2026-01-06 16:22:52 +02:00
|
|
|
showing: false,
|
2023-04-06 14:15:57 -04:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components: {
|
2026-06-04 18:35:20 +03:00
|
|
|
DialogModal: defineAsyncComponent(
|
|
|
|
|
() => import('src/components/dialog_modal/dialog_modal.vue'),
|
|
|
|
|
),
|
2023-04-06 14:15:57 -04:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
emits: ['save', 'discard'],
|
2023-04-06 14:15:57 -04:00
|
|
|
computed: {
|
2026-01-06 16:22:52 +02:00
|
|
|
action() {
|
2026-03-24 21:42:22 +02:00
|
|
|
if (useMergedConfigStore().mergedConfig.autoSaveDraft) {
|
2023-04-06 15:13:20 -04:00
|
|
|
return 'save'
|
|
|
|
|
} else {
|
2026-03-24 21:42:22 +02:00
|
|
|
return useMergedConfigStore().mergedConfig.unsavedPostAction
|
2023-04-06 15:13:20 -04:00
|
|
|
}
|
2023-04-06 14:15:57 -04:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
shouldConfirm() {
|
2023-04-06 14:15:57 -04:00
|
|
|
return this.action === 'confirm'
|
2026-01-06 16:22:52 +02:00
|
|
|
},
|
2023-04-06 14:15:57 -04:00
|
|
|
},
|
|
|
|
|
methods: {
|
2026-01-06 16:22:52 +02:00
|
|
|
requestClose() {
|
2023-04-06 14:15:57 -04:00
|
|
|
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() {
|
2023-04-06 14:15:57 -04:00
|
|
|
this.$emit('save')
|
|
|
|
|
this.showing = false
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
discard() {
|
2023-04-06 14:15:57 -04:00
|
|
|
this.$emit('discard')
|
|
|
|
|
this.showing = false
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
cancel() {
|
2023-04-06 14:15:57 -04:00
|
|
|
this.showing = false
|
2026-01-06 16:22:52 +02:00
|
|
|
},
|
|
|
|
|
},
|
2023-04-06 14:15:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DraftCloser
|