This commit is contained in:
Jonathan Jenne
2023-11-27 16:36:23 +01:00
parent e52eca809e
commit 38577f66e0
8 changed files with 99 additions and 53 deletions

View File

@@ -30,41 +30,47 @@ class App {
async init() {
// Load the envelope from the database
console.debug('Loading envelope from database..')
const envelopeObject = await this.Network.getEnvelope(this.envelopeKey)
this.currentDocument = envelopeObject.envelope.documents[0]
this.currentReceiver = envelopeObject.receiver
const envelopeResponse = await this.Network.getEnvelope(this.envelopeKey)
const envelopeError = !!envelopeResponse.error
console.log(envelopeObject)
if (envelopeError) {
return Swal.fire({
title: "Fehler",
text: "Umschlag konnte nicht geladen werden!",
icon: "error"
})
}
this.currentDocument = envelopeResponse.data.envelope.documents[0]
this.currentReceiver = envelopeResponse.data.receiver
// Load the document from the filestore
console.debug('Loading document from filestore')
let arrayBuffer
try {
arrayBuffer = await this.Network.getDocument(
this.envelopeKey,
this.currentDocument.id
)
} catch (e) {
console.error(e)
const documentResponse = await this.Network.getDocument(
this.envelopeKey,
this.currentDocument.id
)
const documentError = !!documentResponse.error
if (documentError) {
console.error(documentResponse.error)
return Swal.fire({
title: "Fehler",
text: "Dokument konnte nicht geladen werden!",
icon: "error"
})
}
const arrayBuffer = documentResponse.data
// Load PSPDFKit
console.debug('Loading PSPDFKit..')
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))
this.Instance.addEventListener(
'annotations.load',
this.handleAnnotationsLoad
)
this.Instance.addEventListener(
'annotations.change',
this.handleAnnotationsChange
)
this.Instance.addEventListener(
'annotations.create',
this.handleAnnotationsCreate.bind(this)
)
this.Instance.addEventListener('annotations.load', this.handleAnnotationsLoad)
this.Instance.addEventListener('annotations.change', this.handleAnnotationsChange)
this.Instance.addEventListener('annotations.create', this.handleAnnotationsCreate.bind(this))
// Load annotations into PSPDFKit
console.debug('Loading annotations..')
@@ -124,9 +130,17 @@ class App {
result = await this.handleReset(null)
if (result == true) {
alert('Dokument zurückgesetzt!')
Swal.fire({
title: "Erfolg",
text: "Dokument wurde zurückgesetzt",
icon: "info"
})
} else {
alert('Fehler beim Zurücksetzen des Dokuments!')
Swal.fire({
title: "Fehler",
text: "Dokument konnte nicht zurückgesetzt werden!",
icon: "error"
})
}
break
@@ -180,15 +194,21 @@ class App {
}
async handleReset(event) {
if (
confirm(
'Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?'
)
) {
const result = await Swal.fire({
title: "Sind sie sicher?",
text: "Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?",
icon: "question"
})
if (result.isConfirmed) {
const result = this.Annotation.deleteAnnotations(this.Instance)
return true
} else {
}
if (result.isDimissed) {
return true
}
return false
}
}