细化了在createNode时,根据当前node是否是modi的情况进行refresh
This commit is contained in:
parent
9ff8b30e63
commit
e8f2ec1def
|
|
@ -226,6 +226,8 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict, Cxt ext
|
|||
private relationAuth;
|
||||
constructor(cache: Cache<ED, Cxt, FrontCxt, AD>, schema: StorageSchema<ED>, relationAuth: RelationAuth<ED, Cxt, FrontCxt, AD>);
|
||||
createNode<T extends keyof ED>(options: CreateNodeOptions<ED, T>): SingleNode<ED, keyof ED, Cxt, FrontCxt, AD> | ListNode<ED, keyof ED, Cxt, FrontCxt, AD> | VirtualNode<ED, Cxt, FrontCxt, AD>;
|
||||
private checkSingleNodeIsModiNode;
|
||||
checkIsModiNode(path: string): boolean;
|
||||
private findNode;
|
||||
destroyNode(path: string): void;
|
||||
getFreshValue(path: string): Partial<ED[keyof ED]["Schema"]> | Partial<ED[keyof ED]["Schema"]>[] | undefined;
|
||||
|
|
|
|||
|
|
@ -1754,6 +1754,38 @@ var RunningTree = /** @class */ (function (_super) {
|
|||
}
|
||||
return node;
|
||||
};
|
||||
RunningTree.prototype.checkSingleNodeIsModiNode = function (node) {
|
||||
var id = node.getId();
|
||||
if (id) {
|
||||
var modies = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: node.getEntity(),
|
||||
entityId: id,
|
||||
iState: 'active',
|
||||
}
|
||||
});
|
||||
return modies.length > 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
RunningTree.prototype.checkIsModiNode = function (path) {
|
||||
if (!path.includes(exports.MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
var node = this.findNode(path);
|
||||
if (node instanceof SingleNode) {
|
||||
return this.checkSingleNodeIsModiNode(node);
|
||||
}
|
||||
else {
|
||||
(0, assert_1.assert)(node instanceof ListNode);
|
||||
var parent_1 = node.getParent();
|
||||
(0, assert_1.assert)(parent_1 instanceof SingleNode);
|
||||
return this.checkSingleNodeIsModiNode(parent_1);
|
||||
}
|
||||
};
|
||||
RunningTree.prototype.findNode = function (path) {
|
||||
if (this.root[path]) {
|
||||
return this.root[path];
|
||||
|
|
@ -1775,14 +1807,14 @@ var RunningTree = /** @class */ (function (_super) {
|
|||
var node = this.findNode(path);
|
||||
if (node) {
|
||||
var childPath = path.slice(path.lastIndexOf('.') + 1);
|
||||
var parent_1 = node.getParent();
|
||||
if (parent_1 instanceof SingleNode) {
|
||||
parent_1.removeChild(childPath);
|
||||
var parent_2 = node.getParent();
|
||||
if (parent_2 instanceof SingleNode) {
|
||||
parent_2.removeChild(childPath);
|
||||
}
|
||||
else if (parent_1 instanceof ListNode) {
|
||||
parent_1.removeChild(childPath);
|
||||
else if (parent_2 instanceof ListNode) {
|
||||
parent_2.removeChild(childPath);
|
||||
}
|
||||
else if (!parent_1) {
|
||||
else if (!parent_2) {
|
||||
(0, assert_1.assert)(this.root.hasOwnProperty(path));
|
||||
(0, lodash_1.unset)(this.root, path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ var assert_1 = require("oak-domain/lib/utils/assert");
|
|||
var lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
var relation_1 = require("oak-domain/lib/store/relation");
|
||||
var filter_1 = require("oak-domain/lib/store/filter");
|
||||
var runningTree_1 = require("./features/runningTree");
|
||||
var uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
function onPathSet(option) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
|
|
@ -128,6 +127,12 @@ function onPathSet(option) {
|
|||
case 1:
|
||||
// 确保SetState生效,这里改成异步
|
||||
_e.sent();
|
||||
if ((projection || oakProjection) && !features.runningTree.checkIsModiNode(oakPath2)) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
this.reRender();
|
||||
}
|
||||
return [3 /*break*/, 4];
|
||||
case 2:
|
||||
// 创建virtualNode
|
||||
|
|
@ -146,15 +151,9 @@ function onPathSet(option) {
|
|||
})];
|
||||
case 3:
|
||||
_e.sent();
|
||||
this.reRender();
|
||||
_e.label = 4;
|
||||
case 4:
|
||||
if (entity && (projection || oakProjection) && !(oakPath2 === null || oakPath2 === void 0 ? void 0 : oakPath2.includes(runningTree_1.MODI_NEXT_PATH_SUFFIX))) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
this.reRender();
|
||||
}
|
||||
return [2 /*return*/];
|
||||
case 4: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1429,7 +1429,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
};
|
||||
if (this.filters) {
|
||||
filter = combineFilters(this.entity, this.schema, this.filters.map(
|
||||
ele => typeof ele.filter === 'function' ? ele.filter() : ele.filter
|
||||
ele => typeof ele.filter === 'function' ? ele.filter() : ele.filter
|
||||
).concat(filter));
|
||||
}
|
||||
return filter;
|
||||
|
|
@ -1449,7 +1449,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
const value = this.getFreshValue(context);
|
||||
|
||||
if (value && value.$$createAt$$ === 1 && ignoreNewParent) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
for (const key in this.children) {
|
||||
if (childNode === this.children[key]) {
|
||||
|
|
@ -1880,6 +1880,40 @@ export class RunningTree<
|
|||
return node;
|
||||
}
|
||||
|
||||
private checkSingleNodeIsModiNode(node: SingleNode<ED, keyof ED, Cxt, FrontCxt, AD>) {
|
||||
const id = node.getId();
|
||||
if (id) {
|
||||
const modies = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: node.getEntity() as string,
|
||||
entityId: id,
|
||||
iState: 'active',
|
||||
}
|
||||
});
|
||||
return modies.length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
checkIsModiNode(path: string) {
|
||||
if (!path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
const node = this.findNode(path);
|
||||
if (node instanceof SingleNode) {
|
||||
return this.checkSingleNodeIsModiNode(node);
|
||||
}
|
||||
else {
|
||||
assert(node instanceof ListNode);
|
||||
const parent = node.getParent();
|
||||
assert(parent instanceof SingleNode);
|
||||
return this.checkSingleNodeIsModiNode(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private findNode(path: string) {
|
||||
if (this.root[path]) {
|
||||
return this.root[path];
|
||||
|
|
|
|||
|
|
@ -123,6 +123,12 @@ export async function onPathSet<
|
|||
}
|
||||
);
|
||||
|
||||
if ((projection || oakProjection) && !features.runningTree.checkIsModiNode(oakPath2)) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
this.reRender();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 创建virtualNode
|
||||
|
|
@ -146,11 +152,6 @@ export async function onPathSet<
|
|||
}, () => resolve(0));
|
||||
}
|
||||
);
|
||||
}
|
||||
if (entity && (projection || oakProjection) && !oakPath2?.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
this.reRender();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue