Support READ_AND_CONFIRM flow in handleFinish

Add logic to require all pages viewed before allowing finish when READ_AND_CONFIRM is enabled. Skip annotation and form field validations in this mode. Show warnings for unviewed pages and handle errors for save/sign actions. Update minified app to match new flow.
This commit is contained in:
2026-01-20 11:44:40 +01:00
parent 383634fca6
commit ca248c3aa6
2 changed files with 85 additions and 2 deletions

View File

@@ -185,6 +185,88 @@ class App {
}
async handleFinish(event) {
// READ_AND_CONFIRM flow: require all pages viewed, skip annotation validations
if (READ_AND_CONFIRM) {
const allViewed = JSON.parse(sessionStorage.getItem('pspdf_all_pages_rendered') || 'false') === true
if (!allViewed) {
const unviewed = JSON.parse(sessionStorage.getItem('pspdf_unviewed_pages') || '[]')
const message = unviewed.length
? `Bitte sehen Sie sich die folgenden Seiten an: ${unviewed.join(', ')}`
: 'Bitte sehen Sie sich alle Seiten an.'
await Swal.fire({
title: 'Warnung',
text: message,
icon: 'warning'
})
return false
}
return Swal.fire({
title: localized.confirmation,
html: `<div class="text-start fs-6 p-0 m-0">${localized.sigAgree}</div>`,
icon: "question",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: localized.finalize,
cancelButtonText: localized.back
}).then(async (result) => {
if (!result.isConfirmed)
return false
try {
await this.pdfKit.save()
} catch (e) {
Swal.fire({
title: 'Fehler',
text: 'Umschlag konnte nicht signiert werden!',
icon: 'error',
})
return false
}
try {
const iJSON = await this.pdfKit.exportInstantJSON()
const res = await signEnvelope({
instant: iJSON,
structured: mapSignature(iJSON)
})
if (!res.ok) {
if (res.status === 409) {
Swal.fire({
title: 'Warnung',
text: 'Umschlag ist nicht mehr verfügbar.',
icon: 'warning',
})
return false
} else if (res.status === 423) {
Swal.fire({
title: 'Info',
text: 'Dokument wurde von einem Empfänger abgelehnt. Sie werden weitergeleitet...',
icon: 'info',
timer: 2000,
showConfirmButton: false
}).then(() => {
location.reload()
})
} else {
throw new Error()
}
} else
return true
} catch (e) {
Swal.fire({
title: 'Fehler',
text: 'Umschlag konnte nicht signiert werden!',
icon: 'error',
})
return false
}
})
}
const iJSON = await this.pdfKit.exportInstantJSON()
const iFormFieldValues = iJSON.formFieldValues;
@@ -228,7 +310,8 @@ class App {
return Swal.fire({
title: localized.confirmation,
html: `<div class="text-start fs-6 p-0 m-0">${localized.sigAgree}</div>`,
html: `<div class="text-start fs-6 p-0 m-0">${localized.sigAgree}</div>`
,
icon: "question",
showCancelButton: true,
confirmButtonColor: "#3085d6",