增加了对options中features的定义及实现
This commit is contained in:
parent
6b93deba6c
commit
2daed01a18
|
|
@ -1785,10 +1785,10 @@ var VirtualNode = /** @class */ (function (_super) {
|
||||||
if (child instanceof SingleNode || child instanceof ListNode) {
|
if (child instanceof SingleNode || child instanceof ListNode) {
|
||||||
var entity = child.getEntity();
|
var entity = child.getEntity();
|
||||||
if (child instanceof SingleNode) {
|
if (child instanceof SingleNode) {
|
||||||
(0, assert_1.assert)(path === entity || path.startsWith("".concat(entity, ":")), "oakPath\u300C".concat(path, "\u300D\u4E0D\u7B26\u5408\u547D\u540D\u89C4\u8303\uFF0C\u8BF7\u4EE5\u300C").concat(entity, "\u300D\u4E3A\u547D\u540D\u8D77\u59CB\u6807\u8BC6"));
|
(0, assert_1.assert)(path === entity || path.startsWith("".concat(entity, ":")), "oakPath\u300C".concat(path, "\u300D\u4E0D\u7B26\u5408\u547D\u540D\u89C4\u8303\uFF0C\u8BF7\u4EE5\u300C").concat(entity, ":\u300D\u4E3A\u547D\u540D\u8D77\u59CB\u6807\u8BC6"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, assert_1.assert)(path === "".concat(entity, "s") || path.startsWith("".concat(entity, "s:")), "oakPath\u300C".concat(path, "\u300D\u4E0D\u7B26\u5408\u547D\u540D\u89C4\u8303\uFF0C\u8BF7\u4EE5\u300C").concat(entity, "s\u300D\u4E3A\u547D\u540D\u8D77\u59CB\u6807\u8BC6"));
|
(0, assert_1.assert)(path === "".concat(entity, "s") || path.startsWith("".concat(entity, "s:")), "oakPath\u300C".concat(path, "\u300D\u4E0D\u7B26\u5408\u547D\u540D\u89C4\u8303\uFF0C\u8BF7\u4EE5\u300C").concat(entity, "s:\u300D\u4E3A\u547D\u540D\u8D77\u59CB\u6807\u8BC6"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -505,6 +505,9 @@ function createComponent(option, features) {
|
||||||
if (option.entity) {
|
if (option.entity) {
|
||||||
this.subscribed.push(features.cache.subscribe(function () { return _this.reRender(); }));
|
this.subscribed.push(features.cache.subscribe(function () { return _this.reRender(); }));
|
||||||
}
|
}
|
||||||
|
if (option.features) {
|
||||||
|
option.features.forEach(function (ele) { return _this.subscribed.push(features[ele].subscribe(function () { return _this.reRender(); })); });
|
||||||
|
}
|
||||||
attached && attached.call(this);
|
attached && attached.call(this);
|
||||||
},
|
},
|
||||||
detached: function () {
|
detached: function () {
|
||||||
|
|
|
||||||
|
|
@ -641,7 +641,11 @@ function createComponent(option, features) {
|
||||||
}
|
}
|
||||||
this.reRender();
|
this.reRender();
|
||||||
_a.label = 3;
|
_a.label = 3;
|
||||||
case 3: return [2 /*return*/];
|
case 3:
|
||||||
|
if (option.features) {
|
||||||
|
option.features.forEach(function (ele) { return _this.subscribed.push(features[ele].subscribe(function () { return _this.reRender(); })); });
|
||||||
|
}
|
||||||
|
return [2 /*return*/];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,26 @@ declare type FullPropertyToData<T extends AllFullProperty> = ValueType<T['type']
|
||||||
declare type PropertyOptionToData<P extends PropertyOption> = {
|
declare type PropertyOptionToData<P extends PropertyOption> = {
|
||||||
[name in keyof P]: PropertyToData<P[name]>;
|
[name in keyof P]: PropertyToData<P[name]>;
|
||||||
};
|
};
|
||||||
|
declare type CascadeEntity<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||||
|
aggr?: ED[T]['Aggregation'];
|
||||||
|
selection?: ED[T]['Selection'];
|
||||||
|
actions?: [
|
||||||
|
{
|
||||||
|
action: ED[T]['Action'];
|
||||||
|
filters?: Array<{
|
||||||
|
filter: ED[T]['Selection']['filter'];
|
||||||
|
'#name'?: string;
|
||||||
|
}>;
|
||||||
|
data?: Partial<ED[T]['CreateSingle']['data']>;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption> {
|
interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption> {
|
||||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
||||||
path?: string;
|
path?: string;
|
||||||
isList: IsList;
|
isList: IsList;
|
||||||
|
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
||||||
|
cascadeEntities?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => Record<keyof ED[T]['Schema'], CascadeEntity<ED, keyof ED>>;
|
||||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data']);
|
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data']);
|
||||||
append?: boolean;
|
append?: boolean;
|
||||||
pagination?: Pagination;
|
pagination?: Pagination;
|
||||||
|
|
|
||||||
|
|
@ -1777,10 +1777,10 @@ class VirtualNode<
|
||||||
if (child instanceof SingleNode || child instanceof ListNode) {
|
if (child instanceof SingleNode || child instanceof ListNode) {
|
||||||
const entity = child.getEntity() as string;
|
const entity = child.getEntity() as string;
|
||||||
if (child instanceof SingleNode) {
|
if (child instanceof SingleNode) {
|
||||||
assert(path === entity || path.startsWith(`${entity}:`), `oakPath「${path}」不符合命名规范,请以「${entity}」为命名起始标识`);
|
assert(path === entity || path.startsWith(`${entity}:`), `oakPath「${path}」不符合命名规范,请以「${entity}:」为命名起始标识`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(path === `${entity}s` || path.startsWith(`${entity}s:`), `oakPath「${path}」不符合命名规范,请以「${entity}s」为命名起始标识`);
|
assert(path === `${entity}s` || path.startsWith(`${entity}s:`), `oakPath「${path}」不符合命名规范,请以「${entity}s:」为命名起始标识`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -761,6 +761,15 @@ export function createComponent<
|
||||||
features.cache.subscribe(() => this.reRender())
|
features.cache.subscribe(() => this.reRender())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (option.features) {
|
||||||
|
option.features.forEach(
|
||||||
|
ele => this.subscribed.push(
|
||||||
|
features[ele].subscribe(
|
||||||
|
() => this.reRender()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
attached && attached.call(this);
|
attached && attached.call(this);
|
||||||
},
|
},
|
||||||
detached() {
|
detached() {
|
||||||
|
|
|
||||||
|
|
@ -906,6 +906,15 @@ export function createComponent<
|
||||||
}
|
}
|
||||||
this.reRender();
|
this.reRender();
|
||||||
}
|
}
|
||||||
|
if (option.features) {
|
||||||
|
option.features.forEach(
|
||||||
|
ele => this.subscribed.push(
|
||||||
|
features[ele].subscribe(
|
||||||
|
() => this.reRender()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,21 @@ type PropertyOptionToData<P extends PropertyOption> = {
|
||||||
[name in keyof P]: PropertyToData<P[name]>
|
[name in keyof P]: PropertyToData<P[name]>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type CascadeEntity<
|
||||||
|
ED extends EntityDict & BaseEntityDict,
|
||||||
|
T extends keyof ED> = {
|
||||||
|
aggr?: ED[T]['Aggregation'],
|
||||||
|
selection?: ED[T]['Selection'],
|
||||||
|
actions?: [{
|
||||||
|
action: ED[T]['Action'],
|
||||||
|
filters?: Array<{
|
||||||
|
filter: ED[T]['Selection']['filter'];
|
||||||
|
'#name'?: string;
|
||||||
|
}>;
|
||||||
|
data?: Partial<ED[T]['CreateSingle']['data']>;
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
interface ComponentOption<
|
interface ComponentOption<
|
||||||
ED extends EntityDict & BaseEntityDict,
|
ED extends EntityDict & BaseEntityDict,
|
||||||
T extends keyof ED,
|
T extends keyof ED,
|
||||||
|
|
@ -97,6 +112,8 @@ interface ComponentOption<
|
||||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
||||||
path?: string;
|
path?: string;
|
||||||
isList: IsList;
|
isList: IsList;
|
||||||
|
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
||||||
|
cascadeEntities?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => Record<keyof ED[T]['Schema'], CascadeEntity<ED, keyof ED>>,
|
||||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data']);
|
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data']);
|
||||||
append?: boolean;
|
append?: boolean;
|
||||||
pagination?: Pagination;
|
pagination?: Pagination;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue