增加了isCreation方法,差别一个singleNode是不是创建动作
This commit is contained in:
parent
8deede6ed8
commit
bd1d4ce0e9
|
|
@ -125,6 +125,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
|
||||||
addChild(path: string, node: SingleNode<ED, keyof ED, Cxt, FrontCxt, AD> | ListNode<ED, keyof ED, Cxt, FrontCxt, AD>): void;
|
addChild(path: string, node: SingleNode<ED, keyof ED, Cxt, FrontCxt, AD> | ListNode<ED, keyof ED, Cxt, FrontCxt, AD>): void;
|
||||||
removeChild(path: string): void;
|
removeChild(path: string): void;
|
||||||
getFreshValue(noCascade?: boolean): Partial<ED[T]['Schema']> | undefined;
|
getFreshValue(noCascade?: boolean): Partial<ED[T]['Schema']> | undefined;
|
||||||
|
isCreation(): boolean;
|
||||||
doBeforeTrigger(): Promise<void>;
|
doBeforeTrigger(): Promise<void>;
|
||||||
doAfterTrigger(): Promise<void>;
|
doAfterTrigger(): Promise<void>;
|
||||||
create(data: Partial<Omit<ED[T]['CreateSingle']['data'], 'id'>>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>): void;
|
create(data: Partial<Omit<ED[T]['CreateSingle']['data'], 'id'>>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>): void;
|
||||||
|
|
@ -230,6 +231,7 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict, Cxt ext
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]["Operation"];
|
operation: ED[keyof ED]["Operation"];
|
||||||
}[] | undefined;
|
}[] | undefined;
|
||||||
|
isCreation(path: string): boolean;
|
||||||
execute<T extends keyof ED>(path: string, action?: ED[T]['Action']): Promise<{
|
execute<T extends keyof ED>(path: string, action?: ED[T]['Action']): Promise<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]["Operation"];
|
operation: ED[keyof ED]["Operation"];
|
||||||
|
|
|
||||||
|
|
@ -1258,13 +1258,10 @@ var SingleNode = /** @class */ (function (_super) {
|
||||||
* 似乎只有最顶层设置了id的结点的这种情况才需要刷新,
|
* 似乎只有最顶层设置了id的结点的这种情况才需要刷新,
|
||||||
* 如果是子结点,这里的id可以从父结点获得,这个操作是因为create action所引起,可以无视(userRelation/byMobile会跑出来)
|
* 如果是子结点,这里的id可以从父结点获得,这个操作是因为create action所引起,可以无视(userRelation/byMobile会跑出来)
|
||||||
*/
|
*/
|
||||||
if (this.id && this.id !== id) {
|
if (this.dirty) {
|
||||||
this.id = id;
|
throw new Error('结点没有clean之前是不能setId的');
|
||||||
if (this.operation) {
|
|
||||||
throw new Error('结点上的operation没有clean之前是不能setId的');
|
|
||||||
}
|
|
||||||
this.refresh();
|
|
||||||
}
|
}
|
||||||
|
this.id = id;
|
||||||
};
|
};
|
||||||
SingleNode.prototype.unsetId = function () {
|
SingleNode.prototype.unsetId = function () {
|
||||||
this.id = undefined;
|
this.id = undefined;
|
||||||
|
|
@ -1306,6 +1303,10 @@ var SingleNode = /** @class */ (function (_super) {
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
SingleNode.prototype.isCreation = function () {
|
||||||
|
var _a;
|
||||||
|
return ((_a = this.operation) === null || _a === void 0 ? void 0 : _a.operation.action) === 'create';
|
||||||
|
};
|
||||||
SingleNode.prototype.doBeforeTrigger = function () {
|
SingleNode.prototype.doBeforeTrigger = function () {
|
||||||
var _a;
|
var _a;
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
|
|
@ -2218,6 +2219,11 @@ var RunningTree = /** @class */ (function (_super) {
|
||||||
var operations = node.composeOperations();
|
var operations = node.composeOperations();
|
||||||
return operations;
|
return operations;
|
||||||
};
|
};
|
||||||
|
RunningTree.prototype.isCreation = function (path) {
|
||||||
|
var node = this.findNode(path);
|
||||||
|
(0, assert_1.assert)(node instanceof SingleNode);
|
||||||
|
return node.isCreation();
|
||||||
|
};
|
||||||
RunningTree.prototype.execute = function (path, action) {
|
RunningTree.prototype.execute = function (path, action) {
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
var node, operations, entities, err_3;
|
var node, operations, entities, err_3;
|
||||||
|
|
|
||||||
|
|
@ -388,6 +388,12 @@ var oakBehavior = Behavior({
|
||||||
unsetId: function () {
|
unsetId: function () {
|
||||||
return this.features.runningTree.unsetId(this.state.oakFullpath);
|
return this.features.runningTree.unsetId(this.state.oakFullpath);
|
||||||
},
|
},
|
||||||
|
isCreation: function (path) {
|
||||||
|
var path2 = path
|
||||||
|
? "".concat(this.state.oakFullpath, ".").concat(path)
|
||||||
|
: this.state.oakFullpath;
|
||||||
|
return this.features.runningTree.isCreation(path2);
|
||||||
|
},
|
||||||
update: function (data, action, beforeExecute, afterExecute, path) {
|
update: function (data, action, beforeExecute, afterExecute, path) {
|
||||||
var path2 = path ? "".concat(this.state.oakFullpath, ".").concat(path) : this.state.oakFullpath;
|
var path2 = path ? "".concat(this.state.oakFullpath, ".").concat(path) : this.state.oakFullpath;
|
||||||
return this.features.runningTree.update(path2, data, action, beforeExecute, afterExecute);
|
return this.features.runningTree.update(path2, data, action, beforeExecute, afterExecute);
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,12 @@ var OakComponentBase = /** @class */ (function (_super) {
|
||||||
/* create<T extends keyof ED>(data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) {
|
/* create<T extends keyof ED>(data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) {
|
||||||
this.features.runningTree.create(this.state.oakFullpath, data, beforeExecute, afterExecute);
|
this.features.runningTree.create(this.state.oakFullpath, data, beforeExecute, afterExecute);
|
||||||
} */
|
} */
|
||||||
|
OakComponentBase.prototype.isCreation = function (path) {
|
||||||
|
var path2 = path
|
||||||
|
? "".concat(this.state.oakFullpath, ".").concat(path)
|
||||||
|
: this.state.oakFullpath;
|
||||||
|
return this.features.runningTree.isCreation(path2);
|
||||||
|
};
|
||||||
OakComponentBase.prototype.update = function (data, action, beforeExecute, afterExecute, path) {
|
OakComponentBase.prototype.update = function (data, action, beforeExecute, afterExecute, path) {
|
||||||
var path2 = path
|
var path2 = path
|
||||||
? "".concat(this.state.oakFullpath, ".").concat(path)
|
? "".concat(this.state.oakFullpath, ".").concat(path)
|
||||||
|
|
@ -510,6 +516,9 @@ function createComponent(option, features) {
|
||||||
remove: function (beforeExecute, afterExecute, path) {
|
remove: function (beforeExecute, afterExecute, path) {
|
||||||
return _this.remove(beforeExecute, afterExecute, path);
|
return _this.remove(beforeExecute, afterExecute, path);
|
||||||
},
|
},
|
||||||
|
isCreation: function (path) {
|
||||||
|
return _this.isCreation(path);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (methods) {
|
if (methods) {
|
||||||
var _loop_1 = function (m) {
|
var _loop_1 = function (m) {
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ export declare type OakSingleComponentMethods<ED extends EntityDict & BaseEntity
|
||||||
getId: () => string | undefined;
|
getId: () => string | undefined;
|
||||||
update: (data: ED[T]['Update']['data'], action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
update: (data: ED[T]['Update']['data'], action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
||||||
remove: (beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
remove: (beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
||||||
|
isCreation: (path?: string) => boolean;
|
||||||
};
|
};
|
||||||
export declare type OakListComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
export declare type OakListComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||||
loadMore: () => Promise<void>;
|
loadMore: () => Promise<void>;
|
||||||
|
|
@ -233,7 +234,7 @@ export declare type OakListComoponetData<ED extends EntityDict & BaseEntityDict,
|
||||||
export declare type MakeOakComponent<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>> = <T extends keyof ED, FormedData extends DataOption, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption, TMethod extends MethodOption>(options: OakComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>) => React.ComponentType<any>;
|
export declare type MakeOakComponent<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>> = <T extends keyof ED, FormedData extends DataOption, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption, TMethod extends MethodOption>(options: OakComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>) => React.ComponentType<any>;
|
||||||
export declare type WebComponentCommonMethodNames = 'setNotification' | 'setMessage' | 'navigateTo' | 'navigateBack' | 'redirectTo' | 'clean' | 't' | 'execute' | 'refresh' | 'setDisablePulldownRefresh' | 'aggregate' | 'checkOperation';
|
export declare type WebComponentCommonMethodNames = 'setNotification' | 'setMessage' | 'navigateTo' | 'navigateBack' | 'redirectTo' | 'clean' | 't' | 'execute' | 'refresh' | 'setDisablePulldownRefresh' | 'aggregate' | 'checkOperation';
|
||||||
export declare type WebComponentListMethodNames = 'loadMore' | 'setFilters' | 'addNamedFilter' | 'removeNamedFilter' | 'removeNamedFilterByName' | 'setNamedSorters' | 'addNamedSorter' | 'removeNamedSorter' | 'removeNamedSorterByName' | 'setPageSize' | 'setCurrentPage' | 'addItem' | 'removeItem' | 'updateItem';
|
export declare type WebComponentListMethodNames = 'loadMore' | 'setFilters' | 'addNamedFilter' | 'removeNamedFilter' | 'removeNamedFilterByName' | 'setNamedSorters' | 'addNamedSorter' | 'removeNamedSorter' | 'removeNamedSorterByName' | 'setPageSize' | 'setCurrentPage' | 'addItem' | 'removeItem' | 'updateItem';
|
||||||
export declare type WebComponentSingleMethodNames = 'update' | 'remove';
|
export declare type WebComponentSingleMethodNames = 'update' | 'remove' | 'isCreation';
|
||||||
export declare type WebComponentProps<ED extends EntityDict & BaseEntityDict, T extends keyof ED, IsList extends boolean, TData extends DataOption = {}, TMethod extends MethodOption = {}> = {
|
export declare type WebComponentProps<ED extends EntityDict & BaseEntityDict, T extends keyof ED, IsList extends boolean, TData extends DataOption = {}, TMethod extends MethodOption = {}> = {
|
||||||
methods: TMethod & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
methods: TMethod & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
||||||
data: TData & OakComponentData<ED, T> & (IsList extends true ? OakListComoponetData<ED, T> : {});
|
data: TData & OakComponentData<ED, T> & (IsList extends true ? OakListComoponetData<ED, T> : {});
|
||||||
|
|
|
||||||
|
|
@ -1267,13 +1267,10 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
||||||
* 似乎只有最顶层设置了id的结点的这种情况才需要刷新,
|
* 似乎只有最顶层设置了id的结点的这种情况才需要刷新,
|
||||||
* 如果是子结点,这里的id可以从父结点获得,这个操作是因为create action所引起,可以无视(userRelation/byMobile会跑出来)
|
* 如果是子结点,这里的id可以从父结点获得,这个操作是因为create action所引起,可以无视(userRelation/byMobile会跑出来)
|
||||||
*/
|
*/
|
||||||
if (this.id && this.id !== id) {
|
if (this.dirty) {
|
||||||
this.id = id;
|
throw new Error('结点没有clean之前是不能setId的');
|
||||||
if (this.operation) {
|
|
||||||
throw new Error('结点上的operation没有clean之前是不能setId的');
|
|
||||||
}
|
|
||||||
this.refresh();
|
|
||||||
}
|
}
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsetId() {
|
unsetId() {
|
||||||
|
|
@ -1328,6 +1325,10 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCreation() {
|
||||||
|
return this.operation?.operation.action === 'create';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async doBeforeTrigger(): Promise<void> {
|
async doBeforeTrigger(): Promise<void> {
|
||||||
if (this.operation?.beforeExecute) {
|
if (this.operation?.beforeExecute) {
|
||||||
|
|
@ -2250,6 +2251,12 @@ export class RunningTree<
|
||||||
return operations;
|
return operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCreation(path: string) {
|
||||||
|
const node = this.findNode(path)!;
|
||||||
|
assert(node instanceof SingleNode);
|
||||||
|
return node.isCreation();
|
||||||
|
}
|
||||||
|
|
||||||
async execute<T extends keyof ED>(path: string, action?: ED[T]['Action']) {
|
async execute<T extends keyof ED>(path: string, action?: ED[T]['Action']) {
|
||||||
const node = this.findNode(path)!;
|
const node = this.findNode(path)!;
|
||||||
if (action) {
|
if (action) {
|
||||||
|
|
|
||||||
|
|
@ -50,17 +50,17 @@ const oakBehavior = Behavior<
|
||||||
DataOption,
|
DataOption,
|
||||||
WechatMiniprogram.Component.PropertyOption,
|
WechatMiniprogram.Component.PropertyOption,
|
||||||
OakCommonComponentMethods<EDD, keyof EDD> &
|
OakCommonComponentMethods<EDD, keyof EDD> &
|
||||||
OakListComponentMethods<EDD, keyof EDD> &
|
OakListComponentMethods<EDD, keyof EDD> &
|
||||||
OakSingleComponentMethods<EDD, keyof EDD> & {
|
OakSingleComponentMethods<EDD, keyof EDD> & {
|
||||||
iAmThePage: () => boolean;
|
iAmThePage: () => boolean;
|
||||||
setState: (
|
setState: (
|
||||||
data: Record<string, any>,
|
data: Record<string, any>,
|
||||||
callback?: () => void
|
callback?: () => void
|
||||||
) => void;
|
) => void;
|
||||||
onLoad: (query: Record<string, any>) => Promise<void>;
|
onLoad: (query: Record<string, any>) => Promise<void>;
|
||||||
onPullDownRefresh: () => Promise<void>;
|
onPullDownRefresh: () => Promise<void>;
|
||||||
onReachBottom: () => Promise<void>;
|
onReachBottom: () => Promise<void>;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: Record<string, any>;
|
state: Record<string, any>;
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -81,7 +81,7 @@ const oakBehavior = Behavior<
|
||||||
FrontCxt,
|
FrontCxt,
|
||||||
ADD & CommonAspectDict<EDD, Cxt>
|
ADD & CommonAspectDict<EDD, Cxt>
|
||||||
> &
|
> &
|
||||||
FDD;
|
FDD;
|
||||||
subscribed: Array<() => void>;
|
subscribed: Array<() => void>;
|
||||||
oakOption: OakComponentOption<
|
oakOption: OakComponentOption<
|
||||||
EDD,
|
EDD,
|
||||||
|
|
@ -364,7 +364,7 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
setFilters(filters, path) {
|
setFilters(filters, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.setNamedFilters(
|
this.features.runningTree.setNamedFilters(
|
||||||
path2,
|
path2,
|
||||||
filters
|
filters
|
||||||
|
|
@ -373,7 +373,7 @@ const oakBehavior = Behavior<
|
||||||
|
|
||||||
getFilters(path) {
|
getFilters(path) {
|
||||||
if (this.state.oakFullpath) {
|
if (this.state.oakFullpath) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
const namedFilters = this.features.runningTree.getNamedFilters(
|
const namedFilters = this.features.runningTree.getNamedFilters(
|
||||||
this.state.oakFullpath
|
this.state.oakFullpath
|
||||||
);
|
);
|
||||||
|
|
@ -388,7 +388,7 @@ const oakBehavior = Behavior<
|
||||||
|
|
||||||
getFilterByName(name, path) {
|
getFilterByName(name, path) {
|
||||||
if (this.state.oakFullpath) {
|
if (this.state.oakFullpath) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
const filter = this.features.runningTree.getNamedFilterByName(
|
const filter = this.features.runningTree.getNamedFilterByName(
|
||||||
path2,
|
path2,
|
||||||
name
|
name
|
||||||
|
|
@ -403,7 +403,7 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
addNamedFilter(namedFilter, refresh, path) {
|
addNamedFilter(namedFilter, refresh, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.addNamedFilter(
|
this.features.runningTree.addNamedFilter(
|
||||||
path2,
|
path2,
|
||||||
namedFilter,
|
namedFilter,
|
||||||
|
|
@ -412,7 +412,7 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
removeNamedFilter(namedFilter, refresh, path) {
|
removeNamedFilter(namedFilter, refresh, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.removeNamedFilter(
|
this.features.runningTree.removeNamedFilter(
|
||||||
path2,
|
path2,
|
||||||
namedFilter,
|
namedFilter,
|
||||||
|
|
@ -421,7 +421,7 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
removeNamedFilterByName(name, refresh, path) {
|
removeNamedFilterByName(name, refresh, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.removeNamedFilterByName(
|
this.features.runningTree.removeNamedFilterByName(
|
||||||
path2,
|
path2,
|
||||||
name,
|
name,
|
||||||
|
|
@ -430,7 +430,7 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
setNamedSorters(namedSorters, path) {
|
setNamedSorters(namedSorters, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.setNamedSorters(
|
this.features.runningTree.setNamedSorters(
|
||||||
path2,
|
path2,
|
||||||
namedSorters
|
namedSorters
|
||||||
|
|
@ -439,7 +439,7 @@ const oakBehavior = Behavior<
|
||||||
|
|
||||||
getSorters(path) {
|
getSorters(path) {
|
||||||
if (this.state.oakFullpath) {
|
if (this.state.oakFullpath) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
const namedSorters = this.features.runningTree.getNamedSorters(path2);
|
const namedSorters = this.features.runningTree.getNamedSorters(path2);
|
||||||
const sorters = namedSorters
|
const sorters = namedSorters
|
||||||
.map(({ sorter }) => {
|
.map(({ sorter }) => {
|
||||||
|
|
@ -455,7 +455,7 @@ const oakBehavior = Behavior<
|
||||||
|
|
||||||
getSorterByName(name, path) {
|
getSorterByName(name, path) {
|
||||||
if (this.state.oakFullpath) {
|
if (this.state.oakFullpath) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
const sorter = this.features.runningTree.getNamedSorterByName(
|
const sorter = this.features.runningTree.getNamedSorterByName(
|
||||||
path2,
|
path2,
|
||||||
name
|
name
|
||||||
|
|
@ -470,12 +470,12 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
addNamedSorter(namedSorter, refresh, path) {
|
addNamedSorter(namedSorter, refresh, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.addNamedSorter(path2, namedSorter, refresh);
|
this.features.runningTree.addNamedSorter(path2, namedSorter, refresh);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeNamedSorter(namedSorter, refresh, path) {
|
removeNamedSorter(namedSorter, refresh, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.removeNamedSorter(
|
this.features.runningTree.removeNamedSorter(
|
||||||
path2,
|
path2,
|
||||||
namedSorter,
|
namedSorter,
|
||||||
|
|
@ -484,19 +484,19 @@ const oakBehavior = Behavior<
|
||||||
},
|
},
|
||||||
|
|
||||||
removeNamedSorterByName(name, refresh, path) {
|
removeNamedSorterByName(name, refresh, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.removeNamedSorterByName(path2, name, refresh);
|
this.features.runningTree.removeNamedSorterByName(path2, name, refresh);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPagination(path) {
|
getPagination(path) {
|
||||||
if (this.state.oakFullpath) {
|
if (this.state.oakFullpath) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
return this.features.runningTree.getPagination(path2);
|
return this.features.runningTree.getPagination(path2);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setPageSize(pageSize, path) {
|
setPageSize(pageSize, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.setPageSize(
|
this.features.runningTree.setPageSize(
|
||||||
path2,
|
path2,
|
||||||
pageSize
|
pageSize
|
||||||
|
|
@ -507,7 +507,7 @@ const oakBehavior = Behavior<
|
||||||
assert(currentPage !== 0);
|
assert(currentPage !== 0);
|
||||||
|
|
||||||
if (this.state.oakEntity && this.state.oakFullpath) {
|
if (this.state.oakEntity && this.state.oakFullpath) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
this.features.runningTree.setCurrentPage(
|
this.features.runningTree.setCurrentPage(
|
||||||
path2,
|
path2,
|
||||||
currentPage
|
currentPage
|
||||||
|
|
@ -515,7 +515,7 @@ const oakBehavior = Behavior<
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addItem(data, beforeExecute, afterExecute, path) {
|
addItem(data, beforeExecute, afterExecute, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
return this.features.runningTree.addItem(
|
return this.features.runningTree.addItem(
|
||||||
path2,
|
path2,
|
||||||
data,
|
data,
|
||||||
|
|
@ -524,7 +524,7 @@ const oakBehavior = Behavior<
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
updateItem(data, id, action, beforeExecute, afterExecute, path) {
|
updateItem(data, id, action, beforeExecute, afterExecute, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
return this.features.runningTree.updateItem(
|
return this.features.runningTree.updateItem(
|
||||||
path2,
|
path2,
|
||||||
data,
|
data,
|
||||||
|
|
@ -535,7 +535,7 @@ const oakBehavior = Behavior<
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
removeItem(id, beforeExecute, afterExecute, path) {
|
removeItem(id, beforeExecute, afterExecute, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
return this.features.runningTree.removeItem(
|
return this.features.runningTree.removeItem(
|
||||||
path2,
|
path2,
|
||||||
id,
|
id,
|
||||||
|
|
@ -544,7 +544,7 @@ const oakBehavior = Behavior<
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
recoverItem(id, path) {
|
recoverItem(id, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
return this.features.runningTree.recoverItem(
|
return this.features.runningTree.recoverItem(
|
||||||
path2,
|
path2,
|
||||||
id
|
id
|
||||||
|
|
@ -556,8 +556,16 @@ const oakBehavior = Behavior<
|
||||||
unsetId() {
|
unsetId() {
|
||||||
return this.features.runningTree.unsetId(this.state.oakFullpath);
|
return this.features.runningTree.unsetId(this.state.oakFullpath);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isCreation(path?: string) {
|
||||||
|
const path2 = path
|
||||||
|
? `${this.state.oakFullpath}.${path}`
|
||||||
|
: this.state.oakFullpath;
|
||||||
|
return this.features.runningTree.isCreation(path2);
|
||||||
|
},
|
||||||
|
|
||||||
update(data, action, beforeExecute, afterExecute, path) {
|
update(data, action, beforeExecute, afterExecute, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
return this.features.runningTree.update(
|
return this.features.runningTree.update(
|
||||||
path2,
|
path2,
|
||||||
data,
|
data,
|
||||||
|
|
@ -567,7 +575,7 @@ const oakBehavior = Behavior<
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
remove(beforeExecute, afterExecute, path) {
|
remove(beforeExecute, afterExecute, path) {
|
||||||
const path2 = path? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath;
|
||||||
return this.features.runningTree.remove(
|
return this.features.runningTree.remove(
|
||||||
path2,
|
path2,
|
||||||
beforeExecute,
|
beforeExecute,
|
||||||
|
|
@ -655,7 +663,7 @@ export function createComponent<
|
||||||
lifetimes,
|
lifetimes,
|
||||||
observers,
|
observers,
|
||||||
} = option;
|
} = option;
|
||||||
const { attached, show, hide, created, detached, ready, moved, error } = lifetimes || {};
|
const { attached, show, hide, created, detached, ready, moved, error } = lifetimes || {};
|
||||||
const { options, externalClasses } = wechatMp || {};
|
const { options, externalClasses } = wechatMp || {};
|
||||||
|
|
||||||
return Component<
|
return Component<
|
||||||
|
|
@ -682,7 +690,7 @@ export function createComponent<
|
||||||
FrontCxt,
|
FrontCxt,
|
||||||
AD & CommonAspectDict<ED, Cxt>
|
AD & CommonAspectDict<ED, Cxt>
|
||||||
> &
|
> &
|
||||||
FD;
|
FD;
|
||||||
subscribed: Array<() => void>;
|
subscribed: Array<() => void>;
|
||||||
oakOption: OakComponentOption<
|
oakOption: OakComponentOption<
|
||||||
ED,
|
ED,
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,13 @@ abstract class OakComponentBase<
|
||||||
this.features.runningTree.create(this.state.oakFullpath, data, beforeExecute, afterExecute);
|
this.features.runningTree.create(this.state.oakFullpath, data, beforeExecute, afterExecute);
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
isCreation(path?: string) {
|
||||||
|
const path2 = path
|
||||||
|
? `${this.state.oakFullpath}.${path}`
|
||||||
|
: this.state.oakFullpath;
|
||||||
|
return this.features.runningTree.isCreation(path2);
|
||||||
|
}
|
||||||
|
|
||||||
update<T extends keyof ED>(
|
update<T extends keyof ED>(
|
||||||
data: ED[T]['Update']['data'],
|
data: ED[T]['Update']['data'],
|
||||||
action?: ED[T]['Action'],
|
action?: ED[T]['Action'],
|
||||||
|
|
@ -782,6 +789,9 @@ export function createComponent<
|
||||||
remove: (beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => {
|
remove: (beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => {
|
||||||
return this.remove(beforeExecute, afterExecute, path);
|
return this.remove(beforeExecute, afterExecute, path);
|
||||||
},
|
},
|
||||||
|
isCreation: (path?: string)=> {
|
||||||
|
return this.isCreation(path);
|
||||||
|
}
|
||||||
} as Record<WebComponentSingleMethodNames, Function>);
|
} as Record<WebComponentSingleMethodNames, Function>);
|
||||||
|
|
||||||
if (methods) {
|
if (methods) {
|
||||||
|
|
|
||||||
|
|
@ -333,6 +333,7 @@ export type OakSingleComponentMethods<ED extends EntityDict & BaseEntityDict, T
|
||||||
// create: (data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
// create: (data: Omit<ED[T]['CreateSingle']['data'], 'id'>, beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>) => void;
|
||||||
update: (data: ED[T]['Update']['data'], action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
update: (data: ED[T]['Update']['data'], action?: ED[T]['Action'], beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
||||||
remove: (beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
remove: (beforeExecute?: () => Promise<void>, afterExecute?: () => Promise<void>, path?: string) => void;
|
||||||
|
isCreation: (path?: string) => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OakListComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
export type OakListComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||||
|
|
@ -436,7 +437,7 @@ export type WebComponentListMethodNames = 'loadMore' | 'setFilters' | 'addNamedF
|
||||||
| 'addNamedSorter' | 'removeNamedSorter' | 'removeNamedSorterByName' | 'setPageSize' | 'setCurrentPage' | 'addItem' | 'removeItem' | 'updateItem';
|
| 'addNamedSorter' | 'removeNamedSorter' | 'removeNamedSorterByName' | 'setPageSize' | 'setCurrentPage' | 'addItem' | 'removeItem' | 'updateItem';
|
||||||
|
|
||||||
// 暴露给single组件的方法
|
// 暴露给single组件的方法
|
||||||
export type WebComponentSingleMethodNames = 'update' | 'remove';
|
export type WebComponentSingleMethodNames = 'update' | 'remove' | 'isCreation';
|
||||||
|
|
||||||
export type WebComponentProps<
|
export type WebComponentProps<
|
||||||
ED extends EntityDict & BaseEntityDict,
|
ED extends EntityDict & BaseEntityDict,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue