@trudb/tru-common-lib 0.0.340 → 0.0.342
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/esm2020/lib/base-classes/tru-entity-base.mjs +2 -1
- package/esm2020/lib/classes/tru-merge-data-set.mjs +12 -0
- package/esm2020/lib/classes/tru-merge-data.mjs +17 -0
- package/esm2020/lib/components/validation-dialog/tru-validation-dialog-config.mjs +21 -0
- package/esm2020/lib/components/validation-dialog/tru-validation-dialog.mjs +44 -37
- package/esm2020/lib/directives/breeze-validator/tru-breeze-validator.mjs +18 -8
- package/fesm2015/trudb-tru-common-lib.mjs +80 -43
- package/fesm2015/trudb-tru-common-lib.mjs.map +1 -1
- package/fesm2020/trudb-tru-common-lib.mjs +80 -43
- package/fesm2020/trudb-tru-common-lib.mjs.map +1 -1
- package/lib/base-classes/tru-entity-base.d.ts +2 -1
- package/lib/classes/tru-merge-data-set.d.ts +7 -0
- package/lib/classes/tru-merge-data.d.ts +9 -0
- package/lib/components/validation-dialog/tru-validation-dialog-config.d.ts +13 -0
- package/lib/components/validation-dialog/tru-validation-dialog.d.ts +11 -6
- package/lib/directives/breeze-validator/tru-breeze-validator.d.ts +3 -2
- package/package.json +1 -1
|
@@ -106,6 +106,7 @@ class TruEntityBase {
|
|
|
106
106
|
this.CreatedRef = -1;
|
|
107
107
|
this.Updated = undefined;
|
|
108
108
|
this.UpdatedRef = undefined;
|
|
109
|
+
this.Merge_Data_Set = undefined;
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -4835,60 +4836,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
4835
4836
|
}] }]; } });
|
|
4836
4837
|
|
|
4837
4838
|
class TruValidationDialog {
|
|
4838
|
-
constructor() {
|
|
4839
|
+
constructor(elementRef, util) {
|
|
4840
|
+
this.elementRef = elementRef;
|
|
4841
|
+
this.util = util;
|
|
4842
|
+
this.errorMsg = '';
|
|
4839
4843
|
this.onAcceptAll = () => {
|
|
4840
|
-
let entity = this.entity;
|
|
4844
|
+
let entity = this.config.entity;
|
|
4841
4845
|
let originalValues = entity.entityAspect.originalValues;
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
entity[key] = this.mergeData[propertyNameKey].value;
|
|
4846
|
+
for (const key in this.config.mergeData) {
|
|
4847
|
+
entity[key] = this.config.mergeData.getData(key).value;
|
|
4845
4848
|
if (originalValues.hasOwnProperty(key))
|
|
4846
4849
|
delete originalValues[key];
|
|
4847
|
-
}
|
|
4850
|
+
}
|
|
4851
|
+
;
|
|
4848
4852
|
if (Object.keys(originalValues).length === 0 && originalValues.constructor === Object)
|
|
4849
4853
|
entity.entityAspect.setUnchanged();
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
propertiesToValidate.forEach(function (key) {
|
|
4854
|
+
entity.Merge_Data_Set = JSON.stringify({});
|
|
4855
|
+
for (const key in this.config.mergeData) {
|
|
4853
4856
|
entity.entityAspect.validateProperty(key);
|
|
4854
|
-
}
|
|
4857
|
+
}
|
|
4858
|
+
;
|
|
4855
4859
|
};
|
|
4856
4860
|
this.onAccept = () => {
|
|
4857
|
-
let entity = this.entity;
|
|
4858
|
-
let originalValues = entity.entityAspect.originalValues;
|
|
4859
|
-
let propertyName = '';
|
|
4860
|
-
|
|
4861
|
-
let propertyNameKey = propertyName;
|
|
4862
|
-
entity[propertyName] = this.mergeData
|
|
4863
|
-
delete this.mergeData[propertyNameKey];
|
|
4864
|
-
if (originalValues.hasOwnProperty(propertyName) && (Object.keys(originalValues).length === 0 && originalValues.constructor === Object))
|
|
4865
|
-
|
|
4866
|
-
if (!Object.keys(this.mergeData).length)
|
|
4867
|
-
|
|
4868
|
-
entity.Merge_Data = JSON.stringify(this.mergeData);
|
|
4869
|
-
entity.entityAspect.validateProperty(propertyName);
|
|
4861
|
+
//let entity = this.config.entity as any;
|
|
4862
|
+
//let originalValues = entity.entityAspect.originalValues;
|
|
4863
|
+
//let propertyName = '';
|
|
4864
|
+
//let mergeData = JSON.parse(entity.Merge_Data_Set);
|
|
4865
|
+
//let propertyNameKey = propertyName as keyof typeof this.mergeData;
|
|
4866
|
+
//entity[propertyName] = this.config.mergeData?.getData(propertyNameKey)!.value;
|
|
4867
|
+
//delete this.mergeData[propertyNameKey];
|
|
4868
|
+
//if (originalValues.hasOwnProperty(propertyName) && (Object.keys(originalValues).length === 0 && originalValues.constructor === Object))
|
|
4869
|
+
// delete originalValues[propertyName];
|
|
4870
|
+
//if (!Object.keys(this.mergeData).length)
|
|
4871
|
+
// entity.entityAspect.setUnchanged();
|
|
4872
|
+
//entity.Merge_Data = JSON.stringify(this.mergeData);
|
|
4873
|
+
//entity.entityAspect.validateProperty(propertyName);
|
|
4870
4874
|
};
|
|
4871
4875
|
this.onDecline = () => {
|
|
4872
|
-
let entity = this.entity;
|
|
4873
|
-
let propertyName = '';
|
|
4874
|
-
this.mergeData = JSON.parse(entity.Merge_Data);
|
|
4875
|
-
let propertyNameKey = propertyName;
|
|
4876
|
-
delete this.mergeData[propertyNameKey];
|
|
4877
|
-
entity.Merge_Data = JSON.stringify(this.mergeData);
|
|
4878
|
-
entity.entityAspect.validateProperty(propertyName);
|
|
4876
|
+
//let entity = this.entity as any;
|
|
4877
|
+
//let propertyName = '';
|
|
4878
|
+
//this.mergeData = JSON.parse(entity.Merge_Data);
|
|
4879
|
+
//let propertyNameKey = propertyName as keyof typeof this.mergeData;
|
|
4880
|
+
//delete this.mergeData[propertyNameKey];
|
|
4881
|
+
//entity.Merge_Data = JSON.stringify(this.mergeData);
|
|
4882
|
+
//entity.entityAspect.validateProperty(propertyName);
|
|
4879
4883
|
};
|
|
4880
4884
|
}
|
|
4881
4885
|
ngOnInit() {
|
|
4886
|
+
this.util.findClosestAncestorByClass(this.elementRef.nativeElement, '.mat-mdc-form-field-flex').classList.add('invalid');
|
|
4887
|
+
this.errorMsg = this.config.errorMsg;
|
|
4888
|
+
}
|
|
4889
|
+
ngOnDestroy() {
|
|
4890
|
+
this.util.findClosestAncestorByClass(this.elementRef.nativeElement, '.mat-mdc-form-field-flex').classList.remove('invalid');
|
|
4882
4891
|
}
|
|
4883
4892
|
}
|
|
4884
|
-
TruValidationDialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruValidationDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4885
|
-
TruValidationDialog.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.1", type: TruValidationDialog, selector: "tru-validation-dialog", inputs: {
|
|
4893
|
+
TruValidationDialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruValidationDialog, deps: [{ token: i0.ElementRef }, { token: TruUtil }], target: i0.ɵɵFactoryTarget.Component });
|
|
4894
|
+
TruValidationDialog.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.1", type: TruValidationDialog, selector: "tru-validation-dialog", inputs: { config: "config" }, ngImport: i0, template: "<div class=\"invalid\">\r\n <i class=\"icon-warning-sign icon-white\"></i>{{config.errorMsg}}\r\n <div>\r\n <button *ngif=\"config.mergeData\" class=\"md-primary md-button ng-scope md-ink-ripple merge-button\" (click)=\"onAcceptAll()\">Accept All</button>\r\n <button *ngif=\"config.mergeData\" class=\"md-primary md-button ng-scope md-ink-ripple merge-button\" (click)=\"onAccept()\">Accept</button>\r\n <button *ngif=\"config.mergeData\" class=\"md-primary md-button ng-scope md-ink-ripple merge-button\" (click)=\"onDecline()\">Decline</button>\r\n </div>\r\n</div>\r\n<span class=\"invalid-flag\"></span>\r\n", styles: [".invalid{position:absolute;left:0;top:20px;display:none;-moz-min-width:200px;-ms-min-width:200px;-o-min-width:200px;-webkit-min-width:200px;min-width:200px;min-height:20px;max-width:500px;max-height:500px}.invalid-flag{box-sizing:border-box;position:absolute;left:0;top:0;width:8px;height:8px;border-bottom:solid 4px transparent;border-right:solid 4px transparent;border-left:solid 4px red;border-top:solid 4px red}.invalid-triangle:after{box-sizing:border-box}.invalid{background-color:#bd362f;margin:2px 0 0;padding:4px 10px;border-radius:3px!important;background-position:15px center;background-repeat:no-repeat;-ms-box-shadow:0 0 12px #999999;box-shadow:0 0 12px #999;color:#fff;-ms-opacity:.9;opacity:.9;z-index:1000}.merge-button{margin:5px;background-color:#fff}\n"] });
|
|
4886
4895
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruValidationDialog, decorators: [{
|
|
4887
4896
|
type: Component,
|
|
4888
|
-
args: [{ selector: 'tru-validation-dialog', template: "<
|
|
4889
|
-
}], ctorParameters: function () { return []; }, propDecorators: {
|
|
4890
|
-
type: Input
|
|
4891
|
-
}], mergeData: [{
|
|
4897
|
+
args: [{ selector: 'tru-validation-dialog', template: "<div class=\"invalid\">\r\n <i class=\"icon-warning-sign icon-white\"></i>{{config.errorMsg}}\r\n <div>\r\n <button *ngif=\"config.mergeData\" class=\"md-primary md-button ng-scope md-ink-ripple merge-button\" (click)=\"onAcceptAll()\">Accept All</button>\r\n <button *ngif=\"config.mergeData\" class=\"md-primary md-button ng-scope md-ink-ripple merge-button\" (click)=\"onAccept()\">Accept</button>\r\n <button *ngif=\"config.mergeData\" class=\"md-primary md-button ng-scope md-ink-ripple merge-button\" (click)=\"onDecline()\">Decline</button>\r\n </div>\r\n</div>\r\n<span class=\"invalid-flag\"></span>\r\n", styles: [".invalid{position:absolute;left:0;top:20px;display:none;-moz-min-width:200px;-ms-min-width:200px;-o-min-width:200px;-webkit-min-width:200px;min-width:200px;min-height:20px;max-width:500px;max-height:500px}.invalid-flag{box-sizing:border-box;position:absolute;left:0;top:0;width:8px;height:8px;border-bottom:solid 4px transparent;border-right:solid 4px transparent;border-left:solid 4px red;border-top:solid 4px red}.invalid-triangle:after{box-sizing:border-box}.invalid{background-color:#bd362f;margin:2px 0 0;padding:4px 10px;border-radius:3px!important;background-position:15px center;background-repeat:no-repeat;-ms-box-shadow:0 0 12px #999999;box-shadow:0 0 12px #999;color:#fff;-ms-opacity:.9;opacity:.9;z-index:1000}.merge-button{margin:5px;background-color:#fff}\n"] }]
|
|
4898
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: TruUtil }]; }, propDecorators: { config: [{
|
|
4892
4899
|
type: Input
|
|
4893
4900
|
}] } });
|
|
4894
4901
|
|
|
@@ -4906,6 +4913,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
4906
4913
|
}]
|
|
4907
4914
|
}] });
|
|
4908
4915
|
|
|
4916
|
+
class TruValidationDialogConfig {
|
|
4917
|
+
get entity() {
|
|
4918
|
+
return this._entity;
|
|
4919
|
+
}
|
|
4920
|
+
get propertyName() {
|
|
4921
|
+
return this._propertyName;
|
|
4922
|
+
}
|
|
4923
|
+
get errorMsg() {
|
|
4924
|
+
return this._errorMsg;
|
|
4925
|
+
}
|
|
4926
|
+
get mergeData() {
|
|
4927
|
+
return this._mergeData;
|
|
4928
|
+
}
|
|
4929
|
+
constructor(entity, propertyName, errorMsg, mergeData = null) {
|
|
4930
|
+
this._entity = entity;
|
|
4931
|
+
this._propertyName = propertyName;
|
|
4932
|
+
this._errorMsg = errorMsg;
|
|
4933
|
+
this._mergeData = mergeData;
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
|
|
4909
4937
|
class TruBreezeValidator {
|
|
4910
4938
|
constructor(el, dataContext, viewContainerRef, componentFactoryResolver) {
|
|
4911
4939
|
this.el = el;
|
|
@@ -4931,19 +4959,28 @@ class TruBreezeValidator {
|
|
|
4931
4959
|
}
|
|
4932
4960
|
});
|
|
4933
4961
|
if (targetProperty && targetProperty.Merge_Data) {
|
|
4934
|
-
return
|
|
4962
|
+
return targetProperty.Merge_Data_Set;
|
|
4935
4963
|
}
|
|
4964
|
+
return undefined;
|
|
4936
4965
|
}
|
|
4937
4966
|
else {
|
|
4938
|
-
return
|
|
4967
|
+
return this.entity.Merge_Data_Set;
|
|
4939
4968
|
}
|
|
4940
4969
|
};
|
|
4941
|
-
this.
|
|
4970
|
+
this.parseErrorMessages = (validationErrors) => {
|
|
4971
|
+
let errorMsg = '';
|
|
4972
|
+
validationErrors.forEach((error) => {
|
|
4973
|
+
errorMsg += error.errorMessage + '; ';
|
|
4974
|
+
});
|
|
4975
|
+
return errorMsg;
|
|
4976
|
+
};
|
|
4977
|
+
this.addValidationDialog = (config) => {
|
|
4942
4978
|
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(TruValidationDialog);
|
|
4943
4979
|
const component = this.viewContainerRef.createComponent(componentFactory, 0, this.viewContainerRef.injector);
|
|
4980
|
+
component.instance.config = config;
|
|
4944
4981
|
this.dialogRef = component;
|
|
4945
4982
|
};
|
|
4946
|
-
this.
|
|
4983
|
+
this.removeValidationDialog = () => {
|
|
4947
4984
|
if (this.dialogRef) {
|
|
4948
4985
|
this.dialogRef.destroy();
|
|
4949
4986
|
this.dialogRef = null;
|
|
@@ -4959,11 +4996,11 @@ class TruBreezeValidator {
|
|
|
4959
4996
|
let removedPropertyValdations = validationObject.removed.filter((v) => {
|
|
4960
4997
|
return v.propertyName === this.config.propertyName;
|
|
4961
4998
|
});
|
|
4962
|
-
if (addedPropertyValdations.length) {
|
|
4963
|
-
this.
|
|
4999
|
+
if (addedPropertyValdations.length || this.mergeData) {
|
|
5000
|
+
this.addValidationDialog(new TruValidationDialogConfig(this.entity, this.config.propertyName, this.parseErrorMessages(addedPropertyValdations), this.mergeData));
|
|
4964
5001
|
}
|
|
4965
5002
|
else if (!addedPropertyValdations.length && removedPropertyValdations.length) {
|
|
4966
|
-
this.
|
|
5003
|
+
this.removeValidationDialog();
|
|
4967
5004
|
}
|
|
4968
5005
|
}
|
|
4969
5006
|
};
|