fantasia-archive/src/components/dialogs/CloseDocumentCheck.vue

89 lines
2.1 KiB
Vue
Raw Normal View History

<template>
<q-dialog
v-model="dialogModel"
2021-05-09 02:05:13 +12:00
@before-hide="triggerDialogClose"
>
<q-card dark class="documentCloseDialog">
<q-card-section class="row justify-center">
2021-04-28 06:06:01 +12:00
<h6 class="text-center q-my-sm">Discard changes to <span class="text-primary">{{retrieveFieldValue(dialogDocument,'name')}}</span>?</h6>
</q-card-section>
<q-card-actions align="around" class="q-mx-xl q-mt-lg q-mb-md">
<q-btn
flat
label="Cancel"
2021-03-04 13:27:07 +13:00
color="accent"
v-close-popup />
<q-btn
2021-03-04 13:27:07 +13:00
outline
label="Discard changes"
2021-03-04 13:27:07 +13:00
color="secondary"
@click="closeDocument(dialogDocument)" />
</q-card-actions>
</q-card>
</q-dialog>
</template>
<script lang="ts">
import { Component, Watch, Prop } from "vue-property-decorator"
import DialogBase from "src/components/dialogs/_DialogBase"
import { I_OpenedDocument } from "src/interfaces/I_OpenedDocument"
@Component({
components: { }
})
export default class CloseDocumentCheckDialog extends DialogBase {
2021-04-03 12:33:49 +13:00
/**
* React to dialog opening request
*/
@Watch("dialogTrigger")
openDialog (val: string|false) {
if (val) {
this.checkForCloseOpenedDocument()
}
}
2021-04-03 12:33:49 +13:00
/**
* Current document being processed by the dialog
*/
@Prop() readonly dialogDocument!: I_OpenedDocument
2021-04-03 12:33:49 +13:00
/**
* Determine if the document has edits or not. Based on this either skip this dialog altogether or show it.
*/
checkForCloseOpenedDocument () {
const input = this.dialogDocument
if (input?.hasEdits) {
if (this.SGET_getDialogsState) {
return
}
this.SSET_setDialogState(true)
this.dialogModel = true
}
else {
2021-03-08 11:07:40 +13:00
this.closeDocument(input)
}
}
2021-04-03 12:33:49 +13:00
/**
* Closes the document and removes it from the list
*/
2021-03-08 11:07:40 +13:00
closeDocument (input: I_OpenedDocument) {
const dataPass = { doc: input, treeAction: false }
2021-04-03 12:33:49 +13:00
this.SSET_removeOpenedDocument(dataPass)
2021-03-18 10:26:08 +13:00
this.dialogModel = false
this.SSET_setDialogState(false)
}
}
</script>
<style lang="scss" scoped>
.documentCloseDialog {
min-width: 600px;
}
</style>