31-10-2023
This commit is contained in:
@@ -97,10 +97,11 @@ var App = /** @class */ (function () {
|
||||
};
|
||||
App.handleClick = function (eventType) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a;
|
||||
var result, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
result = false;
|
||||
_a = eventType;
|
||||
switch (_a) {
|
||||
case "RESET": return [3 /*break*/, 1];
|
||||
@@ -109,11 +110,24 @@ var App = /** @class */ (function () {
|
||||
return [3 /*break*/, 5];
|
||||
case 1: return [4 /*yield*/, App.handleReset(null)];
|
||||
case 2:
|
||||
_b.sent();
|
||||
result = _b.sent();
|
||||
if (result == true) {
|
||||
alert("Dokument zurückgesetzt!");
|
||||
}
|
||||
else {
|
||||
alert("Fehler beim Zurücksetzen des Dokuments!");
|
||||
}
|
||||
return [3 /*break*/, 5];
|
||||
case 3: return [4 /*yield*/, App.handleFinish(null)];
|
||||
case 4:
|
||||
_b.sent();
|
||||
result = _b.sent();
|
||||
if (result == true) {
|
||||
// TODO: Redirect to success page
|
||||
alert("Dokument erfolgreich signiert!");
|
||||
}
|
||||
else {
|
||||
alert("Fehler beim Abschließen des Dokuments!");
|
||||
}
|
||||
return [3 /*break*/, 5];
|
||||
case 5: return [2 /*return*/];
|
||||
}
|
||||
@@ -122,24 +136,52 @@ var App = /** @class */ (function () {
|
||||
};
|
||||
App.handleFinish = function (event) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var json, result;
|
||||
var e_2, json, postEnvelopeResult, e_3, buffer, postDocumentResult, e_4;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, App.Instance.save()];
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, App.Instance.save()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [4 /*yield*/, App.Instance.exportInstantJSON()];
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
json = _a.sent();
|
||||
console.log(json);
|
||||
console.log(JSON.stringify(json));
|
||||
return [4 /*yield*/, App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))];
|
||||
e_2 = _a.sent();
|
||||
console.error(e_2);
|
||||
return [2 /*return*/, false];
|
||||
case 3:
|
||||
result = _a.sent();
|
||||
if (result == true) {
|
||||
alert("Dokument erfolgreich signiert!");
|
||||
_a.trys.push([3, 6, , 7]);
|
||||
return [4 /*yield*/, App.Instance.exportInstantJSON()];
|
||||
case 4:
|
||||
json = _a.sent();
|
||||
return [4 /*yield*/, App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))];
|
||||
case 5:
|
||||
postEnvelopeResult = _a.sent();
|
||||
if (postEnvelopeResult === false) {
|
||||
return [2 /*return*/, false];
|
||||
}
|
||||
return [2 /*return*/];
|
||||
return [3 /*break*/, 7];
|
||||
case 6:
|
||||
e_3 = _a.sent();
|
||||
console.error(e_3);
|
||||
return [2 /*return*/, false];
|
||||
case 7:
|
||||
_a.trys.push([7, 10, , 11]);
|
||||
return [4 /*yield*/, App.Instance.exportPDF({ flatten: true })];
|
||||
case 8:
|
||||
buffer = _a.sent();
|
||||
return [4 /*yield*/, App.Network.postDocument(App.envelopeKey, App.currentDocument.id, buffer)];
|
||||
case 9:
|
||||
postDocumentResult = _a.sent();
|
||||
if (postDocumentResult === false) {
|
||||
return [2 /*return*/, false];
|
||||
}
|
||||
return [3 /*break*/, 11];
|
||||
case 10:
|
||||
e_4 = _a.sent();
|
||||
console.error(e_4);
|
||||
return [2 /*return*/, false];
|
||||
case 11: return [2 /*return*/, true];
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -148,8 +190,12 @@ var App = /** @class */ (function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var result;
|
||||
return __generator(this, function (_a) {
|
||||
if (confirm("Wollen Sie das Dokument und alle erstellten Signaturen zur<EFBFBD>cksetzen?")) {
|
||||
if (confirm("Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?")) {
|
||||
result = App.Annotation.deleteAnnotations(App.Instance);
|
||||
return [2 /*return*/, true];
|
||||
}
|
||||
else {
|
||||
return [2 /*return*/, true];
|
||||
}
|
||||
return [2 /*return*/];
|
||||
});
|
||||
@@ -272,16 +318,32 @@ var Network = /** @class */ (function () {
|
||||
.then(function (res) { return res.arrayBuffer(); });
|
||||
};
|
||||
Network.prototype.postDocument = function (envelopeKey, documentId, buffer) {
|
||||
return fetch("/api/document/".concat(envelopeKey, "/").concat(documentId), { credentials: "include", method: "POST", body: buffer })
|
||||
.then(function (res) { return res.json(); });
|
||||
var url = "/api/document/".concat(envelopeKey, "/").concat(documentId);
|
||||
var options = {
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
body: buffer
|
||||
};
|
||||
console.debug("PostDocument/Calling url: " + url);
|
||||
return fetch(url, options)
|
||||
.then(this.handleResponse)
|
||||
.then(function (res) {
|
||||
if (!res.ok) {
|
||||
return false;
|
||||
}
|
||||
;
|
||||
return true;
|
||||
});
|
||||
};
|
||||
Network.prototype.postEnvelope = function (envelopeKey, documentId, jsonString) {
|
||||
var url = "/api/envelope/".concat(envelopeKey, "?index=").concat(documentId);
|
||||
var options = {
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
body: jsonString
|
||||
};
|
||||
return fetch("/api/envelope/".concat(envelopeKey, "?index=").concat(documentId), options)
|
||||
console.debug("PostEnvelope/Calling url: " + url);
|
||||
return fetch(url, options)
|
||||
.then(this.handleResponse)
|
||||
.then(function (res) {
|
||||
if (!res.ok) {
|
||||
@@ -321,16 +383,18 @@ var UI = /** @class */ (function () {
|
||||
{
|
||||
type: "custom",
|
||||
id: "button-reset",
|
||||
title: "Zur<75>cksetzen",
|
||||
className: "button-reset",
|
||||
title: "Zurücksetzen",
|
||||
onPress: function () {
|
||||
callback("RESET");
|
||||
},
|
||||
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" fill=\"currentColor\" class=\"bi bi-arrow-counterclockwise\" viewBox=\"0 0 16 16\">\n <path fill-rule=\"evenodd\" d=\"M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z\"/>\n <path d=\"M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z\"/>\n </svg>"
|
||||
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" fill=\"currentColor\" class=\"bi bi-arrow-counterclockwise\" viewBox=\"0 0 16 16\">\n <path fill-rule=\"evenodd\" d=\"M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z\"/>\n <path d=\"M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z\"/>\n </svg>"
|
||||
},
|
||||
{
|
||||
type: "custom",
|
||||
id: "button-finish",
|
||||
title: "Abschlie<69>en",
|
||||
className: "button-finish",
|
||||
title: "Abschließen",
|
||||
onPress: function () {
|
||||
callback("FINISH");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user