runningTree对remove的一个小bug去除
This commit is contained in:
parent
8ebf5c1bea
commit
824852f729
|
|
@ -165,12 +165,12 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict, Cxt ext
|
|||
addNamedSorter<T extends keyof ED>(path: string, sorter: NamedSorterItem<ED, T>, refresh?: boolean): Promise<void>;
|
||||
removeNamedSorter<T extends keyof ED>(path: string, sorter: NamedSorterItem<ED, T>, refresh?: boolean): Promise<void>;
|
||||
removeNamedSorterByName<T extends keyof ED>(path: string, name: string, refresh?: boolean): Promise<void>;
|
||||
testAction(path: string, action?: string, execute?: boolean): Promise<{
|
||||
testAction(path: string, action: string, execute?: boolean): Promise<{
|
||||
node: SingleNode<ED, keyof ED, Cxt, AD> | ListNode<ED, keyof ED, Cxt, AD>;
|
||||
operation: DeduceOperation<ED[keyof ED]["Schema"]> | DeduceOperation<ED[keyof ED]["Schema"]>[];
|
||||
}>;
|
||||
private beforeExecute;
|
||||
execute(path: string, action?: string): Promise<DeduceOperation<ED[keyof ED]["Schema"]> | DeduceOperation<ED[keyof ED]["Schema"]>[]>;
|
||||
execute(path: string, action: string): Promise<DeduceOperation<ED[keyof ED]["Schema"]> | DeduceOperation<ED[keyof ED]["Schema"]>[]>;
|
||||
pushNode<T extends keyof ED>(path: string, options: Pick<CreateNodeOptions<ED, T>, 'updateData' | 'beforeExecute' | 'afterExecute'>): Promise<SingleNode<ED, keyof ED, Cxt, AD>>;
|
||||
removeNode(parent: string, path: string): Promise<void>;
|
||||
resetUpdateData(path: string): void;
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ var ListNode = /** @class */ (function (_super) {
|
|||
if (action) {
|
||||
(0, assert_1.assert)(action === 'create'); // 在list页面测试create是否允许?
|
||||
return [2 /*return*/, {
|
||||
id: this.dirty,
|
||||
id: 'dummy',
|
||||
action: action,
|
||||
data: {},
|
||||
}];
|
||||
|
|
@ -2368,52 +2368,59 @@ var RunningTree = /** @class */ (function (_super) {
|
|||
switch (_b.label) {
|
||||
case 0:
|
||||
node = this.findNode(path);
|
||||
if (!execute) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, this.beforeExecute(node, action)];
|
||||
if (!execute) return [3 /*break*/, 4];
|
||||
if (!!node.isDirty()) return [3 /*break*/, 2];
|
||||
// remove会出现这样的情况,create和update似乎也不是完全没有可能
|
||||
return [4 /*yield*/, node.setDirty()];
|
||||
case 1:
|
||||
// remove会出现这样的情况,create和update似乎也不是完全没有可能
|
||||
_b.sent();
|
||||
_b.label = 2;
|
||||
case 2: return [4 /*yield*/, node.composeOperation(action, execute)];
|
||||
case 2: return [4 /*yield*/, this.beforeExecute(node, action)];
|
||||
case 3:
|
||||
operation = _b.sent();
|
||||
if (!(operation instanceof Array)) return [3 /*break*/, 12];
|
||||
_b.label = 4;
|
||||
case 4:
|
||||
_b.trys.push([4, 9, 10, 11]);
|
||||
operation_2 = tslib_1.__values(operation), operation_2_1 = operation_2.next();
|
||||
_b.label = 5;
|
||||
case 5:
|
||||
if (!!operation_2_1.done) return [3 /*break*/, 8];
|
||||
oper = operation_2_1.value;
|
||||
return [4 /*yield*/, this.cache.operate(node.getEntity(), oper)];
|
||||
case 6:
|
||||
_b.sent();
|
||||
_b.label = 4;
|
||||
case 4: return [4 /*yield*/, node.composeOperation(action, execute)];
|
||||
case 5:
|
||||
operation = _b.sent();
|
||||
if (!(operation instanceof Array)) return [3 /*break*/, 14];
|
||||
_b.label = 6;
|
||||
case 6:
|
||||
_b.trys.push([6, 11, 12, 13]);
|
||||
operation_2 = tslib_1.__values(operation), operation_2_1 = operation_2.next();
|
||||
_b.label = 7;
|
||||
case 7:
|
||||
operation_2_1 = operation_2.next();
|
||||
return [3 /*break*/, 5];
|
||||
case 8: return [3 /*break*/, 11];
|
||||
if (!!operation_2_1.done) return [3 /*break*/, 10];
|
||||
oper = operation_2_1.value;
|
||||
return [4 /*yield*/, this.cache.operate(node.getEntity(), oper)];
|
||||
case 8:
|
||||
_b.sent();
|
||||
_b.label = 9;
|
||||
case 9:
|
||||
operation_2_1 = operation_2.next();
|
||||
return [3 /*break*/, 7];
|
||||
case 10: return [3 /*break*/, 13];
|
||||
case 11:
|
||||
e_19_1 = _b.sent();
|
||||
e_19 = { error: e_19_1 };
|
||||
return [3 /*break*/, 11];
|
||||
case 10:
|
||||
return [3 /*break*/, 13];
|
||||
case 12:
|
||||
try {
|
||||
if (operation_2_1 && !operation_2_1.done && (_a = operation_2.return)) _a.call(operation_2);
|
||||
}
|
||||
finally { if (e_19) throw e_19.error; }
|
||||
return [7 /*endfinally*/];
|
||||
case 11: return [3 /*break*/, 15];
|
||||
case 12:
|
||||
if (!operation) return [3 /*break*/, 14];
|
||||
return [4 /*yield*/, this.cache.operate(node.getEntity(), operation)];
|
||||
case 13:
|
||||
_b.sent();
|
||||
return [3 /*break*/, 15];
|
||||
case 13: return [3 /*break*/, 17];
|
||||
case 14:
|
||||
if (!operation) return [3 /*break*/, 16];
|
||||
return [4 /*yield*/, this.cache.operate(node.getEntity(), operation)];
|
||||
case 15:
|
||||
_b.sent();
|
||||
return [3 /*break*/, 17];
|
||||
case 16:
|
||||
(0, assert_1.assert)(false);
|
||||
_b.label = 15;
|
||||
case 15: return [2 /*return*/, {
|
||||
_b.label = 17;
|
||||
case 17: return [2 /*return*/, {
|
||||
node: node,
|
||||
operation: operation,
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ export declare type OakCommonComponentMethods<ED extends EntityDict & BaseEntity
|
|||
setUniqueForeignKeys: (ids: string[], goBackDelta?: number) => Promise<void>;
|
||||
setAction: (action: ED[T]['Action'], path?: string) => Promise<void>;
|
||||
toggleNode: (nodeData: Record<string, any>, checked: boolean, path?: string) => Promise<void>;
|
||||
execute: (action?: ED[T]['Action'], legalExceptions?: Array<string>, path?: string) => Promise<DeduceOperation<ED[T]['Schema']> | DeduceOperation<ED[T]['Schema']>[] | undefined>;
|
||||
execute: (action: ED[T]['Action'], legalExceptions?: Array<string>, path?: string) => Promise<DeduceOperation<ED[T]['Schema']> | DeduceOperation<ED[T]['Schema']>[] | undefined>;
|
||||
};
|
||||
export declare type OakListComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||
pushNode: (path?: string, options?: Pick<CreateNodeOptions<ED, keyof ED>, 'updateData' | 'beforeExecute' | 'afterExecute'>) => Promise<void>;
|
||||
|
|
|
|||
|
|
@ -551,7 +551,7 @@ class ListNode<
|
|||
if (action) {
|
||||
assert(action === 'create'); // 在list页面测试create是否允许?
|
||||
return {
|
||||
id: this.dirty!,
|
||||
id: 'dummy',
|
||||
action,
|
||||
data: {},
|
||||
};
|
||||
|
|
@ -1938,9 +1938,13 @@ export class RunningTree<
|
|||
}
|
||||
}
|
||||
|
||||
async testAction(path: string, action?: string, execute?: boolean) {
|
||||
async testAction(path: string, action: string, execute?: boolean) {
|
||||
const node = this.findNode(path);
|
||||
if (execute) {
|
||||
if (!node.isDirty()) {
|
||||
// remove会出现这样的情况,create和update似乎也不是完全没有可能
|
||||
await node.setDirty();
|
||||
}
|
||||
await this.beforeExecute(node, action);
|
||||
}
|
||||
const operation = await node.composeOperation(action, execute);
|
||||
|
|
@ -1998,7 +2002,7 @@ export class RunningTree<
|
|||
}
|
||||
|
||||
@Action
|
||||
async execute(path: string, action?: string) {
|
||||
async execute(path: string, action: string) {
|
||||
const { node, operation } = await this.testAction(path, action, true);
|
||||
|
||||
await this.getAspectWrapper().exec('operate', {
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ export type OakCommonComponentMethods<ED extends EntityDict & BaseEntityDict, T
|
|||
path?: string
|
||||
) => Promise<void>;
|
||||
execute: (
|
||||
action?: ED[T]['Action'],
|
||||
action: ED[T]['Action'],
|
||||
legalExceptions?: Array<string>,
|
||||
path?: string
|
||||
) => Promise<
|
||||
|
|
|
|||
Loading…
Reference in New Issue