diff --git a/EnvelopeGenerator.Web/wwwroot/js/annotation.js b/EnvelopeGenerator.Web/wwwroot/js/annotation.js index cd8c7ebe..555e9073 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/annotation.js +++ b/EnvelopeGenerator.Web/wwwroot/js/annotation.js @@ -106,6 +106,8 @@ readOnly: isMobile() }) + this.markFieldAsRequired(formFieldCity); + /** * Date, post code and place label part */ @@ -162,7 +164,7 @@ annotationIds: PSPDFKit.Immutable.List([annotation_city_label.id]), value: "Ort", readOnly: true - }) + }) return [annotation, formField, annotation_date, formFieldDate, annotation_city, formFieldCity, annotation_date_label, formFieldDateLabel, annotation_city_label, formFieldCityLabel] } @@ -304,4 +306,14 @@ static inchToPoint(inch) { return inch * 72 } -} + + static #requiredFieldNames = new Array() + + static markFieldAsRequired(formField) { + this.#requiredFieldNames.push(formField.name) + } + + static isFieldRequired(formField) { + return this.#requiredFieldNames.includes(formField.name) + } +} \ No newline at end of file diff --git a/EnvelopeGenerator.Web/wwwroot/js/app.js b/EnvelopeGenerator.Web/wwwroot/js/app.js index 2d1caece..a2c6ae9d 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/app.js +++ b/EnvelopeGenerator.Web/wwwroot/js/app.js @@ -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,