mmhglobal-dynamicform 2.26.0 → 2.28.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 +10 -1
- package/esm2020/lib/services/main.service.mjs +11 -22
- package/esm2020/lib/uipage/uipage.component.mjs +4 -4
- package/esm2020/lib/zbuttons/zbuttons.component.mjs +6 -4
- package/esm2020/lib/zselectmultiple/zselectmultiple.component.mjs +8 -2
- package/esm2020/lib/zupload/zupload.component.mjs +104 -62
- package/esm2020/lib/zworkflowbuttons/zworkflowbuttons.component.mjs +9 -22
- package/fesm2015/mmhglobal-dynamicform.mjs +133 -108
- package/fesm2015/mmhglobal-dynamicform.mjs.map +1 -1
- package/fesm2020/mmhglobal-dynamicform.mjs +133 -107
- package/fesm2020/mmhglobal-dynamicform.mjs.map +1 -1
- package/lib/services/main.service.d.ts +3 -3
- package/lib/zselectmultiple/zselectmultiple.component.d.ts +1 -0
- package/lib/zupload/zupload.component.d.ts +5 -2
- package/lib/zworkflowbuttons/zworkflowbuttons.component.d.ts +2 -2
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { NavigationStart, NavigationEnd, NavigationError, RouterModule } from '@
|
|
|
6
6
|
import { BehaviorSubject, forkJoin, of, tap as tap$1, map as map$1, first, isObservable, switchMap as switchMap$1, interval, takeWhile, from, Subject, delay as delay$1, filter, auditTime } from 'rxjs';
|
|
7
7
|
import { tap, switchMap, map, take, delay, concatMap, ignoreElements } from 'rxjs/operators';
|
|
8
8
|
import * as i2 from 'mmhglobal-zcore';
|
|
9
|
-
import { ZGroup, FormType, ZComponentHelper, MESSAGETYPE, ActionType, DefaultMessage, DefaultDialogTitle, Delimiter, ZSelectPostApiParams, ComponentType as ComponentType$1, ZComponentProperties, SignalType, DropdownSearchOperator, InternalComponentType_DropDown, UploadMetaData, AttachmentConfig, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
|
|
9
|
+
import { ZGroup, FormType, ZComponentHelper, MESSAGETYPE, ActionType, DefaultMessage, DefaultDialogTitle, TriggerFromType, Delimiter, ZSelectPostApiParams, ComponentType as ComponentType$1, ZComponentProperties, SignalType, DropdownSearchOperator, InternalComponentType_DropDown, UploadMetaData, AttachmentConfig, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
|
|
10
10
|
import * as i2$1 from '@ionic/angular';
|
|
11
11
|
import { IonicModule } from '@ionic/angular';
|
|
12
12
|
import * as i3 from 'mmhglobal-zmodal';
|
|
@@ -828,8 +828,8 @@ class MainService {
|
|
|
828
828
|
getResourceServerData() {
|
|
829
829
|
return this.resourceApiService.loadData();
|
|
830
830
|
}
|
|
831
|
-
getGroupFields(fieldElementName, formType, group, propertyName) {
|
|
832
|
-
return this.fieldService.getFormFieldCode(fieldElementName, formType, group, propertyName);
|
|
831
|
+
getGroupFields(fieldElementName, formType, triggerFrom, group, propertyName) {
|
|
832
|
+
return this.fieldService.getFormFieldCode(fieldElementName, formType, group, propertyName, triggerFrom);
|
|
833
833
|
}
|
|
834
834
|
initializeGroup(group, ctrlName, pageName, me) {
|
|
835
835
|
if (me.subscription) {
|
|
@@ -839,7 +839,7 @@ class MainService {
|
|
|
839
839
|
group.resourceURLName = resourceName;
|
|
840
840
|
Object.assign(group, {
|
|
841
841
|
resourceURL: this.resourceApiService.getURL(resourceName),
|
|
842
|
-
gridColumnFields: this.fieldService.getFormFieldCode(ctrlName, "FormField"
|
|
842
|
+
gridColumnFields: this.fieldService.getFormFieldCode(ctrlName, "FormField"),
|
|
843
843
|
ctrlScope: me,
|
|
844
844
|
pageName,
|
|
845
845
|
ctrlName,
|
|
@@ -879,23 +879,12 @@ class MainService {
|
|
|
879
879
|
me.subscription = group.subject.subscribe((event) => this.subjectEvent(event, group, me));
|
|
880
880
|
return me.subscription;
|
|
881
881
|
}
|
|
882
|
-
getModel$(group, id) {
|
|
882
|
+
getModel$(group, id, triggerFrom) {
|
|
883
883
|
const recId = id || group.referenceId;
|
|
884
884
|
return this.webApiService
|
|
885
|
-
.httpGet$(group.resourceURL
|
|
885
|
+
.httpGet$(`${group.resourceURL}/${recId}`, null, { triggerFrom: triggerFrom })
|
|
886
886
|
.pipe(tap((zmodel) => {
|
|
887
887
|
group.zModel = zmodel;
|
|
888
|
-
//if (
|
|
889
|
-
// group.parentReferenceField &&
|
|
890
|
-
// Object.keys(zmodel).indexOf(group.parentReferenceField) !== -1 &&
|
|
891
|
-
// !group.backNavigationPage.endsWith(".edit")
|
|
892
|
-
//) {
|
|
893
|
-
// group.backNavigationPage =
|
|
894
|
-
// group.backNavigationPage +
|
|
895
|
-
// "/" +
|
|
896
|
-
// zmodel[group.parentReferenceField].toString() +
|
|
897
|
-
// "/edit";
|
|
898
|
-
//}
|
|
899
888
|
}), switchMap(() => {
|
|
900
889
|
if (group.afterGetModelSuccess) {
|
|
901
890
|
return this.afterGetModelSuccess(group);
|
|
@@ -1365,7 +1354,7 @@ class MainService {
|
|
|
1365
1354
|
}), switchMap(() => {
|
|
1366
1355
|
const newModel = Object.assign({}, group.zModel);
|
|
1367
1356
|
ZComponentHelper.removeNullFields(newModel);
|
|
1368
|
-
return this.webApiService.httpPost$(group.resourceURL, newModel).pipe(tap((resp) => {
|
|
1357
|
+
return this.webApiService.httpPost$(group.resourceURL, newModel, { buttonDetail: event, group: group, triggerFrom: event.triggerFrom }).pipe(tap((resp) => {
|
|
1369
1358
|
createModelres = resp;
|
|
1370
1359
|
return resp;
|
|
1371
1360
|
}), tap((res) => {
|
|
@@ -1411,7 +1400,7 @@ class MainService {
|
|
|
1411
1400
|
}
|
|
1412
1401
|
return of(false);
|
|
1413
1402
|
}
|
|
1414
|
-
updateAPIObservable = updateAPIObservable || this.webApiService.httpPut$(`${group.resourceURL}/${group.zModel.Id}`, group.zModel,
|
|
1403
|
+
updateAPIObservable = updateAPIObservable || this.webApiService.httpPut$(`${group.resourceURL}/${group.zModel.Id}`, group.zModel, { buttonDetail: event, group: group, triggerFrom: event.triggerFrom }).pipe(tap((res) => {
|
|
1415
1404
|
this.handleSuccess(res, resMessage);
|
|
1416
1405
|
}
|
|
1417
1406
|
//this.handleSuccess(res, "Record is updated successfully.")
|
|
@@ -1501,7 +1490,7 @@ class MainService {
|
|
|
1501
1490
|
group.zModel.Disabled = true;
|
|
1502
1491
|
let tempResponse = {};
|
|
1503
1492
|
return this.webApiService
|
|
1504
|
-
.httpPut$(group.resourceURL
|
|
1493
|
+
.httpPut$(`${group.resourceURL}/${group.zModel.Id}`, group.zModel, { buttonDetail: event, group: group, triggerFrom: event.triggerFrom })
|
|
1505
1494
|
.pipe(tap((res) => {
|
|
1506
1495
|
tempResponse = Object.assign({}, res);
|
|
1507
1496
|
this.handleSuccess(res, resMessage);
|
|
@@ -1795,7 +1784,7 @@ class MainService {
|
|
|
1795
1784
|
if (formId === respResult.Id?.toString() && eventName === window.location.href) {
|
|
1796
1785
|
if (respResult.UserName === this.authService.e1Token.myProfile.UserName) {
|
|
1797
1786
|
if (respResult.Action === ActionType.Update) {
|
|
1798
|
-
this.webApiService.httpGet$(`${this.group.resourceURL}/${formId}`, null).subscribe(resp => {
|
|
1787
|
+
this.webApiService.httpGet$(`${this.group.resourceURL}/${formId}`, null, { triggerFrom: TriggerFromType.signalRAlert }).subscribe(resp => {
|
|
1799
1788
|
this.reloadDataAndWorkflowButton(resp);
|
|
1800
1789
|
});
|
|
1801
1790
|
}
|
|
@@ -4004,7 +3993,7 @@ class UipageComponent {
|
|
|
4004
3993
|
const fieldElementName = this.group.fieldName ? this.group.fieldName : ctrlName;
|
|
4005
3994
|
this.group.fieldName = fieldElementName; // to be decprecated
|
|
4006
3995
|
this.group.fieldElementName = fieldElementName;
|
|
4007
|
-
return this.mainService.getGroupFields(fieldElementName, formType, this.group, "fields");
|
|
3996
|
+
return this.mainService.getGroupFields(fieldElementName, formType, TriggerFromType.initialPageLoad, this.group, "fields");
|
|
4008
3997
|
//let formFieldName = this.group.fieldName ? this.group.fieldName : ctrlName;
|
|
4009
3998
|
//this.group.fieldName = formFieldName;
|
|
4010
3999
|
//if(UipageComponent.signalrEventSubscription){
|
|
@@ -4049,7 +4038,7 @@ class UipageComponent {
|
|
|
4049
4038
|
return this.group.getModel(this.group, this.group.referenceId);
|
|
4050
4039
|
}
|
|
4051
4040
|
else {
|
|
4052
|
-
return this.mainService.getModel$(this.group, this.group.referenceId);
|
|
4041
|
+
return this.mainService.getModel$(this.group, this.group.referenceId, TriggerFromType.initialPageLoad);
|
|
4053
4042
|
}
|
|
4054
4043
|
}
|
|
4055
4044
|
else {
|
|
@@ -5303,7 +5292,7 @@ class ZbuttonsComponent extends ButtonFieldBase {
|
|
|
5303
5292
|
this.componentService.decrementComponentCounterForField(this.data);
|
|
5304
5293
|
}
|
|
5305
5294
|
loadButton() {
|
|
5306
|
-
const field$ = this.fieldService.getFormFieldCode(this.data.Value, "FormField"
|
|
5295
|
+
const field$ = this.fieldService.getFormFieldCode(this.data.Value, "FormField");
|
|
5307
5296
|
this.group.zButtonsCount++;
|
|
5308
5297
|
if (this.group.zButtonsCount === 1) {
|
|
5309
5298
|
this.FirstZbtn = true;
|
|
@@ -5354,6 +5343,7 @@ class ZbuttonsComponent extends ButtonFieldBase {
|
|
|
5354
5343
|
SubType: this.data.SubType,
|
|
5355
5344
|
Type: button.Type,
|
|
5356
5345
|
buttonData: button,
|
|
5346
|
+
eventId: ZComponentHelper.generateTimeStampId()
|
|
5357
5347
|
};
|
|
5358
5348
|
}
|
|
5359
5349
|
if (button['PositionX'] && button['PositionX'] === "right") {
|
|
@@ -5378,7 +5368,8 @@ class ZbuttonsComponent extends ButtonFieldBase {
|
|
|
5378
5368
|
this.group.subject.next({
|
|
5379
5369
|
type: "buttonClick",
|
|
5380
5370
|
target: item.clickEvent,
|
|
5381
|
-
data: item
|
|
5371
|
+
data: item,
|
|
5372
|
+
triggerFrom: TriggerFromType.button
|
|
5382
5373
|
});
|
|
5383
5374
|
}
|
|
5384
5375
|
getButtonDisableTriggerValue(data, button) {
|
|
@@ -6852,13 +6843,13 @@ class ZworkflowbuttonsComponent extends ButtonFieldBase {
|
|
|
6852
6843
|
if (this.group.resourceURL) {
|
|
6853
6844
|
this.isLocalHostAPI = this.group.resourceURL.toLowerCase().includes("localhost") ? true : false;
|
|
6854
6845
|
}
|
|
6855
|
-
this.loadButton();
|
|
6846
|
+
this.loadButton(TriggerFromType.initialPageLoad);
|
|
6856
6847
|
});
|
|
6857
6848
|
}
|
|
6858
6849
|
ngAfterViewInit() {
|
|
6859
6850
|
this.componentService.decrementComponentCounterForField(this.data);
|
|
6860
6851
|
}
|
|
6861
|
-
loadButton() {
|
|
6852
|
+
loadButton(triggerFrom) {
|
|
6862
6853
|
this.leftBtns = [];
|
|
6863
6854
|
this.rightBtns = [];
|
|
6864
6855
|
this.items = [];
|
|
@@ -6872,7 +6863,7 @@ class ZworkflowbuttonsComponent extends ButtonFieldBase {
|
|
|
6872
6863
|
try {
|
|
6873
6864
|
of(true).pipe(concatMap(() => {
|
|
6874
6865
|
// retrieve the workflow button
|
|
6875
|
-
return this.workflowService.getWorkflowButtonsField(this.data.WorkflowCode, this.e1wfs_wfcGetWorkflowButtonURL, String(this.isLocalHostAPI));
|
|
6866
|
+
return this.workflowService.getWorkflowButtonsField(this.data.WorkflowCode, this.e1wfs_wfcGetWorkflowButtonURL, String(this.isLocalHostAPI), triggerFrom);
|
|
6876
6867
|
}), tap(resultData => {
|
|
6877
6868
|
if (resultData) {
|
|
6878
6869
|
resultData.forEach((button) => {
|
|
@@ -6908,7 +6899,7 @@ class ZworkflowbuttonsComponent extends ButtonFieldBase {
|
|
|
6908
6899
|
this.items.push(...this.leftBtns, ...this.rightBtns);
|
|
6909
6900
|
}
|
|
6910
6901
|
else {
|
|
6911
|
-
console.warn(
|
|
6902
|
+
console.warn(`Unable to get workflow button. Data returned null.`);
|
|
6912
6903
|
}
|
|
6913
6904
|
}), switchMap(() => {
|
|
6914
6905
|
return super.translateButtonsLabel(this.items);
|
|
@@ -6955,19 +6946,6 @@ class ZworkflowbuttonsComponent extends ButtonFieldBase {
|
|
|
6955
6946
|
const formGroup = this.group.form;
|
|
6956
6947
|
const attributes = JSON.parse(button.Attributes);
|
|
6957
6948
|
const buttonTypeCode = button.TypeCode.toUpperCase();
|
|
6958
|
-
//// Skip if the button's click event includes backnavigation
|
|
6959
|
-
//if (buttonTypeCode === 'GOTO') {
|
|
6960
|
-
// // Check if the form has unsaved changes
|
|
6961
|
-
// if (!this.data.SkipCheckFormDirty && !formGroup.dirty) {
|
|
6962
|
-
// console.warn(`Record not saved because the form is not dirty.`);
|
|
6963
|
-
// return;
|
|
6964
|
-
// }
|
|
6965
|
-
// // Check if the form is valid
|
|
6966
|
-
// if (this.data.UseDefaultValidate && !formGroup.valid) {
|
|
6967
|
-
// this.componentErrorHandlerService.showFormGroupErrorMessage(this.group, formGroup);
|
|
6968
|
-
// return;
|
|
6969
|
-
// }
|
|
6970
|
-
//}
|
|
6971
6949
|
// Type 1 == functional;
|
|
6972
6950
|
// Type 2 == GOTO;
|
|
6973
6951
|
this.group.isTriggered = button.disableTrigger != undefined ? !button.disableTrigger : true;
|
|
@@ -6977,11 +6955,10 @@ class ZworkflowbuttonsComponent extends ButtonFieldBase {
|
|
|
6977
6955
|
if (!this.group.isTriggered) {
|
|
6978
6956
|
return;
|
|
6979
6957
|
}
|
|
6980
|
-
const group = this.group;
|
|
6981
6958
|
// Disable trigger timer
|
|
6982
6959
|
if (!attributes['DisableTriggerTimer']) {
|
|
6983
6960
|
setTimeout(function () {
|
|
6984
|
-
group['isTriggered'] = false;
|
|
6961
|
+
this.group['isTriggered'] = false;
|
|
6985
6962
|
}, 500);
|
|
6986
6963
|
}
|
|
6987
6964
|
console.log("Functional Button: ", button.Name);
|
|
@@ -6993,7 +6970,7 @@ class ZworkflowbuttonsComponent extends ButtonFieldBase {
|
|
|
6993
6970
|
// Call the workflow service to handle the GOTO button click event
|
|
6994
6971
|
this.workflowService.gotoButton_Onclick(button, this.data, attributes, this.group, this.isLocalHostAPI).subscribe(res => {
|
|
6995
6972
|
// Reload the button
|
|
6996
|
-
this.loadButton();
|
|
6973
|
+
this.loadButton(TriggerFromType.goToButton);
|
|
6997
6974
|
// Reset trigger status
|
|
6998
6975
|
this.group.isTriggered = false;
|
|
6999
6976
|
if (res) {
|
|
@@ -7017,6 +6994,7 @@ class ZworkflowbuttonsComponent extends ButtonFieldBase {
|
|
|
7017
6994
|
};
|
|
7018
6995
|
const newButton = {
|
|
7019
6996
|
...button,
|
|
6997
|
+
eventId: ZComponentHelper.generateTimeStampId(),
|
|
7020
6998
|
Attributes: JSON.stringify(newAttributes),
|
|
7021
6999
|
disableTrigger: this.isButtonDisableTrigger(this.data, button),
|
|
7022
7000
|
};
|
|
@@ -7215,6 +7193,7 @@ class ZselectmultipleComponent extends InputFieldBase {
|
|
|
7215
7193
|
this.itemDataField = null;
|
|
7216
7194
|
this.itemTemplate = "{{item[itemTextField]}}";
|
|
7217
7195
|
this.infiniteScrollPageNo = 0;
|
|
7196
|
+
this.infiniteDataLoaded = false;
|
|
7218
7197
|
this.isLoading = true;
|
|
7219
7198
|
this.allowCustomValue = false;
|
|
7220
7199
|
this.autoClose = true;
|
|
@@ -7432,6 +7411,8 @@ class ZselectmultipleComponent extends InputFieldBase {
|
|
|
7432
7411
|
this.infiniteScrollPageNo = 0;
|
|
7433
7412
|
this.modelzData = [];
|
|
7434
7413
|
}
|
|
7414
|
+
this.infiniteDataLoaded = false;
|
|
7415
|
+
ZComponentHelper.cancelGetInfiniteData;
|
|
7435
7416
|
this.getInfiniteData(event);
|
|
7436
7417
|
}
|
|
7437
7418
|
else {
|
|
@@ -7529,7 +7510,10 @@ class ZselectmultipleComponent extends InputFieldBase {
|
|
|
7529
7510
|
}
|
|
7530
7511
|
handleOpen(event) {
|
|
7531
7512
|
if (this.data.HasInfiniteScroll) {
|
|
7532
|
-
this.
|
|
7513
|
+
if (!this.infiniteDataLoaded) {
|
|
7514
|
+
this.infiniteDataLoaded = true;
|
|
7515
|
+
this.handleFilter(null);
|
|
7516
|
+
}
|
|
7533
7517
|
}
|
|
7534
7518
|
// Ensure multiselect value meets the search length requirement
|
|
7535
7519
|
if (this.multiselect && this.data.SearchLength && this.multiselect.value.length < this.data.SearchLength) {
|
|
@@ -8245,7 +8229,7 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8245
8229
|
// DivClass: "col-md-12 col-md-6",
|
|
8246
8230
|
// Visible: true
|
|
8247
8231
|
// }];
|
|
8248
|
-
constructor(componentService, authService, compressImage, zcoreService, ngZone, sharePointService) {
|
|
8232
|
+
constructor(componentService, authService, compressImage, zcoreService, ngZone, sharePointService, alertService) {
|
|
8249
8233
|
super(componentService);
|
|
8250
8234
|
this.componentService = componentService;
|
|
8251
8235
|
this.authService = authService;
|
|
@@ -8253,6 +8237,7 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8253
8237
|
this.zcoreService = zcoreService;
|
|
8254
8238
|
this.ngZone = ngZone;
|
|
8255
8239
|
this.sharePointService = sharePointService;
|
|
8240
|
+
this.alertService = alertService;
|
|
8256
8241
|
this.uploadAttachmentUrl = null;
|
|
8257
8242
|
this.uploadSaveUrl = "/Attachment/Chunk_Upload_Save"; // should represent an actual API endpoint
|
|
8258
8243
|
this.uploadRemoveUrl = "/Attachment/Chunk_Upload_Remove"; // should represent an actual API endpoint
|
|
@@ -8313,6 +8298,9 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8313
8298
|
if (this.data.Multiple) {
|
|
8314
8299
|
this.isMultiple = this.data.Multiple;
|
|
8315
8300
|
}
|
|
8301
|
+
if (this.data.AllowedFileExtension) {
|
|
8302
|
+
this.restrictions.allowedExtensions = this.restrictions.allowedExtensions.concat(this.data.AllowedFileExtension);
|
|
8303
|
+
}
|
|
8316
8304
|
this.componentProperties.style.style6 = this.componentProperties.style.style6 || "margin: 5px; border: 1px solid gray;";
|
|
8317
8305
|
}
|
|
8318
8306
|
onSuccess(e) {
|
|
@@ -8407,18 +8395,24 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8407
8395
|
// Image Preview
|
|
8408
8396
|
const me = this;
|
|
8409
8397
|
e.files.forEach((file) => {
|
|
8410
|
-
if (
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8398
|
+
if (!me.isValidUploadedFile(me, file)) {
|
|
8399
|
+
e.preventDefault();
|
|
8400
|
+
return;
|
|
8401
|
+
}
|
|
8402
|
+
else {
|
|
8403
|
+
if (file.rawFile && file.rawFile.type.includes("image")) {
|
|
8404
|
+
if (!file.validationErrors) {
|
|
8405
|
+
const reader = new FileReader();
|
|
8406
|
+
reader.onload = function (ev) {
|
|
8407
|
+
if (me.data.EnableImagePreview) {
|
|
8408
|
+
if (!me.uid.includes(file.uid)) {
|
|
8409
|
+
me.uid.push(file.uid);
|
|
8410
|
+
me.imagePreviews.push({ ...file, src: reader.result });
|
|
8411
|
+
}
|
|
8418
8412
|
}
|
|
8419
|
-
}
|
|
8420
|
-
|
|
8421
|
-
|
|
8413
|
+
};
|
|
8414
|
+
reader.readAsDataURL(file.rawFile);
|
|
8415
|
+
}
|
|
8422
8416
|
}
|
|
8423
8417
|
}
|
|
8424
8418
|
});
|
|
@@ -8482,38 +8476,60 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8482
8476
|
});
|
|
8483
8477
|
}
|
|
8484
8478
|
}
|
|
8479
|
+
isValidUploadedFile(me, file) {
|
|
8480
|
+
const fileSize = file.rawFile.size;
|
|
8481
|
+
const fileExtension = file.rawFile.name.split('.').pop().toLowerCase();
|
|
8482
|
+
// Check if file size and extension are valid
|
|
8483
|
+
if (fileSize > me.restrictions.maxFileSize || !me.restrictions.allowedExtensions.includes(fileExtension)) {
|
|
8484
|
+
let errorMessage = 'Error: ';
|
|
8485
|
+
if (!me.restrictions.allowedExtensions.includes(fileExtension)) {
|
|
8486
|
+
errorMessage = `Invalid file type. Allowed types are: ${me.restrictions.allowedExtensions.join(', ')}.`;
|
|
8487
|
+
}
|
|
8488
|
+
else if (fileSize > me.restrictions.maxFileSize) {
|
|
8489
|
+
errorMessage = `File size cannot exceeds ${me.formatFileSize(me.restrictions.maxFileSize)}.`;
|
|
8490
|
+
}
|
|
8491
|
+
me.alertService.showOkay('Failed to upload', errorMessage, ['col-4']);
|
|
8492
|
+
return false;
|
|
8493
|
+
}
|
|
8494
|
+
return true;
|
|
8495
|
+
}
|
|
8485
8496
|
selectEventHandler(e) {
|
|
8486
8497
|
const me = this;
|
|
8487
|
-
|
|
8498
|
+
//#region sharepoint
|
|
8488
8499
|
const attachmentInfo = this.sharePointService.getAttachmentInfo(this.data["DownloadFileConfig"]);
|
|
8489
|
-
//
|
|
8500
|
+
// Change uploadSaveUrl if saving to SharePoint
|
|
8490
8501
|
if (attachmentInfo && attachmentInfo.isSaveToSharePoint && attachmentInfo.siteName) {
|
|
8491
8502
|
const attachmentSourceUrl = this.zcoreService.getEnvironment().attachmentSourceUrl;
|
|
8492
8503
|
this.uploadSaveUrl = attachmentSourceUrl + '/Chunk_Upload_Save';
|
|
8493
8504
|
}
|
|
8494
|
-
|
|
8505
|
+
//#endregion
|
|
8495
8506
|
if (this.data['SelectFileOnly']) {
|
|
8496
|
-
//
|
|
8507
|
+
// Append all files to component memory
|
|
8497
8508
|
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
|
-
|
|
8509
|
+
if (me.isValidUploadedFile(me, file)) {
|
|
8510
|
+
if (file.rawFile) {
|
|
8511
|
+
const reader = new FileReader();
|
|
8512
|
+
reader.onload = function (ev) {
|
|
8513
|
+
// Clone the data and also add the read file to the object
|
|
8514
|
+
const fileData = Object.assign({}, file);
|
|
8515
|
+
fileData['file'] = ev.target["result"];
|
|
8516
|
+
// Push to component fileList
|
|
8517
|
+
me.fileList.push(fileData);
|
|
8518
|
+
me.group['zupload_' + me.data.Value] = me.fileList;
|
|
8519
|
+
if (me.data['FileSelectedEvent']) {
|
|
8520
|
+
// Call the project event
|
|
8521
|
+
me.group.subject.next({
|
|
8522
|
+
type: "zupload-fileSelectedEvent",
|
|
8523
|
+
target: me.data['FileSelectedEvent'],
|
|
8524
|
+
data: me.fileList
|
|
8525
|
+
});
|
|
8526
|
+
}
|
|
8527
|
+
};
|
|
8528
|
+
await reader.readAsDataURL(file.rawFile);
|
|
8529
|
+
}
|
|
8530
|
+
}
|
|
8531
|
+
else {
|
|
8532
|
+
e.preventDefault();
|
|
8517
8533
|
}
|
|
8518
8534
|
});
|
|
8519
8535
|
}
|
|
@@ -8525,29 +8541,32 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8525
8541
|
//Check if Image Compression is enabled.
|
|
8526
8542
|
if (imageCompressionEnabled === true) {
|
|
8527
8543
|
e.files.forEach((file) => {
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
if (
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
.
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8544
|
+
if (me.isValidUploadedFile(me, file)) {
|
|
8545
|
+
// Compress only if it is an image file
|
|
8546
|
+
if (file.rawFile && file.rawFile.type.includes("image")) {
|
|
8547
|
+
if (!file.validationErrors) {
|
|
8548
|
+
const imgConfig = this.compressionConfigHandler(this.data.Compression);
|
|
8549
|
+
if (file.size > imgConfig.FileSizeMinSizeByte) {
|
|
8550
|
+
me.compressImage.compress(file.rawFile, imgConfig) //Pass in parameter to set the Compression Options
|
|
8551
|
+
.pipe(take(1))
|
|
8552
|
+
.subscribe(compressFile => {
|
|
8553
|
+
this.ngZone.run(() => {
|
|
8554
|
+
file.rawFile = compressFile;
|
|
8555
|
+
file.size = compressFile.size;
|
|
8556
|
+
// Push to component fileList
|
|
8557
|
+
me.fileList.push(Object.assign({}, file));
|
|
8558
|
+
const reader = new FileReader();
|
|
8559
|
+
reader.readAsDataURL(file.rawFile);
|
|
8560
|
+
});
|
|
8561
|
+
console.log(`Compressed file size: ${(file.rawFile.size / 1024).toFixed(2)}KB`);
|
|
8545
8562
|
});
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8563
|
+
} // file size check
|
|
8564
|
+
} // validationErrors check
|
|
8565
|
+
} // file type check
|
|
8566
|
+
}
|
|
8567
|
+
else {
|
|
8568
|
+
e.preventDefault();
|
|
8569
|
+
}
|
|
8551
8570
|
}); // loop each file
|
|
8552
8571
|
} // imagecompression check
|
|
8553
8572
|
// add to group scope
|
|
@@ -8559,13 +8578,20 @@ class ZuploadComponent extends InputFieldBase {
|
|
|
8559
8578
|
this.uploadComponent.clearFiles();
|
|
8560
8579
|
this.group['zupload_' + this.data.Value] = this.fileList;
|
|
8561
8580
|
}
|
|
8581
|
+
formatFileSize(bytes) {
|
|
8582
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
8583
|
+
if (bytes === 0)
|
|
8584
|
+
return '0 Byte';
|
|
8585
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
8586
|
+
return parseFloat((bytes / Math.pow(1024, i)).toFixed(2)) + sizes[i];
|
|
8587
|
+
}
|
|
8562
8588
|
}
|
|
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
|
|
8589
|
+
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 });
|
|
8590
|
+
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
8591
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ZuploadComponent, decorators: [{
|
|
8566
8592
|
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: [{
|
|
8593
|
+
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"] }]
|
|
8594
|
+
}], 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
8595
|
type: ViewChild,
|
|
8570
8596
|
args: ["uploadComponent"]
|
|
8571
8597
|
}] } });
|