@colijnit/sharedcomponents 258.1.11 → 258.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/colijnit-sharedcomponents.umd.js +77 -46
- package/bundles/colijnit-sharedcomponents.umd.js.map +1 -1
- package/colijnit-sharedcomponents.metadata.json +1 -1
- package/esm2015/lib/components/custom-pdf/custom-pdf-dialog.component.js +55 -47
- package/esm2015/lib/components/custom-pdf/custom-pdf-dialog.module.js +3 -2
- package/fesm2015/colijnit-sharedcomponents.js +56 -47
- package/fesm2015/colijnit-sharedcomponents.js.map +1 -1
- package/lib/components/custom-pdf/custom-pdf-dialog.component.d.ts +1 -0
- package/lib/components/custom-pdf/style/_layout.scss +12 -0
- package/package.json +1 -1
|
@@ -3750,6 +3750,7 @@
|
|
|
3750
3750
|
this.additionalFileChangeEvent = new i0.EventEmitter();
|
|
3751
3751
|
this.signaturePads = {};
|
|
3752
3752
|
this.signatureCanvases = {};
|
|
3753
|
+
this.showLoader = false;
|
|
3753
3754
|
}
|
|
3754
3755
|
CustomPdfDialogComponent.prototype.showClass = function () {
|
|
3755
3756
|
return true;
|
|
@@ -3833,54 +3834,83 @@
|
|
|
3833
3834
|
};
|
|
3834
3835
|
CustomPdfDialogComponent.prototype.handleSaveClicked = function () {
|
|
3835
3836
|
return __awaiter(this, void 0, void 0, function () {
|
|
3836
|
-
var clearButton, doc, htmlDocument, documentSection, sectionsCount, _loop_1, i;
|
|
3837
|
-
var _this = this;
|
|
3837
|
+
var clearButton, doc, htmlDocument, documentSection, sectionsCount, _loop_1, i, tempFile, file, fileAsCoDocument;
|
|
3838
3838
|
return __generator(this, function (_a) {
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3839
|
+
switch (_a.label) {
|
|
3840
|
+
case 0:
|
|
3841
|
+
this.showLoader = true;
|
|
3842
|
+
clearButton = document.getElementById('clearButton');
|
|
3843
|
+
clearButton.hidden = true;
|
|
3844
|
+
doc = new jspdf.jsPDF();
|
|
3845
|
+
htmlDocument = document.querySelector("#pdfBody");
|
|
3846
|
+
documentSection = htmlDocument.getElementsByTagName('section');
|
|
3847
|
+
sectionsCount = documentSection.length;
|
|
3848
|
+
_loop_1 = function (i) {
|
|
3849
|
+
var html, dataUrl_1, img_1, error_1;
|
|
3850
|
+
return __generator(this, function (_b) {
|
|
3851
|
+
switch (_b.label) {
|
|
3852
|
+
case 0:
|
|
3853
|
+
html = documentSection[i];
|
|
3854
|
+
_b.label = 1;
|
|
3855
|
+
case 1:
|
|
3856
|
+
_b.trys.push([1, 4, , 5]);
|
|
3857
|
+
return [4 /*yield*/, htmlToImage.toJpeg(html, {
|
|
3858
|
+
quality: 1,
|
|
3859
|
+
backgroundColor: 'white'
|
|
3860
|
+
})];
|
|
3861
|
+
case 2:
|
|
3862
|
+
dataUrl_1 = _b.sent();
|
|
3863
|
+
img_1 = new Image();
|
|
3864
|
+
img_1.src = dataUrl_1;
|
|
3865
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
3866
|
+
img_1.onload = function () {
|
|
3867
|
+
var imgWidth = 218;
|
|
3868
|
+
var imgHeight = (img_1.height * imgWidth) / img_1.width;
|
|
3869
|
+
doc.addImage(dataUrl_1, 'JPG', -4, 0, imgWidth, imgHeight);
|
|
3870
|
+
if (i < sectionsCount - 1) {
|
|
3871
|
+
doc.addPage();
|
|
3872
|
+
}
|
|
3873
|
+
resolve();
|
|
3874
|
+
};
|
|
3875
|
+
})];
|
|
3876
|
+
case 3:
|
|
3877
|
+
_b.sent();
|
|
3878
|
+
return [3 /*break*/, 5];
|
|
3879
|
+
case 4:
|
|
3880
|
+
error_1 = _b.sent();
|
|
3881
|
+
console.error('Error generating image:', error_1);
|
|
3882
|
+
return [3 /*break*/, 5];
|
|
3883
|
+
case 5: return [2 /*return*/];
|
|
3884
|
+
}
|
|
3885
|
+
});
|
|
3874
3886
|
};
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3887
|
+
i = 0;
|
|
3888
|
+
_a.label = 1;
|
|
3889
|
+
case 1:
|
|
3890
|
+
if (!(i < sectionsCount)) return [3 /*break*/, 4];
|
|
3891
|
+
return [5 /*yield**/, _loop_1(i)];
|
|
3892
|
+
case 2:
|
|
3893
|
+
_a.sent();
|
|
3894
|
+
_a.label = 3;
|
|
3895
|
+
case 3:
|
|
3896
|
+
i++;
|
|
3897
|
+
return [3 /*break*/, 1];
|
|
3898
|
+
case 4:
|
|
3899
|
+
tempFile = doc.output('datauristring');
|
|
3900
|
+
file = this.dataURItoBlob(tempFile);
|
|
3901
|
+
return [4 /*yield*/, fileUtils.FileUtils.ReadFileAsNewCoDocument(file)];
|
|
3902
|
+
case 5:
|
|
3903
|
+
fileAsCoDocument = _a.sent();
|
|
3904
|
+
fileAsCoDocument.fileType = fileUtils.FileUtils.IsImageFile(file) ? fileType_enum.FileType.Image : fileType_enum.FileType.Document;
|
|
3905
|
+
fileAsCoDocument.creationDate = new Date();
|
|
3906
|
+
fileAsCoDocument.modifiedDate = new Date();
|
|
3907
|
+
fileAsCoDocument.reports = 1;
|
|
3908
|
+
this.additionalFileChangeEvent.emit(fileAsCoDocument);
|
|
3909
|
+
this.showLoader = false;
|
|
3910
|
+
this.closePDFDialog.emit();
|
|
3911
|
+
clearButton.hidden = false;
|
|
3912
|
+
return [2 /*return*/];
|
|
3881
3913
|
}
|
|
3882
|
-
clearButton.hidden = false;
|
|
3883
|
-
return [2 /*return*/];
|
|
3884
3914
|
});
|
|
3885
3915
|
});
|
|
3886
3916
|
};
|
|
@@ -3911,7 +3941,7 @@
|
|
|
3911
3941
|
CustomPdfDialogComponent.decorators = [
|
|
3912
3942
|
{ type: i0.Component, args: [{
|
|
3913
3943
|
selector: 'co-custom-pdf-dialog',
|
|
3914
|
-
template: "\n
|
|
3944
|
+
template: "\n <co-dialog\n [footerTemplate]=\"footerTemplate\"\n id=\"custom-pdf-dialog\"\n (closeClick)=\"closePDFDialog.emit()\">\n <!-- create a nice container for loader so it is not random in the corner somewhere -->\n <div *ngIf=\"showLoader\" class=\"loader-container\">\n <co-loader *ngIf=\"showLoader\"></co-loader>\n </div>\n\n <div #pdfBody id=\"pdfBody\">\n <section [innerHTML]=\"fileBody\"></section>\n </div>\n <ng-template #footerTemplate>\n <div class=\"co-dialog-footer-button-wrapper\">\n <co-button class=\"save-button\"\n [iconData]=\"iconCacheService.getIcon(icons.CheckDuotone)\"\n (click)=\"handleSaveClicked()\"></co-button>\n <co-button class=\"close-button\"\n [iconData]=\"iconCacheService.getIcon(icons.CrossSkinny)\"\n (click)=\"closePDFDialog.emit()\"></co-button>\n </div>\n </ng-template>\n </co-dialog>\n ",
|
|
3915
3945
|
encapsulation: i0.ViewEncapsulation.None
|
|
3916
3946
|
},] }
|
|
3917
3947
|
];
|
|
@@ -3941,6 +3971,7 @@
|
|
|
3941
3971
|
common.CommonModule,
|
|
3942
3972
|
corecomponents_v12.ButtonModule,
|
|
3943
3973
|
SharedComponentsTranslationModule,
|
|
3974
|
+
corecomponents_v12.LoaderModule
|
|
3944
3975
|
],
|
|
3945
3976
|
declarations: [
|
|
3946
3977
|
CustomPdfDialogComponent
|