validation client and server

This commit is contained in:
Jonathan Jenne
2023-12-15 10:45:32 +01:00
parent 0ad1d214ba
commit bdf7bdd37a
7 changed files with 269 additions and 127 deletions

View File

@@ -3,7 +3,7 @@
const annotations = []
document.elements.forEach((element) => {
console.log('Creating annotation for element', element.id)
console.debug('Creating annotation for element', element.id)
const [annotation, formField] = this.createAnnotationFromElement(element)
annotations.push(annotation)
@@ -13,17 +13,20 @@
return annotations
}
async deleteAnnotations(instance) {
let pageAnnotations = (
await Promise.all(
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
instance.getAnnotations(pageIndex)
)
async getAnnotations(instance) {
const array = await Promise.all(
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
instance.getAnnotations(pageIndex)
)
)
.flatMap((annotations) =>
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
)
return array.flatMap((annotations) =>
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
)
}
async deleteAnnotations(instance) {
let pageAnnotations = this.getAnnotations(instance)
.filter(
(annotation) =>
!!annotation.isSignature || annotation.description == 'FRAME'
@@ -33,16 +36,7 @@
}
async validateAnnotations(instance) {
let pageAnnotations = (
await Promise.all(
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
instance.getAnnotations(pageIndex)
)
)
)
.flatMap((annotations) =>
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
)
let pageAnnotations = this.getAnnotations(instance)
.map((annotation) => {
console.log(annotation.toJS())
return annotation