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:
parent
f94728bf67
commit
14bd2e22fc
@ -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)
|
||||
}
|
||||
}
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user