@trudb/tru-common-lib 0.2.355 → 0.2.356
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.
|
@@ -1730,6 +1730,15 @@ class TruEntityAccessor {
|
|
|
1730
1730
|
return result;
|
|
1731
1731
|
return null;
|
|
1732
1732
|
};
|
|
1733
|
+
searchByRefServerOnly = (entity, ref) => {
|
|
1734
|
+
var queryOptions = this._entityManager.queryOptions.using({
|
|
1735
|
+
fetchStrategy: FetchStrategy.FromServer
|
|
1736
|
+
});
|
|
1737
|
+
var query = this._breezeContext.createQuery(this.getQueryServiceName(entity)).where(entity.name + 'Ref', '==', ref).using(queryOptions);
|
|
1738
|
+
return defer(() => from(this._entityManager.executeQuery(query).then((queryData) => {
|
|
1739
|
+
return queryData.results[0];
|
|
1740
|
+
})));
|
|
1741
|
+
};
|
|
1733
1742
|
searchByRefArrayCacheOnly = (entity, setupQuery = null, refs, includeDeleted = false) => {
|
|
1734
1743
|
if (!includeDeleted)
|
|
1735
1744
|
includeDeleted = false;
|
|
@@ -7740,23 +7749,24 @@ class TruDataGrid {
|
|
|
7740
7749
|
//let parentName = this.entity.constructor.name;
|
|
7741
7750
|
let unassociatedType = this.config.resultConfig.entityManyToManyType;
|
|
7742
7751
|
let ref = this.selectedUnassociatedChoice.value.$;
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7752
|
+
this.dataContext.entityAccess().searchByRefServerOnly(unassociatedType, ref).subscribe((childToAssociate) => {
|
|
7753
|
+
if (!childToAssociate)
|
|
7754
|
+
childToAssociate = this.appEnvironment.globalDataContext?.entityAccess().searchByRefCacheOnly(unassociatedType, ref, true);
|
|
7755
|
+
if (childToAssociate) {
|
|
7756
|
+
let enhancedEntity = this.enhanceRowDataForEntity(newEntity);
|
|
7757
|
+
enhancedEntity.$entity[this.config.resultConfig.entityManyToManyTypeNameWithPrefix + 'Ref'] = childToAssociate[unassociatedType.name + 'Ref'];
|
|
7758
|
+
enhancedEntity.$entity[this.config.parentTableRelationshipRefName] = this.entity[this.config.parentTableRefName];
|
|
7759
|
+
// remove item from the add dropdown control
|
|
7760
|
+
let itemIndex = this.unassociatedChoices.findIndex((choice) => {
|
|
7761
|
+
return choice.value.$ === childToAssociate[unassociatedType.name + 'Ref'];
|
|
7762
|
+
});
|
|
7763
|
+
this.unassociatedChoices.splice(itemIndex, 1);
|
|
7764
|
+
// clear add selection
|
|
7765
|
+
this.selectedUnassociatedChoice = undefined;
|
|
7766
|
+
// add row to grid
|
|
7767
|
+
this.unsavedEntities.push(enhancedEntity);
|
|
7768
|
+
}
|
|
7769
|
+
});
|
|
7760
7770
|
}
|
|
7761
7771
|
};
|
|
7762
7772
|
subscribeTo = () => {
|