feat: Developed markFieldAsRequired and isFieldRequired methods to mark and validate required form fields; added user alert if location information is not provided.

This commit is contained in:
Developer 02
2024-07-17 15:52:04 +02:00
parent f94728bf67
commit 14bd2e22fc
2 changed files with 30 additions and 4 deletions

View File

@@ -65,7 +65,7 @@ class App {
this.Instance.addEventListener("annotations.willChange", _ => {
Comp.ActPanel.Toggle();
});
});
// Load annotations into PSPDFKit
try {
@@ -168,6 +168,20 @@ class App {
}
async handleFinish(event) {
const iJSON = await this.Instance.exportInstantJSON()
const iFormFieldValues = await iJSON.formFieldValues;
const iReqFields = iFormFieldValues.filter(f => Annotation.isFieldRequired(f))
const hasEmptyReq = iReqFields.some(f => (f.value === undefined || f.value === null || f.value === ""))
if (hasEmptyReq){
Swal.fire({
title: 'Warnung',
text: 'Bitte füllen Sie alle Standortinformationen vollständig aus!',
icon: 'warning',
})
return false;
}
const validationResult = await this.validateAnnotations(this.signatureCount)
if (validationResult === false) {
Swal.fire({
@@ -204,7 +218,7 @@ class App {
// Export annotation data and save to database
try {
const json = await this.Instance.exportInstantJSON()
const json = await iJSON
const postEnvelopeResult = await this.Network.postEnvelope(
this.envelopeKey,
this.currentDocument.id,