2021-03-05 01:51:11 +13:00
|
|
|
<template>
|
|
|
|
<q-dialog
|
|
|
|
v-model="dialogModel"
|
2021-05-09 02:05:13 +12:00
|
|
|
@before-hide="triggerDialogClose"
|
2021-03-05 01:51:11 +13:00
|
|
|
>
|
|
|
|
<q-card dark class="documentCloseDialog">
|
|
|
|
<q-card-section class="row justify-center">
|
|
|
|
<h6 class="text-center q-my-sm">Delete <span class="text-primary">{{retrieveFieldValue(currentDocument, 'name')}}</span>?</h6>
|
|
|
|
</q-card-section>
|
|
|
|
|
|
|
|
<q-card-section class="row justify-center q-mx-xl">
|
|
|
|
<div>
|
2021-04-18 02:43:13 +12:00
|
|
|
The document will be deleted <span class="text-bold text-secondary">FOREVER</span> with no way to retrieve it.
|
2021-03-05 01:51:11 +13:00
|
|
|
<br>
|
2021-06-07 12:57:36 +12:00
|
|
|
<span class="text-caption">(unless a previous save of the project exists from earlier time that cointains it)</span>
|
2021-03-05 01:51:11 +13:00
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
|
|
|
|
Proceed?
|
|
|
|
</div>
|
|
|
|
</q-card-section>
|
|
|
|
|
|
|
|
<q-card-actions align="around" class="q-mx-xl q-mt-lg q-mb-md">
|
|
|
|
<q-btn
|
|
|
|
flat
|
|
|
|
label="Cancel"
|
|
|
|
color="accent"
|
|
|
|
v-close-popup />
|
|
|
|
<q-btn
|
|
|
|
outline
|
2021-04-10 12:22:31 +12:00
|
|
|
:disable="!retrieveFieldValue(currentDocument, 'name')"
|
2021-03-05 01:51:11 +13:00
|
|
|
label="Delete document"
|
|
|
|
color="secondary"
|
|
|
|
@click="deleteDocument()" />
|
|
|
|
</q-card-actions>
|
|
|
|
</q-card>
|
|
|
|
</q-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
2021-04-10 12:22:31 +12:00
|
|
|
import { Component, Watch, Prop } from "vue-property-decorator"
|
2021-03-05 01:51:11 +13:00
|
|
|
|
|
|
|
import DialogBase from "src/components/dialogs/_DialogBase"
|
2021-04-26 09:01:41 +12:00
|
|
|
import { I_ShortenedDocument } from "src/interfaces/I_OpenedDocument"
|
2021-03-05 01:51:11 +13:00
|
|
|
import PouchDB from "pouchdb"
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: { }
|
|
|
|
})
|
|
|
|
export default class DeleteDocumentCheckDialog extends DialogBase {
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* React to dialog opening request
|
|
|
|
*/
|
2021-03-05 01:51:11 +13:00
|
|
|
@Watch("dialogTrigger")
|
2021-04-26 09:01:41 +12:00
|
|
|
openDialog (val: string|false) {
|
2021-04-10 12:22:31 +12:00
|
|
|
if (val && (this.SGET_allOpenedDocuments.docs.length > 0 || (this.documentType.length > 0 && this.documentId.length > 0))) {
|
2021-03-05 01:51:11 +13:00
|
|
|
if (this.SGET_getDialogsState) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.SSET_setDialogState(true)
|
|
|
|
this.dialogModel = true
|
2021-04-10 12:22:31 +12:00
|
|
|
|
|
|
|
const documentID = (this.documentId.length > 0) ? this.documentId : this.$route.params.id
|
2021-04-26 09:01:41 +12:00
|
|
|
this.currentDocument = this.SGET_document(documentID)
|
2021-03-05 01:51:11 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-10 12:22:31 +12:00
|
|
|
/**
|
|
|
|
* OPTIONAL
|
|
|
|
* Type of the document to delete
|
|
|
|
*/
|
|
|
|
@Prop({ default: "" }) readonly documentType!: ""
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OPTIONAL
|
|
|
|
* ID of the document to delete
|
|
|
|
*/
|
|
|
|
@Prop({ default: "" }) readonly documentId!: ""
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Current document for deletion
|
|
|
|
*/
|
2021-04-26 09:01:41 +12:00
|
|
|
currentDocument = false as unknown as I_ShortenedDocument
|
2021-03-05 01:51:11 +13:00
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Delete the document
|
|
|
|
*/
|
2021-03-05 01:51:11 +13:00
|
|
|
async deleteDocument () {
|
2021-04-27 01:01:51 +12:00
|
|
|
const documentID = (this.documentId.length > 0) ? this.documentId : this.$route.params.id
|
|
|
|
|
2021-04-10 12:22:31 +12:00
|
|
|
const documentType = (this.documentType.length > 0) ? this.documentType : this.$route.params.type
|
2021-04-26 09:01:41 +12:00
|
|
|
window.FA_dbs[documentType] = new PouchDB(documentType)
|
2021-03-05 01:51:11 +13:00
|
|
|
|
2021-04-27 01:01:51 +12:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
|
|
this.currentDocument = await window.FA_dbs[documentType].get(documentID)
|
|
|
|
|
2021-04-26 09:01:41 +12:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
|
|
await window.FA_dbs[documentType].remove(this.currentDocument)
|
2021-03-05 01:51:11 +13:00
|
|
|
|
|
|
|
const dataPass = { doc: this.currentDocument, treeAction: true }
|
2021-03-18 10:26:08 +13:00
|
|
|
|
|
|
|
this.dialogModel = false
|
|
|
|
this.SSET_setDialogState(false)
|
|
|
|
|
2021-04-27 01:01:51 +12:00
|
|
|
this.currentDocument = this.SGET_document(documentID)
|
|
|
|
|
2021-04-26 09:01:41 +12:00
|
|
|
// @ts-ignore
|
2021-03-05 01:51:11 +13:00
|
|
|
this.SSET_removeOpenedDocument(dataPass)
|
2021-04-26 09:01:41 +12:00
|
|
|
// @ts-ignore
|
2021-04-27 01:01:51 +12:00
|
|
|
this.SSET_removeDocument({ doc: this.currentDocument })
|
2021-03-05 01:51:11 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
.documentCloseDialog {
|
|
|
|
min-width: 600px;
|
|
|
|
}
|
|
|
|
</style>
|