@trudb/tru-common-lib 0.0.336 → 0.0.338
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/directives/breeze-validator/tru-breeze-validator.mjs +50 -34
- package/esm2020/lib/services/tru-data-context.mjs +2 -2
- package/fesm2015/trudb-tru-common-lib.mjs +51 -35
- package/fesm2015/trudb-tru-common-lib.mjs.map +1 -1
- package/fesm2020/trudb-tru-common-lib.mjs +50 -34
- package/fesm2020/trudb-tru-common-lib.mjs.map +1 -1
- package/lib/directives/breeze-validator/tru-breeze-validator.d.ts +8 -3
- package/lib/services/tru-data-context.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1475,7 +1475,7 @@ class TruDataContext {
|
|
|
1475
1475
|
this.uiNotification = uiNotification;
|
|
1476
1476
|
this._pendingDeleteEntities = [];
|
|
1477
1477
|
this._pendingCascadeDeleteEntities = [];
|
|
1478
|
-
this.
|
|
1478
|
+
this.validationChangeDetection = new Observable((observer) => {
|
|
1479
1479
|
this.entityManager.validationErrorsChanged.subscribe(entities => {
|
|
1480
1480
|
observer.next(entities);
|
|
1481
1481
|
});
|
|
@@ -4913,45 +4913,61 @@ class TruBreezeValidator {
|
|
|
4913
4913
|
this.viewContainerRef = viewContainerRef;
|
|
4914
4914
|
this.componentFactoryResolver = componentFactoryResolver;
|
|
4915
4915
|
this.configModel = {};
|
|
4916
|
+
this.dialogRef = null;
|
|
4916
4917
|
this.subs = [];
|
|
4917
|
-
this.
|
|
4918
|
-
if (
|
|
4919
|
-
this.
|
|
4920
|
-
|
|
4921
|
-
let
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
let targetProperty;
|
|
4931
|
-
propertyNameParts.forEach((name) => {
|
|
4932
|
-
if (!targetProperty) {
|
|
4933
|
-
let targetPropertyName = 'o' + name;
|
|
4934
|
-
targetProperty = this.entity[targetPropertyName];
|
|
4935
|
-
}
|
|
4936
|
-
else {
|
|
4937
|
-
let targetPropertyName = 'o' + name;
|
|
4938
|
-
targetProperty = targetProperty[targetPropertyName];
|
|
4939
|
-
}
|
|
4940
|
-
});
|
|
4941
|
-
if (targetProperty && targetProperty.Merge_Data) {
|
|
4942
|
-
this.mergeData = JSON.parse(targetProperty.Merge_Data);
|
|
4918
|
+
this.getMergeData = () => {
|
|
4919
|
+
if (this.config.propertyPath?.includes('/')) {
|
|
4920
|
+
let propertyNameParts = this.config.propertyPath.split('/');
|
|
4921
|
+
propertyNameParts.pop();
|
|
4922
|
+
let targetProperty;
|
|
4923
|
+
propertyNameParts.forEach((name) => {
|
|
4924
|
+
if (!targetProperty) {
|
|
4925
|
+
let targetPropertyName = 'o' + name;
|
|
4926
|
+
targetProperty = this.entity[targetPropertyName];
|
|
4927
|
+
}
|
|
4928
|
+
else {
|
|
4929
|
+
let targetPropertyName = 'o' + name;
|
|
4930
|
+
targetProperty = targetProperty[targetPropertyName];
|
|
4943
4931
|
}
|
|
4932
|
+
});
|
|
4933
|
+
if (targetProperty && targetProperty.Merge_Data) {
|
|
4934
|
+
return JSON.parse(targetProperty.Merge_Data);
|
|
4944
4935
|
}
|
|
4945
|
-
|
|
4946
|
-
|
|
4936
|
+
}
|
|
4937
|
+
else {
|
|
4938
|
+
return JSON.parse(this.entity.Merge_Data);
|
|
4939
|
+
}
|
|
4940
|
+
};
|
|
4941
|
+
this.addValidation = (propertyValidations) => {
|
|
4942
|
+
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(TruValidationDialog);
|
|
4943
|
+
const component = this.viewContainerRef.createComponent(componentFactory, 0, this.viewContainerRef.injector);
|
|
4944
|
+
this.dialogRef = component;
|
|
4945
|
+
};
|
|
4946
|
+
this.removeValidation = () => {
|
|
4947
|
+
if (this.dialogRef) {
|
|
4948
|
+
this.viewContainerRef.remove(this.viewContainerRef.indexOf(this.dialogRef.instance));
|
|
4949
|
+
this.dialogRef = null;
|
|
4950
|
+
}
|
|
4951
|
+
};
|
|
4952
|
+
this.valErrsChanged = (validationObject) => {
|
|
4953
|
+
let validationTableName = validationObject.entity.constructor.name;
|
|
4954
|
+
if (this.config.rootTable === validationTableName) {
|
|
4955
|
+
let addedPropertyValdations = validationObject.added.find((v) => { v.propertyName === this.config.propertyName; });
|
|
4956
|
+
let removedPropertyValdations = validationObject.removed.find((v) => { v.propertyName === this.config.propertyName; });
|
|
4957
|
+
if (addedPropertyValdations.length) {
|
|
4958
|
+
this.addValidation(addedPropertyValdations);
|
|
4947
4959
|
}
|
|
4948
|
-
|
|
4949
|
-
|
|
4960
|
+
else if (!addedPropertyValdations.length && removedPropertyValdations.length) {
|
|
4961
|
+
this.removeValidation();
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
if (this.config.rootTable === validationTableName) {
|
|
4965
|
+
this.mergeData = this.getMergeData();
|
|
4950
4966
|
}
|
|
4951
4967
|
};
|
|
4952
4968
|
}
|
|
4953
4969
|
ngOnInit() {
|
|
4954
|
-
this.subs.push(this.dataContext.
|
|
4970
|
+
this.subs.push(this.dataContext.validationChangeDetection.subscribe(entities => {
|
|
4955
4971
|
console.log(entities);
|
|
4956
4972
|
this.valErrsChanged(entities);
|
|
4957
4973
|
}));
|
|
@@ -4961,7 +4977,7 @@ class TruBreezeValidator {
|
|
|
4961
4977
|
}
|
|
4962
4978
|
}
|
|
4963
4979
|
TruBreezeValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruBreezeValidator, deps: [{ token: i0.ElementRef }, { token: TruDataContext }, { token: i0.ViewContainerRef }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4964
|
-
TruBreezeValidator.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: TruBreezeValidator, selector: "[truBreezeValidator]", inputs: { entity: ["truBreezeValidator", "entity"],
|
|
4980
|
+
TruBreezeValidator.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: TruBreezeValidator, selector: "[truBreezeValidator]", inputs: { entity: ["truBreezeValidator", "entity"], config: "config" }, ngImport: i0 });
|
|
4965
4981
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruBreezeValidator, decorators: [{
|
|
4966
4982
|
type: Directive,
|
|
4967
4983
|
args: [{
|
|
@@ -4970,7 +4986,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
4970
4986
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: TruDataContext }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { entity: [{
|
|
4971
4987
|
type: Input,
|
|
4972
4988
|
args: ['truBreezeValidator']
|
|
4973
|
-
}],
|
|
4989
|
+
}], config: [{
|
|
4974
4990
|
type: Input
|
|
4975
4991
|
}] } });
|
|
4976
4992
|
|