mmhglobal-dynamicform 2.26.0 → 2.27.0
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/README.md +5 -1
- package/esm2020/lib/zupload/zupload.component.mjs +104 -62
- package/fesm2015/mmhglobal-dynamicform.mjs +103 -61
- package/fesm2015/mmhglobal-dynamicform.mjs.map +1 -1
- package/fesm2020/mmhglobal-dynamicform.mjs +103 -61
- package/fesm2020/mmhglobal-dynamicform.mjs.map +1 -1
- package/lib/zupload/zupload.component.d.ts +5 -2
- package/package.json +1 -1
|
@@ -8245,7 +8245,7 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8245
8245
|
// DivClass: "col-md-12 col-md-6",
|
|
8246
8246
|
// Visible: true
|
|
8247
8247
|
// }];
|
|
8248
|
-
constructor(componentService, authService, compressImage, zcoreService, ngZone, sharePointService) {
|
|
8248
|
+
constructor(componentService, authService, compressImage, zcoreService, ngZone, sharePointService, alertService) {
|
|
8249
8249
|
super(componentService);
|
|
8250
8250
|
this.componentService = componentService;
|
|
8251
8251
|
this.authService = authService;
|
|
@@ -8253,6 +8253,7 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8253
8253
|
this.zcoreService = zcoreService;
|
|
8254
8254
|
this.ngZone = ngZone;
|
|
8255
8255
|
this.sharePointService = sharePointService;
|
|
8256
|
+
this.alertService = alertService;
|
|
8256
8257
|
this.uploadAttachmentUrl = null;
|
|
8257
8258
|
this.uploadSaveUrl = "/Attachment/Chunk_Upload_Save"; // should represent an actual API endpoint
|
|
8258
8259
|
this.uploadRemoveUrl = "/Attachment/Chunk_Upload_Remove"; // should represent an actual API endpoint
|
|
@@ -8313,6 +8314,9 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8313
8314
|
if (this.data.Multiple) {
|
|
8314
8315
|
this.isMultiple = this.data.Multiple;
|
|
8315
8316
|
}
|
|
8317
|
+
if (this.data.AllowedFileExtension) {
|
|
8318
|
+
this.restrictions.allowedExtensions = this.restrictions.allowedExtensions.concat(this.data.AllowedFileExtension);
|
|
8319
|
+
}
|
|
8316
8320
|
this.componentProperties.style.style6 = this.componentProperties.style.style6 || "margin: 5px; border: 1px solid gray;";
|
|
8317
8321
|
}
|
|
8318
8322
|
onSuccess(e) {
|
|
@@ -8407,18 +8411,24 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8407
8411
|
// Image Preview
|
|
8408
8412
|
const me = this;
|
|
8409
8413
|
e.files.forEach((file) => {
|
|
8410
|
-
if (
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8414
|
+
if (!me.isValidUploadedFile(me, file)) {
|
|
8415
|
+
e.preventDefault();
|
|
8416
|
+
return;
|
|
8417
|
+
}
|
|
8418
|
+
else {
|
|
8419
|
+
if (file.rawFile && file.rawFile.type.includes("image")) {
|
|
8420
|
+
if (!file.validationErrors) {
|
|
8421
|
+
const reader = new FileReader();
|
|
8422
|
+
reader.onload = function (ev) {
|
|
8423
|
+
if (me.data.EnableImagePreview) {
|
|
8424
|
+
if (!me.uid.includes(file.uid)) {
|
|
8425
|
+
me.uid.push(file.uid);
|
|
8426
|
+
me.imagePreviews.push({ ...file, src: reader.result });
|
|
8427
|
+
}
|
|
8418
8428
|
}
|
|
8419
|
-
}
|
|
8420
|
-
|
|
8421
|
-
|
|
8429
|
+
};
|
|
8430
|
+
reader.readAsDataURL(file.rawFile);
|
|
8431
|
+
}
|
|
8422
8432
|
}
|
|
8423
8433
|
}
|
|
8424
8434
|
});
|
|
@@ -8482,38 +8492,60 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8482
8492
|
});
|
|
8483
8493
|
}
|
|
8484
8494
|
}
|
|
8495
|
+
isValidUploadedFile(me, file) {
|
|
8496
|
+
const fileSize = file.rawFile.size;
|
|
8497
|
+
const fileExtension = file.rawFile.name.split('.').pop().toLowerCase();
|
|
8498
|
+
// Check if file size and extension are valid
|
|
8499
|
+
if (fileSize > me.restrictions.maxFileSize || !me.restrictions.allowedExtensions.includes(fileExtension)) {
|
|
8500
|
+
let errorMessage = 'Error: ';
|
|
8501
|
+
if (!me.restrictions.allowedExtensions.includes(fileExtension)) {
|
|
8502
|
+
errorMessage = `Invalid file type. Allowed types are: ${me.restrictions.allowedExtensions.join(', ')}.`;
|
|
8503
|
+
}
|
|
8504
|
+
else if (fileSize > me.restrictions.maxFileSize) {
|
|
8505
|
+
errorMessage = `File size cannot exceeds ${me.formatFileSize(me.restrictions.maxFileSize)}.`;
|
|
8506
|
+
}
|
|
8507
|
+
me.alertService.showOkay('Failed to upload', errorMessage, ['col-4']);
|
|
8508
|
+
return false;
|
|
8509
|
+
}
|
|
8510
|
+
return true;
|
|
8511
|
+
}
|
|
8485
8512
|
selectEventHandler(e) {
|
|
8486
8513
|
const me = this;
|
|
8487
|
-
|
|
8514
|
+
//#region sharepoint
|
|
8488
8515
|
const attachmentInfo = this.sharePointService.getAttachmentInfo(this.data["DownloadFileConfig"]);
|
|
8489
|
-
//
|
|
8516
|
+
// Change uploadSaveUrl if saving to SharePoint
|
|
8490
8517
|
if (attachmentInfo && attachmentInfo.isSaveToSharePoint && attachmentInfo.siteName) {
|
|
8491
8518
|
const attachmentSourceUrl = this.zcoreService.getEnvironment().attachmentSourceUrl;
|
|
8492
8519
|
this.uploadSaveUrl = attachmentSourceUrl + '/Chunk_Upload_Save';
|
|
8493
8520
|
}
|
|
8494
|
-
|
|
8521
|
+
//#endregion
|
|
8495
8522
|
if (this.data['SelectFileOnly']) {
|
|
8496
|
-
//
|
|
8523
|
+
// Append all files to component memory
|
|
8497
8524
|
e.files.forEach(async (file) => {
|
|
8498
|
-
if (file
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8525
|
+
if (me.isValidUploadedFile(me, file)) {
|
|
8526
|
+
if (file.rawFile) {
|
|
8527
|
+
const reader = new FileReader();
|
|
8528
|
+
reader.onload = function (ev) {
|
|
8529
|
+
// Clone the data and also add the read file to the object
|
|
8530
|
+
const fileData = Object.assign({}, file);
|
|
8531
|
+
fileData['file'] = ev.target["result"];
|
|
8532
|
+
// Push to component fileList
|
|
8533
|
+
me.fileList.push(fileData);
|
|
8534
|
+
me.group['zupload_' + me.data.Value] = me.fileList;
|
|
8535
|
+
if (me.data['FileSelectedEvent']) {
|
|
8536
|
+
// Call the project event
|
|
8537
|
+
me.group.subject.next({
|
|
8538
|
+
type: "zupload-fileSelectedEvent",
|
|
8539
|
+
target: me.data['FileSelectedEvent'],
|
|
8540
|
+
data: me.fileList
|
|
8541
|
+
});
|
|
8542
|
+
}
|
|
8543
|
+
};
|
|
8544
|
+
await reader.readAsDataURL(file.rawFile);
|
|
8545
|
+
}
|
|
8546
|
+
}
|
|
8547
|
+
else {
|
|
8548
|
+
e.preventDefault();
|
|
8517
8549
|
}
|
|
8518
8550
|
});
|
|
8519
8551
|
}
|
|
@@ -8525,29 +8557,32 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8525
8557
|
//Check if Image Compression is enabled.
|
|
8526
8558
|
if (imageCompressionEnabled === true) {
|
|
8527
8559
|
e.files.forEach((file) => {
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
if (
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
.
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8560
|
+
if (me.isValidUploadedFile(me, file)) {
|
|
8561
|
+
// Compress only if it is an image file
|
|
8562
|
+
if (file.rawFile && file.rawFile.type.includes("image")) {
|
|
8563
|
+
if (!file.validationErrors) {
|
|
8564
|
+
const imgConfig = this.compressionConfigHandler(this.data.Compression);
|
|
8565
|
+
if (file.size > imgConfig.FileSizeMinSizeByte) {
|
|
8566
|
+
me.compressImage.compress(file.rawFile, imgConfig) //Pass in parameter to set the Compression Options
|
|
8567
|
+
.pipe(take(1))
|
|
8568
|
+
.subscribe(compressFile => {
|
|
8569
|
+
this.ngZone.run(() => {
|
|
8570
|
+
file.rawFile = compressFile;
|
|
8571
|
+
file.size = compressFile.size;
|
|
8572
|
+
// Push to component fileList
|
|
8573
|
+
me.fileList.push(Object.assign({}, file));
|
|
8574
|
+
const reader = new FileReader();
|
|
8575
|
+
reader.readAsDataURL(file.rawFile);
|
|
8576
|
+
});
|
|
8577
|
+
console.log(`Compressed file size: ${(file.rawFile.size / 1024).toFixed(2)}KB`);
|
|
8545
8578
|
});
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8579
|
+
} // file size check
|
|
8580
|
+
} // validationErrors check
|
|
8581
|
+
} // file type check
|
|
8582
|
+
}
|
|
8583
|
+
else {
|
|
8584
|
+
e.preventDefault();
|
|
8585
|
+
}
|
|
8551
8586
|
}); // loop each file
|
|
8552
8587
|
} // imagecompression check
|
|
8553
8588
|
// add to group scope
|
|
@@ -8559,13 +8594,20 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8559
8594
|
this.uploadComponent.clearFiles();
|
|
8560
8595
|
this.group['zupload_' + this.data.Value] = this.fileList;
|
|
8561
8596
|
}
|
|
8597
|
+
formatFileSize(bytes) {
|
|
8598
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
8599
|
+
if (bytes === 0)
|
|
8600
|
+
return '0 Byte';
|
|
8601
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
8602
|
+
return parseFloat((bytes / Math.pow(1024, i)).toFixed(2)) + sizes[i];
|
|
8603
|
+
}
|
|
8562
8604
|
}
|
|
8563
|
-
ZuploadComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ZuploadComponent, deps: [{ token: ZComponentService }, { token: i2.AuthService }, { token: i2.CompressImageService }, { token: i2.ZCoreService }, { token: i0.NgZone }, { token: i2.SharePointService }], target: i0.ɵɵFactoryTarget.Component });
|
|
8564
|
-
ZuploadComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: ZuploadComponent, selector: "app-zupload", viewQueries: [{ propertyName: "uploadComponent", first: true, predicate: ["uploadComponent"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div [formGroup]=\"form\" class=\"zupload-container e1tag-style\" [style]=\"componentProperties.style.style\">\r\n <kendo-upload
|
|
8605
|
+
ZuploadComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ZuploadComponent, deps: [{ token: ZComponentService }, { token: i2.AuthService }, { token: i2.CompressImageService }, { token: i2.ZCoreService }, { token: i0.NgZone }, { token: i2.SharePointService }, { token: i2.AlertService }], target: i0.ɵɵFactoryTarget.Component });
|
|
8606
|
+
ZuploadComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: ZuploadComponent, selector: "app-zupload", viewQueries: [{ propertyName: "uploadComponent", first: true, predicate: ["uploadComponent"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div [formGroup]=\"form\" class=\"zupload-container e1tag-style\" [style]=\"componentProperties.style.style\">\r\n <kendo-upload\r\n *ngIf=\"!data.SelectFileOnly\"\r\n #uploadComponent\r\n [id]=\"data.Value\"\r\n [autoUpload]=\"isAutoUpload\"\r\n [saveUrl]=\"uploadSaveUrl\"\r\n [removeUrl]=\"uploadRemoveUrl\"\r\n [restrictions]=\"restrictions\"\r\n [multiple]=\"isMultiple\"\r\n [chunkable]=\"chunkSettings\"\r\n [showFileList]=\"showFileList\"\r\n (select)=\"selectEventHandler($event)\"\r\n (remove)=\"onRemove($event)\"\r\n (success)=\"onSuccess($event)\"\r\n (upload)=\"uploadEventHandler($event)\"\r\n [style]=\"componentProperties.style.style1\"\r\n class=\"e1tag-style1\">\r\n </kendo-upload>\r\n\r\n <kendo-fileselect\r\n *ngIf=\"data.SelectFileOnly\"\r\n #uploadComponent\r\n [id]=\"data.Value\"\r\n (select)=\"selectEventHandler($event)\"\r\n (remove)=\"onRemove($event)\"\r\n [formControlName]=\"data.Value\"\r\n (valueChange)=\"onChange($event)\" \r\n [restrictions]=\"restrictions\"\r\n [style]=\"componentProperties.style.style1\"\r\n class=\"e1tag-style1\">\r\n </kendo-fileselect>\r\n\r\n <div\r\n *ngIf=\"imagePreviews.length\"\r\n class=\"image-preview-container e1tag-style2\"\r\n [style]=\"componentProperties.style.style2\">\r\n <div\r\n class=\"label-container e1tag-style3\"\r\n [style]=\"componentProperties.style.style3\">\r\n Image Preview:\r\n </div>\r\n <div\r\n class=\"image-container e1tag-style4\"\r\n [style]=\"componentProperties.style.style4\">\r\n <img\r\n *ngFor=\"let image of imagePreviews\"\r\n [src]=\"image.src\"\r\n alt=\"image preview\"\r\n height=\"100\"\r\n class=\"e1tag-style5\"\r\n [style]=\"componentProperties.style.style5\" />\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [".image-preview-container{border:1px solid rgba(0,0,0,.08)}.image-preview-container>.label-container{margin:5px}\n"], components: [{ type: i3$7.UploadComponent, selector: "kendo-upload", inputs: ["autoUpload", "batch", "withCredentials", "saveField", "saveHeaders", "saveMethod", "saveUrl", "responseType", "removeField", "removeHeaders", "removeMethod", "removeUrl", "chunkable", "concurrent", "multiple", "disabled", "showFileList", "tabindex", "zoneId", "tabIndex", "accept", "restrictions", "focusableId", "actionsLayout"], outputs: ["blur", "cancel", "clear", "complete", "error", "focus", "pause", "remove", "resume", "select", "success", "upload", "uploadProgress", "valueChange"], exportAs: ["kendoUpload"] }, { type: i3$7.FileSelectComponent, selector: "kendo-fileselect", inputs: ["accept", "disabled", "multiple", "name", "showFileList", "tabindex", "restrictions", "zoneId", "focusableId"], outputs: ["blur", "focus", "select", "remove", "valueChange"], exportAs: ["kendoFileSelect"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
8565
8607
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ZuploadComponent, decorators: [{
|
|
8566
8608
|
type: Component,
|
|
8567
|
-
args: [{ selector: "app-zupload", template: "<div [formGroup]=\"form\" class=\"zupload-container e1tag-style\" [style]=\"componentProperties.style.style\">\r\n <kendo-upload
|
|
8568
|
-
}], ctorParameters: function () { return [{ type: ZComponentService }, { type: i2.AuthService }, { type: i2.CompressImageService }, { type: i2.ZCoreService }, { type: i0.NgZone }, { type: i2.SharePointService }]; }, propDecorators: { uploadComponent: [{
|
|
8609
|
+
args: [{ selector: "app-zupload", template: "<div [formGroup]=\"form\" class=\"zupload-container e1tag-style\" [style]=\"componentProperties.style.style\">\r\n <kendo-upload\r\n *ngIf=\"!data.SelectFileOnly\"\r\n #uploadComponent\r\n [id]=\"data.Value\"\r\n [autoUpload]=\"isAutoUpload\"\r\n [saveUrl]=\"uploadSaveUrl\"\r\n [removeUrl]=\"uploadRemoveUrl\"\r\n [restrictions]=\"restrictions\"\r\n [multiple]=\"isMultiple\"\r\n [chunkable]=\"chunkSettings\"\r\n [showFileList]=\"showFileList\"\r\n (select)=\"selectEventHandler($event)\"\r\n (remove)=\"onRemove($event)\"\r\n (success)=\"onSuccess($event)\"\r\n (upload)=\"uploadEventHandler($event)\"\r\n [style]=\"componentProperties.style.style1\"\r\n class=\"e1tag-style1\">\r\n </kendo-upload>\r\n\r\n <kendo-fileselect\r\n *ngIf=\"data.SelectFileOnly\"\r\n #uploadComponent\r\n [id]=\"data.Value\"\r\n (select)=\"selectEventHandler($event)\"\r\n (remove)=\"onRemove($event)\"\r\n [formControlName]=\"data.Value\"\r\n (valueChange)=\"onChange($event)\" \r\n [restrictions]=\"restrictions\"\r\n [style]=\"componentProperties.style.style1\"\r\n class=\"e1tag-style1\">\r\n </kendo-fileselect>\r\n\r\n <div\r\n *ngIf=\"imagePreviews.length\"\r\n class=\"image-preview-container e1tag-style2\"\r\n [style]=\"componentProperties.style.style2\">\r\n <div\r\n class=\"label-container e1tag-style3\"\r\n [style]=\"componentProperties.style.style3\">\r\n Image Preview:\r\n </div>\r\n <div\r\n class=\"image-container e1tag-style4\"\r\n [style]=\"componentProperties.style.style4\">\r\n <img\r\n *ngFor=\"let image of imagePreviews\"\r\n [src]=\"image.src\"\r\n alt=\"image preview\"\r\n height=\"100\"\r\n class=\"e1tag-style5\"\r\n [style]=\"componentProperties.style.style5\" />\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [".image-preview-container{border:1px solid rgba(0,0,0,.08)}.image-preview-container>.label-container{margin:5px}\n"] }]
|
|
8610
|
+
}], ctorParameters: function () { return [{ type: ZComponentService }, { type: i2.AuthService }, { type: i2.CompressImageService }, { type: i2.ZCoreService }, { type: i0.NgZone }, { type: i2.SharePointService }, { type: i2.AlertService }]; }, propDecorators: { uploadComponent: [{
|
|
8569
8611
|
type: ViewChild,
|
|
8570
8612
|
args: ["uploadComponent"]
|
|
8571
8613
|
}] } });
|