From a1d6b5347f3bb195e69957df5b1a6b3cb4d5990a Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 21 Oct 2025 09:48:06 +0200 Subject: [PATCH] refactor(annotation): simplify mapSignature function to return a flat array Reworked mapSignature to return a single flattened array combining formFields, frames, and signatures instead of a nested object. This simplifies downstream processing and improves readability. --- EnvelopeGenerator.Web/wwwroot/js/annotation.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/EnvelopeGenerator.Web/wwwroot/js/annotation.js b/EnvelopeGenerator.Web/wwwroot/js/annotation.js index 5f3199d8..69837322 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/annotation.js +++ b/EnvelopeGenerator.Web/wwwroot/js/annotation.js @@ -317,8 +317,9 @@ function fixBase64(escapedBase64) { } function mapSignature(iJSON) { - return { - formFields: iJSON.formFieldValues.filter(field => !field.name.includes("label")).map((field) => { + return [ + // formFields + ...iJSON.formFieldValues.filter(field => !field.name.includes("label")).map((field) => { const nameParts = field.name.split('#'); return { elementId: Number(nameParts[2]), @@ -327,7 +328,9 @@ function mapSignature(iJSON) { type: field.type }; }), - frames: iJSON.annotations.filter(annot => annot.description === 'FRAME').map((annot) => { + + // frames + ...iJSON.annotations.filter(annot => annot.description === 'FRAME').map((annot) => { const preElement = findNearest(annot, e => e.bbox[0], e => e.bbox[1], ...iJSON.annotations.filter(field => field.id.includes("signature"))); const idPartsOfPre = preElement.id.split('#'); return { @@ -337,7 +340,9 @@ function mapSignature(iJSON) { type: annot.type }; }), - signatures: iJSON.annotations.filter(annot => annot.isSignature).map(annot => { + + // signatures + ...iJSON.annotations.filter(annot => annot.isSignature).map(annot => { const preElement = findNearest(annot, e => e.bbox[0], e => e.bbox[1], ...iJSON.annotations.filter(field => field.id.includes("signature"))); const idPartsOfPre = preElement.id.split('#'); @@ -359,5 +364,5 @@ function mapSignature(iJSON) { type: annot.type }; }) - }; + ]; } \ No newline at end of file