Compare commits
6 Commits
42870b973d
...
3f116ce11a
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f116ce11a | |||
| 41738bb36c | |||
| 320b2ecc77 | |||
| b02cc3d7a4 | |||
| 14f2d9b6af | |||
| df74267616 |
@@ -563,6 +563,10 @@
|
|||||||
<Project>{63e32615-0eca-42dc-96e3-91037324b7c7}</Project>
|
<Project>{63e32615-0eca-42dc-96e3-91037324b7c7}</Project>
|
||||||
<Name>EnvelopeGenerator.Infrastructure</Name>
|
<Name>EnvelopeGenerator.Infrastructure</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\EnvelopeGenerator.PdfEditor\EnvelopeGenerator.PdfEditor.csproj">
|
||||||
|
<Project>{211619f5-ae25-4ba5-a552-bacafe0632d3}</Project>
|
||||||
|
<Name>EnvelopeGenerator.PdfEditor</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Imports DigitalData.Modules.Logging
|
|||||||
Imports GdPicture14
|
Imports GdPicture14
|
||||||
Imports Newtonsoft.Json
|
Imports Newtonsoft.Json
|
||||||
Imports EnvelopeGenerator.CommonServices.Jobs.FinalizeDocument.FinalizeDocumentExceptions
|
Imports EnvelopeGenerator.CommonServices.Jobs.FinalizeDocument.FinalizeDocumentExceptions
|
||||||
|
Imports DevExpress.DataProcessing
|
||||||
|
|
||||||
Namespace Jobs.FinalizeDocument
|
Namespace Jobs.FinalizeDocument
|
||||||
Public Class PDFBurner
|
Public Class PDFBurner
|
||||||
@@ -40,11 +41,13 @@ Namespace Jobs.FinalizeDocument
|
|||||||
|
|
||||||
' Add annotation to PDF
|
' Add annotation to PDF
|
||||||
For Each oJSON In pInstantJSONList
|
For Each oJSON In pInstantJSONList
|
||||||
If AddInstantJSONAnnotationToPDF(oJSON) = False Then
|
Try
|
||||||
|
AddInstantJSONAnnotationToPDF(oJSON)
|
||||||
|
Catch ex As Exception
|
||||||
Logger.Warn($"Error in AddInstantJSONAnnotationToPDF - oJson: ")
|
Logger.Warn($"Error in AddInstantJSONAnnotationToPDF - oJson: ")
|
||||||
Logger.Warn(oJSON)
|
Logger.Warn(oJSON)
|
||||||
Throw New BurnAnnotationException($"Adding Annotation failed")
|
Throw New BurnAnnotationException($"Adding Annotation failed", ex)
|
||||||
End If
|
End Try
|
||||||
Next
|
Next
|
||||||
oResult = Manager.BurnAnnotationsToPage(RemoveInitialAnnots:=True, VectorMode:=True)
|
oResult = Manager.BurnAnnotationsToPage(RemoveInitialAnnots:=True, VectorMode:=True)
|
||||||
If oResult <> GdPictureStatus.OK Then
|
If oResult <> GdPictureStatus.OK Then
|
||||||
@@ -65,12 +68,10 @@ Namespace Jobs.FinalizeDocument
|
|||||||
End Using
|
End Using
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function AddInstantJSONAnnotationToPDF(pInstantJSON As String) As Boolean
|
Private Sub AddInstantJSONAnnotationToPDF(pInstantJSON As String)
|
||||||
Try
|
|
||||||
Dim oAnnotationData = JsonConvert.DeserializeObject(Of AnnotationData)(pInstantJSON)
|
Dim oAnnotationData = JsonConvert.DeserializeObject(Of AnnotationData)(pInstantJSON)
|
||||||
oAnnotationData.annotations.Reverse()
|
oAnnotationData.annotations.Reverse()
|
||||||
|
|
||||||
Dim sigAnnotType = oAnnotationData.annotations.ElementAt(1).type
|
|
||||||
Dim yPosOfSigAnnot = oAnnotationData.annotations.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7
|
Dim yPosOfSigAnnot = oAnnotationData.annotations.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7
|
||||||
Dim isSeal = True 'First element is signature seal
|
Dim isSeal = True 'First element is signature seal
|
||||||
|
|
||||||
@@ -86,9 +87,11 @@ Namespace Jobs.FinalizeDocument
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
AddImageAnnotation(oAnnotation, oAnnotationData.attachments)
|
AddImageAnnotation(oAnnotation, oAnnotationData.attachments)
|
||||||
|
Exit Select
|
||||||
|
|
||||||
Case ANNOTATION_TYPE_INK
|
Case ANNOTATION_TYPE_INK
|
||||||
AddInkAnnotation(oAnnotation)
|
AddInkAnnotation(oAnnotation)
|
||||||
|
Exit Select
|
||||||
|
|
||||||
Case ANNOTATION_TYPE_WIDGET
|
Case ANNOTATION_TYPE_WIDGET
|
||||||
'Add form field values
|
'Add form field values
|
||||||
@@ -97,21 +100,14 @@ Namespace Jobs.FinalizeDocument
|
|||||||
AddFormFieldValue(oAnnotation, formFieldValue, formFieldIndex)
|
AddFormFieldValue(oAnnotation, formFieldValue, formFieldIndex)
|
||||||
formFieldIndex += 1
|
formFieldIndex += 1
|
||||||
End If
|
End If
|
||||||
|
Exit Select
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
isSeal = False
|
isSeal = False
|
||||||
Next
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
Return True
|
Private Function AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment)) As Void
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Warn("Could not create annotation from InstantJSON")
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment), Optional yOffset As Double = 0) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oAttachment = pAttachments.Where(Function(a) a.Key = pAnnotation.imageAttachmentId).
|
Dim oAttachment = pAttachments.Where(Function(a) a.Key = pAnnotation.imageAttachmentId).
|
||||||
SingleOrDefault()
|
SingleOrDefault()
|
||||||
|
|
||||||
@@ -119,24 +115,15 @@ Namespace Jobs.FinalizeDocument
|
|||||||
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
|
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
|
||||||
|
|
||||||
Dim oX = oBounds.Item(0)
|
Dim oX = oBounds.Item(0)
|
||||||
Dim oY = oBounds.Item(1) + yOffset
|
Dim oY = oBounds.Item(1)
|
||||||
Dim oWidth = oBounds.Item(2)
|
Dim oWidth = oBounds.Item(2)
|
||||||
Dim oHeight = oBounds.Item(3)
|
Dim oHeight = oBounds.Item(3)
|
||||||
|
|
||||||
Manager.SelectPage(pAnnotation.pageIndex + 1)
|
Manager.SelectPage(pAnnotation.pageIndex + 1)
|
||||||
Manager.AddEmbeddedImageAnnotFromBase64(oAttachment.Value.binary, oX, oY, oWidth, oHeight)
|
Manager.AddEmbeddedImageAnnotFromBase64(oAttachment.Value.binary, oX, oY, oWidth, oHeight)
|
||||||
|
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Warn("Could not add image annotation!")
|
|
||||||
Logger.Error(ex)
|
|
||||||
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function AddInkAnnotation(pAnnotation As Annotation) As Boolean
|
Private Function AddInkAnnotation(pAnnotation As Annotation) As Void
|
||||||
Try
|
|
||||||
Dim oSegments = pAnnotation.lines.points
|
Dim oSegments = pAnnotation.lines.points
|
||||||
Dim oColor = ColorTranslator.FromHtml(pAnnotation.strokeColor)
|
Dim oColor = ColorTranslator.FromHtml(pAnnotation.strokeColor)
|
||||||
Manager.SelectPage(pAnnotation.pageIndex + 1)
|
Manager.SelectPage(pAnnotation.pageIndex + 1)
|
||||||
@@ -148,19 +135,9 @@ Namespace Jobs.FinalizeDocument
|
|||||||
|
|
||||||
Manager.AddFreeHandAnnot(oColor, oPoints)
|
Manager.AddFreeHandAnnot(oColor, oPoints)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Warn("Could not add image annotation!")
|
|
||||||
Logger.Error(ex)
|
|
||||||
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function AddFormFieldValue(pAnnotation As Annotation, formFieldValue As FormFieldValue, index As Integer) As Boolean
|
Private Function AddFormFieldValue(pAnnotation As Annotation, formFieldValue As FormFieldValue, index As Integer) As Void
|
||||||
Try
|
|
||||||
' Convert pixels to Inches
|
' Convert pixels to Inches
|
||||||
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
|
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
|
||||||
|
|
||||||
@@ -178,12 +155,6 @@ Namespace Jobs.FinalizeDocument
|
|||||||
ant.FontSize = _pdfBurnerParams.FontSize
|
ant.FontSize = _pdfBurnerParams.FontSize
|
||||||
ant.FontStyle = _pdfBurnerParams.FontStyle
|
ant.FontStyle = _pdfBurnerParams.FontStyle
|
||||||
Manager.SaveAnnotationsToPage()
|
Manager.SaveAnnotationsToPage()
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Warn("Could not add image annotation!")
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function ToPointF(pPoints As List(Of Single)) As PointF
|
Private Function ToPointF(pPoints As List(Of Single)) As PointF
|
||||||
@@ -201,6 +172,22 @@ Namespace Jobs.FinalizeDocument
|
|||||||
|
|
||||||
Friend Class AnnotationData
|
Friend Class AnnotationData
|
||||||
Public Property annotations As List(Of Annotation)
|
Public Property annotations As List(Of Annotation)
|
||||||
|
|
||||||
|
Public ReadOnly Property SignatureAnnotations As List(Of List(Of Annotation))
|
||||||
|
Get
|
||||||
|
Dim result As New List(Of List(Of Annotation))()
|
||||||
|
|
||||||
|
If annotations IsNot Nothing AndAlso annotations.Count > 0 Then
|
||||||
|
For i As Integer = 0 To annotations.Count - 1 Step 6
|
||||||
|
Dim group As List(Of Annotation) = annotations.Skip(i).Take(6).ToList()
|
||||||
|
result.Add(group)
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return result
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
Public Property attachments As Dictionary(Of String, Attachment)
|
Public Property attachments As Dictionary(Of String, Attachment)
|
||||||
Public Property formFieldValues As List(Of FormFieldValue)
|
Public Property formFieldValues As List(Of FormFieldValue)
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
async function createAnnotations(document, envelopeId, receiverId) {
|
||||||
async function createAnnotations(document) {
|
|
||||||
const signatures = [];
|
const signatures = [];
|
||||||
|
|
||||||
for (let element of document.elements) {
|
for (let element of document.elements) {
|
||||||
@@ -7,12 +6,18 @@ async function createAnnotations(document) {
|
|||||||
const page = element.page - 1
|
const page = element.page - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let elementIndex = 0;
|
||||||
|
|
||||||
|
function generateId(annotationType) {
|
||||||
|
return `${envelopeId}_${receiverId}_${elementIndex++}_${annotationType}`;
|
||||||
|
}
|
||||||
|
|
||||||
for (let element of document.elements) {
|
for (let element of document.elements) {
|
||||||
const annotParams = await getAnnotationParams(element.left, element.top);
|
const annotParams = await getAnnotationParams(element.left, element.top);
|
||||||
const page = element.page - 1
|
const page = element.page - 1
|
||||||
|
|
||||||
//#region signatures
|
//#region signatures
|
||||||
const id = PSPDFKit.generateInstantId()
|
const id = generateId('signature');
|
||||||
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: id,
|
id: id,
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
@@ -29,7 +34,7 @@ async function createAnnotations(document) {
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region position
|
//#region position
|
||||||
const id_position = PSPDFKit.generateInstantId()
|
const id_position = generateId('position');
|
||||||
const annotation_position = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_position = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: id_position,
|
id: id_position,
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
@@ -49,7 +54,7 @@ async function createAnnotations(document) {
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region city
|
//#region city
|
||||||
const id_city = PSPDFKit.generateInstantId()
|
const id_city = generateId('city');
|
||||||
const annotation_city = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_city = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: id_city,
|
id: id_city,
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
@@ -69,7 +74,7 @@ async function createAnnotations(document) {
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region date
|
//#region date
|
||||||
const id_date = PSPDFKit.generateInstantId()
|
const id_date = generateId('date');
|
||||||
const annotation_date = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_date = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: id_date,
|
id: id_date,
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
@@ -97,7 +102,7 @@ async function createAnnotations(document) {
|
|||||||
this.markFieldAsCity(formFieldCity);
|
this.markFieldAsCity(formFieldCity);
|
||||||
|
|
||||||
//#region date label
|
//#region date label
|
||||||
const id_date_label = PSPDFKit.generateInstantId()
|
const id_date_label = generateId('date_label');
|
||||||
const annotation_date_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_date_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: id_date_label,
|
id: id_date_label,
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
@@ -120,7 +125,7 @@ async function createAnnotations(document) {
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region city label
|
//#region city label
|
||||||
const id_city_label = PSPDFKit.generateInstantId()
|
const id_city_label = generateId('city_label');
|
||||||
const annotation_city_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_city_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: id_city_label,
|
id: id_city_label,
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
@@ -143,7 +148,7 @@ async function createAnnotations(document) {
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region position label
|
//#region position label
|
||||||
const id_position_label = PSPDFKit.generateInstantId()
|
const id_position_label = generateId('position_label');
|
||||||
const annotation_position_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
const annotation_position_label = new PSPDFKit.Annotations.WidgetAnnotation({
|
||||||
id: id_position_label,
|
id: id_position_label,
|
||||||
pageIndex: page,
|
pageIndex: page,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class App {
|
|||||||
|
|
||||||
// Load annotations into PSPDFKit
|
// Load annotations into PSPDFKit
|
||||||
try {
|
try {
|
||||||
let signatures = await createAnnotations(this.currentDocument);
|
let signatures = await createAnnotations(this.currentDocument, this.envelopeReceiver.envelopeId, this.envelopeReceiver.receiverId);
|
||||||
await this.pdfKit.create(signatures);
|
await this.pdfKit.create(signatures);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Error loading annotations:", e);
|
console.error("Error loading annotations:", e);
|
||||||
|
|||||||
2
EnvelopeGenerator.Web/wwwroot/js/app.min.js
vendored
2
EnvelopeGenerator.Web/wwwroot/js/app.min.js
vendored
@@ -1,3 +1,3 @@
|
|||||||
class App{constructor(n,t,i,r,u,f){this.container=f??`#${this.constructor.name.toLowerCase()}`;this.envelopeKey=n;this.pdfKit=null;this.currentDocument=t.envelope.documents[0];this.currentReceiver=t.receiver;this.signatureCount=t.envelope.documents[0].elements.length;this.envelopeReceiver=t;this.documentBytes=i;this.licenseKey=r;this.locale=u}async init(){this.pdfKit=await loadPSPDFKit(this.documentBytes,this.container,this.licenseKey,this.locale);addToolbarItems(this.pdfKit,this.handleClick.bind(this));this.pdfKit.addEventListener("annotations.load",this.handleAnnotationsLoad.bind(this));this.pdfKit.addEventListener("annotations.change",this.handleAnnotationsChange.bind(this));this.pdfKit.addEventListener("annotations.create",this.handleAnnotationsCreate.bind(this));this.pdfKit.addEventListener("annotations.willChange",()=>{Comp.ActPanel.Toggle()});try{let n=await createAnnotations(this.currentDocument);await this.pdfKit.create(n)}catch(n){console.error("Error loading annotations:",n)}[...document.getElementsByClassName("btn_refresh")].forEach(n=>n.addEventListener("click",()=>this.handleClick("RESET")));[...document.getElementsByClassName("btn_complete")].forEach(n=>n.addEventListener("click",()=>this.handleClick("FINISH")));[...document.getElementsByClassName("btn_reject")].forEach(n=>n.addEventListener("click",()=>this.handleClick("REJECT")))}handleAnnotationsLoad(n){n.toJS()}handleAnnotationsChange(){}async handleAnnotationsCreate(n){const t=n.toJS()[0],i=!!t.formFieldName,r=!!t.isSignature;if(i===!1&&r===!0){const r=t.boundingBox.left-20,u=t.boundingBox.top-20,n=150,i=75,f=new Date,e=await createAnnotationFrameBlob(this.envelopeReceiver.name,this.currentReceiver.signature,f,n,i),o=await fetch(e),s=await o.blob(),h=await this.pdfKit.createAttachment(s),c=createImageAnnotation(new PSPDFKit.Geometry.Rect({left:r,top:u,width:n,height:i}),t.pageIndex,h);this.pdfKit.create(c)}}async handleClick(n){let t=!1;switch(n){case"RESET":t=await this.handleReset(null);Comp.SignatureProgress.SignedCount=0;t.isConfirmed&&Swal.fire({title:"Erfolg",text:"Dokument wurde zurückgesetzt",icon:"info"});break;case"FINISH":t=await this.handleFinish(null);t==!0&&(window.location.href=`/Envelope/${this.envelopeKey}`);break;case"REJECT":Swal.fire({title:localized.rejection,html:`<div class="text-start fs-6 p-0 m-0">${localized.rejectionReasonQ}</div>`,icon:"question",input:"text",inputAttributes:{autocapitalize:"off"},showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:localized.complete,cancelButtonText:localized.back,showLoaderOnConfirm:!0,preConfirm:async n=>{try{return await rejectEnvelope(n)}catch(t){Swal.showValidationMessage(`
|
class App{constructor(n,t,i,r,u,f){this.container=f??`#${this.constructor.name.toLowerCase()}`;this.envelopeKey=n;this.pdfKit=null;this.currentDocument=t.envelope.documents[0];this.currentReceiver=t.receiver;this.signatureCount=t.envelope.documents[0].elements.length;this.envelopeReceiver=t;this.documentBytes=i;this.licenseKey=r;this.locale=u}async init(){this.pdfKit=await loadPSPDFKit(this.documentBytes,this.container,this.licenseKey,this.locale);addToolbarItems(this.pdfKit,this.handleClick.bind(this));this.pdfKit.addEventListener("annotations.load",this.handleAnnotationsLoad.bind(this));this.pdfKit.addEventListener("annotations.change",this.handleAnnotationsChange.bind(this));this.pdfKit.addEventListener("annotations.create",this.handleAnnotationsCreate.bind(this));this.pdfKit.addEventListener("annotations.willChange",()=>{Comp.ActPanel.Toggle()});try{let n=await createAnnotations(this.currentDocument,this.envelopeReceiver.envelopeId,this.envelopeReceiver.receiverId);await this.pdfKit.create(n)}catch(n){console.error("Error loading annotations:",n)}[...document.getElementsByClassName("btn_refresh")].forEach(n=>n.addEventListener("click",()=>this.handleClick("RESET")));[...document.getElementsByClassName("btn_complete")].forEach(n=>n.addEventListener("click",()=>this.handleClick("FINISH")));[...document.getElementsByClassName("btn_reject")].forEach(n=>n.addEventListener("click",()=>this.handleClick("REJECT")))}handleAnnotationsLoad(n){n.toJS()}handleAnnotationsChange(){}async handleAnnotationsCreate(n){const t=n.toJS()[0],i=!!t.formFieldName,r=!!t.isSignature;if(i===!1&&r===!0){const r=t.boundingBox.left-20,u=t.boundingBox.top-20,n=150,i=75,f=new Date,e=await createAnnotationFrameBlob(this.envelopeReceiver.name,this.currentReceiver.signature,f,n,i),o=await fetch(e),s=await o.blob(),h=await this.pdfKit.createAttachment(s),c=createImageAnnotation(new PSPDFKit.Geometry.Rect({left:r,top:u,width:n,height:i}),t.pageIndex,h);this.pdfKit.create(c)}}async handleClick(n){let t=!1;switch(n){case"RESET":t=await this.handleReset(null);Comp.SignatureProgress.SignedCount=0;t.isConfirmed&&Swal.fire({title:"Erfolg",text:"Dokument wurde zurückgesetzt",icon:"info"});break;case"FINISH":t=await this.handleFinish(null);t==!0&&(window.location.href=`/Envelope/${this.envelopeKey}`);break;case"REJECT":Swal.fire({title:localized.rejection,html:`<div class="text-start fs-6 p-0 m-0">${localized.rejectionReasonQ}</div>`,icon:"question",input:"text",inputAttributes:{autocapitalize:"off"},showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:localized.complete,cancelButtonText:localized.back,showLoaderOnConfirm:!0,preConfirm:async n=>{try{return await rejectEnvelope(n)}catch(t){Swal.showValidationMessage(`
|
||||||
Request failed: ${t}
|
Request failed: ${t}
|
||||||
`)}},allowOutsideClick:()=>!Swal.isLoading()}).then(n=>{if(n.isConfirmed){const t=n.value;t.ok?reload():Swal.showValidationMessage(`Request failed: ${t.message}`)}});break;case"COPY_URL":const n=window.location.href.replace(/\/readonly/gi,"");navigator.clipboard.writeText(n).then(function(){bsNotify("Kopiert",{alert_type:"success",delay:4,icon_name:"check_circle"})}).catch(function(){bsNotify("Unerwarteter Fehler",{alert_type:"danger",delay:4,icon_name:"error"})});break;case"SHARE":Comp.ShareBackdrop.show();break;case"LOGOUT":await logout()}}async handleFinish(){const n=await this.pdfKit.exportInstantJSON(),t=await n.formFieldValues,r=t.filter(n=>isFieldRequired(n)),u=r.some(n=>n.value===undefined||n.value===null||n.value==="");if(u)return Swal.fire({title:"Warnung",text:"Bitte füllen Sie alle Standortinformationen vollständig aus!",icon:"warning"}),!1;const f=new RegExp("^[a-zA-Z\\u0080-\\u024F]+(?:([\\ \\-\\']|(\\.\\ ))[a-zA-Z\\u0080-\\u024F]+)*$"),e=t.filter(n=>isCityField(n));for(var i of e)if(!IS_MOBILE_DEVICE&&!f.test(i.value))return Swal.fire({title:"Warnung",text:`Bitte überprüfen Sie die eingegebene Ortsangabe "${i.value}" auf korrekte Formatierung. Beispiele für richtige Formate sind: München, Île-de-France, Sauðárkrókur, San Francisco, St. Catharines usw.`,icon:"warning"}),!1;const o=await this.validateAnnotations(this.signatureCount);return o===!1?(Swal.fire({title:"Warnung",text:"Es wurden nicht alle Signaturfelder ausgefüllt!",icon:"warning"}),!1):Swal.fire({title:localized.confirmation,html:`<div class="text-start fs-6 p-0 m-0">${localized.sigAgree}</div>`,icon:"question",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:localized.finalize,cancelButtonText:localized.back}).then(async t=>{if(t.isConfirmed){try{await this.pdfKit.save()}catch(i){return Swal.fire({title:"Fehler",text:"Umschlag konnte nicht signiert werden!",icon:"error"}),!1}try{const t=await signEnvelope(await n);if(t.ok)return!0;if(t.status===403)return Swal.fire({title:"Warnung",text:"Umschlag ist nicht mehr verfügbar.",icon:"warning"}),!1;throw new Error;}catch(i){return Swal.fire({title:"Fehler",text:"Umschlag konnte nicht signiert werden!",icon:"error"}),!1}}else return!1})}async validateAnnotations(n){const t=await getAnnotations(this.pdfKit),i=t.map(n=>n.toJS()).filter(n=>n.isSignature);return n>i.length?!1:!0}async handleReset(){const n=await Swal.fire({title:"Sind sie sicher?",text:"Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?",icon:"question",showCancelButton:!0});if(n.isConfirmed){const n=await deleteAnnotations(this.pdfKit)}return n}}
|
`)}},allowOutsideClick:()=>!Swal.isLoading()}).then(n=>{if(n.isConfirmed){const t=n.value;t.ok?reload():Swal.showValidationMessage(`Request failed: ${t.message}`)}});break;case"COPY_URL":const n=window.location.href.replace(/\/readonly/gi,"");navigator.clipboard.writeText(n).then(function(){bsNotify("Kopiert",{alert_type:"success",delay:4,icon_name:"check_circle"})}).catch(function(){bsNotify("Unerwarteter Fehler",{alert_type:"danger",delay:4,icon_name:"error"})});break;case"SHARE":Comp.ShareBackdrop.show();break;case"LOGOUT":await logout()}}async handleFinish(){const n=await this.pdfKit.exportInstantJSON(),t=await n.formFieldValues,r=t.filter(n=>isFieldRequired(n)),u=r.some(n=>n.value===undefined||n.value===null||n.value==="");if(u)return Swal.fire({title:"Warnung",text:"Bitte füllen Sie alle Standortinformationen vollständig aus!",icon:"warning"}),!1;const f=new RegExp("^[a-zA-Z\\u0080-\\u024F]+(?:([\\ \\-\\']|(\\.\\ ))[a-zA-Z\\u0080-\\u024F]+)*$"),e=t.filter(n=>isCityField(n));for(var i of e)if(!IS_MOBILE_DEVICE&&!f.test(i.value))return Swal.fire({title:"Warnung",text:`Bitte überprüfen Sie die eingegebene Ortsangabe "${i.value}" auf korrekte Formatierung. Beispiele für richtige Formate sind: München, Île-de-France, Sauðárkrókur, San Francisco, St. Catharines usw.`,icon:"warning"}),!1;const o=await this.validateAnnotations(this.signatureCount);return o===!1?(Swal.fire({title:"Warnung",text:"Es wurden nicht alle Signaturfelder ausgefüllt!",icon:"warning"}),!1):Swal.fire({title:localized.confirmation,html:`<div class="text-start fs-6 p-0 m-0">${localized.sigAgree}</div>`,icon:"question",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:localized.finalize,cancelButtonText:localized.back}).then(async t=>{if(t.isConfirmed){try{await this.pdfKit.save()}catch(i){return Swal.fire({title:"Fehler",text:"Umschlag konnte nicht signiert werden!",icon:"error"}),!1}try{const t=await signEnvelope(await n);if(t.ok)return!0;if(t.status===403)return Swal.fire({title:"Warnung",text:"Umschlag ist nicht mehr verfügbar.",icon:"warning"}),!1;throw new Error;}catch(i){return Swal.fire({title:"Fehler",text:"Umschlag konnte nicht signiert werden!",icon:"error"}),!1}}else return!1})}async validateAnnotations(n){const t=await getAnnotations(this.pdfKit),i=t.map(n=>n.toJS()).filter(n=>n.isSignature);return n>i.length?!1:!0}async handleReset(){const n=await Swal.fire({title:"Sind sie sicher?",text:"Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?",icon:"question",showCancelButton:!0});if(n.isConfirmed){const n=await deleteAnnotations(this.pdfKit)}return n}}
|
||||||
Reference in New Issue
Block a user