format js
This commit is contained in:
parent
eb6d149333
commit
1e2083950f
@ -1,6 +1,6 @@
|
|||||||
const config = {
|
const config = {
|
||||||
trailingComma: "es5",
|
trailingComma: "es5",
|
||||||
tabWidth: 4,
|
tabWidth: 2,
|
||||||
semi: false,
|
semi: false,
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,8 +5,7 @@
|
|||||||
document.elements.forEach((element) => {
|
document.elements.forEach((element) => {
|
||||||
console.log('Creating annotation for element', element.id)
|
console.log('Creating annotation for element', element.id)
|
||||||
|
|
||||||
const [annotation, formField] =
|
const [annotation, formField] = this.createAnnotationFromElement(element)
|
||||||
this.createAnnotationFromElement(element)
|
|
||||||
annotations.push(annotation)
|
annotations.push(annotation)
|
||||||
annotations.push(formField)
|
annotations.push(formField)
|
||||||
})
|
})
|
||||||
@ -17,21 +16,17 @@
|
|||||||
async deleteAnnotations(instance) {
|
async deleteAnnotations(instance) {
|
||||||
let pageAnnotations = (
|
let pageAnnotations = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Array.from({ length: instance.totalPageCount }).map(
|
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
|
||||||
(_, pageIndex) => instance.getAnnotations(pageIndex)
|
instance.getAnnotations(pageIndex)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.flatMap((annotations) =>
|
.flatMap((annotations) =>
|
||||||
annotations.reduce(
|
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
|
||||||
(acc, annotation) => acc.concat(annotation),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.filter(
|
.filter(
|
||||||
(annotation) =>
|
(annotation) =>
|
||||||
!!annotation.isSignature ||
|
!!annotation.isSignature || annotation.description == 'FRAME'
|
||||||
annotation.description == 'FRAME'
|
|
||||||
)
|
)
|
||||||
//deleting all Annotations
|
//deleting all Annotations
|
||||||
return await instance.delete(pageAnnotations)
|
return await instance.delete(pageAnnotations)
|
||||||
@ -40,16 +35,13 @@
|
|||||||
async validateAnnotations(instance) {
|
async validateAnnotations(instance) {
|
||||||
let pageAnnotations = (
|
let pageAnnotations = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Array.from({ length: instance.totalPageCount }).map(
|
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
|
||||||
(_, pageIndex) => instance.getAnnotations(pageIndex)
|
instance.getAnnotations(pageIndex)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.flatMap((annotations) =>
|
.flatMap((annotations) =>
|
||||||
annotations.reduce(
|
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
|
||||||
(acc, annotation) => acc.concat(annotation),
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.map((annotation) => {
|
.map((annotation) => {
|
||||||
console.log(annotation.toJS())
|
console.log(annotation.toJS())
|
||||||
@ -89,7 +81,7 @@
|
|||||||
pageIndex: pageIndex,
|
pageIndex: pageIndex,
|
||||||
formFieldName: id,
|
formFieldName: id,
|
||||||
backgroundColor: PSPDFKit.Color.YELLOW,
|
backgroundColor: PSPDFKit.Color.YELLOW,
|
||||||
blendMode: "multiply",
|
blendMode: 'multiply',
|
||||||
boundingBox: new PSPDFKit.Geometry.Rect({
|
boundingBox: new PSPDFKit.Geometry.Rect({
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@ -112,7 +104,7 @@
|
|||||||
imageAttachmentId,
|
imageAttachmentId,
|
||||||
description: 'FRAME',
|
description: 'FRAME',
|
||||||
boundingBox: boundingBox,
|
boundingBox: boundingBox,
|
||||||
});
|
})
|
||||||
return frameAnnotation
|
return frameAnnotation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,9 +35,9 @@ class App {
|
|||||||
|
|
||||||
if (envelopeError) {
|
if (envelopeError) {
|
||||||
return Swal.fire({
|
return Swal.fire({
|
||||||
title: "Fehler",
|
title: 'Fehler',
|
||||||
text: "Umschlag konnte nicht geladen werden!",
|
text: 'Umschlag konnte nicht geladen werden!',
|
||||||
icon: "error"
|
icon: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,9 +55,9 @@ class App {
|
|||||||
if (documentError) {
|
if (documentError) {
|
||||||
console.error(documentResponse.error)
|
console.error(documentResponse.error)
|
||||||
return Swal.fire({
|
return Swal.fire({
|
||||||
title: "Fehler",
|
title: 'Fehler',
|
||||||
text: "Dokument konnte nicht geladen werden!",
|
text: 'Dokument konnte nicht geladen werden!',
|
||||||
icon: "error"
|
icon: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,9 +68,18 @@ class App {
|
|||||||
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
|
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
|
||||||
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))
|
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))
|
||||||
|
|
||||||
this.Instance.addEventListener('annotations.load', this.handleAnnotationsLoad.bind(this))
|
this.Instance.addEventListener(
|
||||||
this.Instance.addEventListener('annotations.change', this.handleAnnotationsChange.bind(this))
|
'annotations.load',
|
||||||
this.Instance.addEventListener('annotations.create', this.handleAnnotationsCreate.bind(this))
|
this.handleAnnotationsLoad.bind(this)
|
||||||
|
)
|
||||||
|
this.Instance.addEventListener(
|
||||||
|
'annotations.change',
|
||||||
|
this.handleAnnotationsChange.bind(this)
|
||||||
|
)
|
||||||
|
this.Instance.addEventListener(
|
||||||
|
'annotations.create',
|
||||||
|
this.handleAnnotationsCreate.bind(this)
|
||||||
|
)
|
||||||
|
|
||||||
// Load annotations into PSPDFKit
|
// Load annotations into PSPDFKit
|
||||||
console.debug('Loading annotations..')
|
console.debug('Loading annotations..')
|
||||||
@ -99,26 +108,33 @@ class App {
|
|||||||
const isSignature = !!annotation.isSignature
|
const isSignature = !!annotation.isSignature
|
||||||
|
|
||||||
if (isFormField === false && isSignature === true) {
|
if (isFormField === false && isSignature === true) {
|
||||||
|
const left = annotation.boundingBox.left - 25
|
||||||
|
const top = annotation.boundingBox.top - 25
|
||||||
|
const width = 150
|
||||||
|
const height = 75
|
||||||
|
|
||||||
const left = annotation.boundingBox.left - 25;
|
const imageUrl = await this.Annotation.createAnnotationFrameBlob(
|
||||||
const top = annotation.boundingBox.top - 25;
|
this.currentReceiver.name,
|
||||||
const width = 150;
|
width,
|
||||||
const height = 75;
|
height
|
||||||
|
)
|
||||||
|
|
||||||
const imageUrl = await this.Annotation.createAnnotationFrameBlob(this.currentReceiver.name, width, height);
|
const request = await fetch(imageUrl)
|
||||||
|
const blob = await request.blob()
|
||||||
|
const imageAttachmentId = await this.Instance.createAttachment(blob)
|
||||||
|
|
||||||
const request = await fetch(imageUrl);
|
const frameAnnotation = this.Annotation.createImageAnnotation(
|
||||||
const blob = await request.blob();
|
new PSPDFKit.Geometry.Rect({
|
||||||
const imageAttachmentId = await this.Instance.createAttachment(blob);
|
|
||||||
|
|
||||||
const frameAnnotation = this.Annotation.createImageAnnotation(new PSPDFKit.Geometry.Rect({
|
|
||||||
left: left,
|
left: left,
|
||||||
top: top,
|
top: top,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
}), annotation.pageIndex, imageAttachmentId)
|
}),
|
||||||
|
annotation.pageIndex,
|
||||||
|
imageAttachmentId
|
||||||
|
)
|
||||||
|
|
||||||
this.Instance.create(frameAnnotation);
|
this.Instance.create(frameAnnotation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,15 +147,15 @@ class App {
|
|||||||
|
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: "Erfolg",
|
title: 'Erfolg',
|
||||||
text: "Dokument wurde zurückgesetzt",
|
text: 'Dokument wurde zurückgesetzt',
|
||||||
icon: "info"
|
icon: 'info',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: "Fehler",
|
title: 'Fehler',
|
||||||
text: "Dokument konnte nicht zurückgesetzt werden!",
|
text: 'Dokument konnte nicht zurückgesetzt werden!',
|
||||||
icon: "error"
|
icon: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,9 +211,9 @@ class App {
|
|||||||
|
|
||||||
async handleReset(event) {
|
async handleReset(event) {
|
||||||
const result = await Swal.fire({
|
const result = await Swal.fire({
|
||||||
title: "Sind sie sicher?",
|
title: 'Sind sie sicher?',
|
||||||
text: "Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?",
|
text: 'Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?',
|
||||||
icon: "question"
|
icon: 'question',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
class Network {
|
class Network {
|
||||||
|
|
||||||
getEnvelope(envelopeKey) {
|
getEnvelope(envelopeKey) {
|
||||||
return fetch(`/api/envelope/${envelopeKey}`, this.withCSRFToken({ credentials: 'include' }))
|
return fetch(
|
||||||
.then(this.wrapJsonResponse.bind(this))
|
`/api/envelope/${envelopeKey}`,
|
||||||
|
this.withCSRFToken({ credentials: 'include' })
|
||||||
|
).then(this.wrapJsonResponse.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocument(envelopeKey, documentId) {
|
getDocument(envelopeKey, documentId) {
|
||||||
return fetch(`/api/document/${envelopeKey}?index=${documentId}`, this.withCSRFToken({ credentials: 'include' }))
|
return fetch(
|
||||||
.then(this.wrapBinaryResponse.bind(this))
|
`/api/document/${envelopeKey}?index=${documentId}`,
|
||||||
|
this.withCSRFToken({ credentials: 'include' })
|
||||||
|
).then(this.wrapBinaryResponse.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
postEnvelope(envelopeKey, documentId, jsonString) {
|
postEnvelope(envelopeKey, documentId, jsonString) {
|
||||||
@ -57,9 +60,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
withCSRFToken(options) {
|
withCSRFToken(options) {
|
||||||
const token = document.getElementsByName(
|
const token = document.getElementsByName('__RequestVerificationToken')[0]
|
||||||
'__RequestVerificationToken'
|
.value
|
||||||
)[0].value
|
|
||||||
let headers = options.headers
|
let headers = options.headers
|
||||||
options.headers = { ...headers, 'X-XSRF-TOKEN': token }
|
options.headers = { ...headers, 'X-XSRF-TOKEN': token }
|
||||||
|
|
||||||
@ -71,7 +73,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async wrapBinaryResponse(response) {
|
async wrapBinaryResponse(response) {
|
||||||
return await this.wrapResponse(response, async (res) => await res.arrayBuffer())
|
return await this.wrapResponse(
|
||||||
|
response,
|
||||||
|
async (res) => await res.arrayBuffer()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async wrapResponse(response, responseHandler) {
|
async wrapResponse(response, responseHandler) {
|
||||||
|
|||||||
@ -29,10 +29,7 @@
|
|||||||
isEditableAnnotation: function (annotation) {
|
isEditableAnnotation: function (annotation) {
|
||||||
// Check if the annotation is a signature
|
// Check if the annotation is a signature
|
||||||
// This will allow new signatures, but not allow edits.
|
// This will allow new signatures, but not allow edits.
|
||||||
if (
|
if (annotation.isSignature || annotation.description == 'FRAME') {
|
||||||
annotation.isSignature ||
|
|
||||||
annotation.description == 'FRAME'
|
|
||||||
) {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +38,8 @@
|
|||||||
//return !annotation.isSignature;
|
//return !annotation.isSignature;
|
||||||
},
|
},
|
||||||
customRenderers: {
|
customRenderers: {
|
||||||
Annotation: this.annotationRenderer
|
Annotation: this.annotationRenderer,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +95,7 @@
|
|||||||
},
|
},
|
||||||
icon: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-hand-thumbs-down" viewBox="0 0 16 16">
|
icon: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-hand-thumbs-down" viewBox="0 0 16 16">
|
||||||
<path d="M8.864 15.674c-.956.24-1.843-.484-1.908-1.42-.072-1.05-.23-2.015-.428-2.59-.125-.36-.479-1.012-1.04-1.638-.557-.624-1.282-1.179-2.131-1.41C2.685 8.432 2 7.85 2 7V3c0-.845.682-1.464 1.448-1.546 1.07-.113 1.564-.415 2.068-.723l.048-.029c.272-.166.578-.349.97-.484C6.931.08 7.395 0 8 0h3.5c.937 0 1.599.478 1.934 1.064.164.287.254.607.254.913 0 .152-.023.312-.077.464.201.262.38.577.488.9.11.33.172.762.004 1.15.069.13.12.268.159.403.077.27.113.567.113.856 0 .289-.036.586-.113.856-.035.12-.08.244-.138.363.394.571.418 1.2.234 1.733-.206.592-.682 1.1-1.2 1.272-.847.283-1.803.276-2.516.211a9.877 9.877 0 0 1-.443-.05 9.364 9.364 0 0 1-.062 4.51c-.138.508-.55.848-1.012.964zM11.5 1H8c-.51 0-.863.068-1.14.163-.281.097-.506.229-.776.393l-.04.025c-.555.338-1.198.73-2.49.868-.333.035-.554.29-.554.55V7c0 .255.226.543.62.65 1.095.3 1.977.997 2.614 1.709.635.71 1.064 1.475 1.238 1.977.243.7.407 1.768.482 2.85.025.362.36.595.667.518l.262-.065c.16-.04.258-.144.288-.255a8.34 8.34 0 0 0-.145-4.726.5.5 0 0 1 .595-.643h.003l.014.004.058.013a8.912 8.912 0 0 0 1.036.157c.663.06 1.457.054 2.11-.163.175-.059.45-.301.57-.651.107-.308.087-.67-.266-1.021L12.793 7l.353-.354c.043-.042.105-.14.154-.315.048-.167.075-.37.075-.581 0-.211-.027-.414-.075-.581-.05-.174-.111-.273-.154-.315l-.353-.354.353-.354c.047-.047.109-.176.005-.488a2.224 2.224 0 0 0-.505-.804l-.353-.354.353-.354c.006-.005.041-.05.041-.17a.866.866 0 0 0-.121-.415C12.4 1.272 12.063 1 11.5 1"/>
|
<path d="M8.864 15.674c-.956.24-1.843-.484-1.908-1.42-.072-1.05-.23-2.015-.428-2.59-.125-.36-.479-1.012-1.04-1.638-.557-.624-1.282-1.179-2.131-1.41C2.685 8.432 2 7.85 2 7V3c0-.845.682-1.464 1.448-1.546 1.07-.113 1.564-.415 2.068-.723l.048-.029c.272-.166.578-.349.97-.484C6.931.08 7.395 0 8 0h3.5c.937 0 1.599.478 1.934 1.064.164.287.254.607.254.913 0 .152-.023.312-.077.464.201.262.38.577.488.9.11.33.172.762.004 1.15.069.13.12.268.159.403.077.27.113.567.113.856 0 .289-.036.586-.113.856-.035.12-.08.244-.138.363.394.571.418 1.2.234 1.733-.206.592-.682 1.1-1.2 1.272-.847.283-1.803.276-2.516.211a9.877 9.877 0 0 1-.443-.05 9.364 9.364 0 0 1-.062 4.51c-.138.508-.55.848-1.012.964zM11.5 1H8c-.51 0-.863.068-1.14.163-.281.097-.506.229-.776.393l-.04.025c-.555.338-1.198.73-2.49.868-.333.035-.554.29-.554.55V7c0 .255.226.543.62.65 1.095.3 1.977.997 2.614 1.709.635.71 1.064 1.475 1.238 1.977.243.7.407 1.768.482 2.85.025.362.36.595.667.518l.262-.065c.16-.04.258-.144.288-.255a8.34 8.34 0 0 0-.145-4.726.5.5 0 0 1 .595-.643h.003l.014.004.058.013a8.912 8.912 0 0 0 1.036.157c.663.06 1.457.054 2.11-.163.175-.059.45-.301.57-.651.107-.308.087-.67-.266-1.021L12.793 7l.353-.354c.043-.042.105-.14.154-.315.048-.167.075-.37.075-.581 0-.211-.027-.414-.075-.581-.05-.174-.111-.273-.154-.315l-.353-.354.353-.354c.047-.047.109-.176.005-.488a2.224 2.224 0 0 0-.505-.804l-.353-.354.353-.354c.006-.005.041-.05.041-.17a.866.866 0 0 0-.121-.415C12.4 1.272 12.063 1 11.5 1"/>
|
||||||
</svg>`
|
</svg>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
@ -114,9 +111,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
getDefaultItems(items) {
|
getDefaultItems(items) {
|
||||||
return items.filter((item) =>
|
return items.filter((item) => this.allowedToolbarItems.includes(item.type))
|
||||||
this.allowedToolbarItems.includes(item.type)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPresets() {
|
getPresets() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user