为了适配小程序,修改了一点点formData的逻辑
This commit is contained in:
parent
b1564b3c47
commit
5361708764
|
|
@ -43,7 +43,7 @@ var Navigator = /** @class */ (function (_super) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: url,
|
url: url,
|
||||||
success: function () { return resolve(void ); },
|
success: function () { return resolve(undefined); },
|
||||||
fail: function (err) { return reject(err); }
|
fail: function (err) { return reject(err); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -53,7 +53,7 @@ var Navigator = /** @class */ (function (_super) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
wx.redirectTo({
|
wx.redirectTo({
|
||||||
url: url,
|
url: url,
|
||||||
success: function () { return resolve(void ); },
|
success: function () { return resolve(undefined); },
|
||||||
fail: function (err) { return reject(err); }
|
fail: function (err) { return reject(err); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -63,7 +63,7 @@ var Navigator = /** @class */ (function (_super) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
wx.navigateBack({
|
wx.navigateBack({
|
||||||
delta: delta,
|
delta: delta,
|
||||||
success: function () { return resolve(void ); },
|
success: function () { return resolve(undefined); },
|
||||||
fail: function (err) { return reject(err); }
|
fail: function (err) { return reject(err); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export declare class Navigator extends Feature {
|
||||||
* @param history
|
* @param history
|
||||||
*/
|
*/
|
||||||
setHistory(history: BrowserHistory): void;
|
setHistory(history: BrowserHistory): void;
|
||||||
getLocation(): any;
|
getLocation(): import("history").Location;
|
||||||
navigateTo(url: string, state?: Record<string, any>): Promise<void>;
|
navigateTo(url: string, state?: Record<string, any>): Promise<void>;
|
||||||
redirectTo(url: string, state?: Record<string, any>): Promise<void>;
|
redirectTo(url: string, state?: Record<string, any>): Promise<void>;
|
||||||
navigateBack(delta?: number): Promise<void>;
|
navigateBack(delta?: number): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,6 @@ import { I18nOptions } from './platforms/web/i18n';
|
||||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (aspectWrapper: AspectWrapper<ED, Cxt, AD>, basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => (store: RowStore<ED, Cxt>) => Cxt, backendContextBuilder: (contextStr?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, aspectDict: AD, triggers?: Array<Trigger<ED, keyof ED, Cxt>>, checkers?: Array<Checker<ED, keyof ED, Cxt>>, watchers?: Array<Watcher<ED, keyof ED, Cxt>>, initialData?: {
|
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (aspectWrapper: AspectWrapper<ED, Cxt, AD>, basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => (store: RowStore<ED, Cxt>) => Cxt, backendContextBuilder: (contextStr?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, aspectDict: AD, triggers?: Array<Trigger<ED, keyof ED, Cxt>>, checkers?: Array<Checker<ED, keyof ED, Cxt>>, watchers?: Array<Watcher<ED, keyof ED, Cxt>>, initialData?: {
|
||||||
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
||||||
}, actionDict?: ActionDictOfEntityDict<ED>, i18nOptions?: I18nOptions): {
|
}, actionDict?: ActionDictOfEntityDict<ED>, i18nOptions?: I18nOptions): {
|
||||||
i18n: any;
|
i18n: import("i18next").i18n;
|
||||||
features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@ import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||||
import { CommonAspectDict } from 'oak-common-aspect';
|
import { CommonAspectDict } from 'oak-common-aspect';
|
||||||
import { I18nOptions } from './platforms/web/i18n';
|
import { I18nOptions } from './platforms/web/i18n';
|
||||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (aspectWrapper: AspectWrapper<ED, Cxt, AD>, basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => (store: RowStore<ED, Cxt>) => Cxt, connector: Connector<ED, Cxt>, checkers?: Array<Checker<ED, keyof ED, Cxt>>, actionDict?: ActionDictOfEntityDict<ED>, i18nOptions?: I18nOptions): {
|
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (aspectWrapper: AspectWrapper<ED, Cxt, AD>, basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>) => (store: RowStore<ED, Cxt>) => Cxt, connector: Connector<ED, Cxt>, checkers?: Array<Checker<ED, keyof ED, Cxt>>, actionDict?: ActionDictOfEntityDict<ED>, i18nOptions?: I18nOptions): {
|
||||||
i18n: any;
|
i18n: import("i18next").i18n;
|
||||||
features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
features: FD & BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ function onPathSet(option) {
|
||||||
exports.onPathSet = onPathSet;
|
exports.onPathSet = onPathSet;
|
||||||
function reRender(option, extra) {
|
function reRender(option, extra) {
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
var features, formData, rows, oakDirty, oakLoading, oakPullDownRefreshLoading, oakLoadingMore, oakExecuting, data, _a, k, oakAllowExecuting, err_1, actions, testResult, oakLegalActions, data, _b;
|
var features, formData, rows, oakDirty, oakLoading, oakPullDownRefreshLoading, oakLoadingMore, oakExecuting, oakLegalActions, actions, testResult, data, _a, k, oakAllowExecuting, err_1, data, _b;
|
||||||
var _c;
|
var _c;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return tslib_1.__generator(this, function (_d) {
|
return tslib_1.__generator(this, function (_d) {
|
||||||
|
|
@ -181,20 +181,47 @@ function reRender(option, extra) {
|
||||||
oakPullDownRefreshLoading = this.pullDownRefresh && this.features.runningTree.isLoading(this.state.oakFullpath);
|
oakPullDownRefreshLoading = this.pullDownRefresh && this.features.runningTree.isLoading(this.state.oakFullpath);
|
||||||
oakLoadingMore = this.features.runningTree.isLoadingMore(this.state.oakFullpath);
|
oakLoadingMore = this.features.runningTree.isLoadingMore(this.state.oakFullpath);
|
||||||
oakExecuting = this.features.runningTree.isExecuting(this.state.oakFullpath);
|
oakExecuting = this.features.runningTree.isExecuting(this.state.oakFullpath);
|
||||||
if (!formData) return [3 /*break*/, 3];
|
oakLegalActions = [];
|
||||||
|
actions = this.props.oakActions || option.actions;
|
||||||
|
if (!(actions && actions.length > 0)) return [3 /*break*/, 3];
|
||||||
|
(0, assert_1.assert)(this.props.oakId); // actions必须配合id来使用
|
||||||
|
return [4 /*yield*/, Promise.all(actions.map(function (ele) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||||
|
var _a;
|
||||||
|
return tslib_1.__generator(this, function (_b) {
|
||||||
|
switch (_b.label) {
|
||||||
|
case 0:
|
||||||
|
_a = {
|
||||||
|
action: ele
|
||||||
|
};
|
||||||
|
return [4 /*yield*/, this.checkOperation(this.state.oakEntity, ele, { id: this.props.oakId }, ['user', 'row'])];
|
||||||
|
case 1: return [2 /*return*/, (_a.result = _b.sent(),
|
||||||
|
_a)];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}); }))];
|
||||||
|
case 2:
|
||||||
|
testResult = _d.sent();
|
||||||
|
oakLegalActions = testResult.filter(function (ele) { return ele.result; }).map(function (ele) { return ele.action; });
|
||||||
|
_d.label = 3;
|
||||||
|
case 3:
|
||||||
|
if (!formData) return [3 /*break*/, 5];
|
||||||
return [4 /*yield*/, formData.call(this, {
|
return [4 /*yield*/, formData.call(this, {
|
||||||
data: rows,
|
data: rows,
|
||||||
features: features,
|
features: features,
|
||||||
props: this.props,
|
props: this.props,
|
||||||
|
legalActions: oakLegalActions,
|
||||||
})];
|
})];
|
||||||
case 2:
|
|
||||||
_a = _d.sent();
|
|
||||||
return [3 /*break*/, 4];
|
|
||||||
case 3:
|
|
||||||
_a = {};
|
|
||||||
_d.label = 4;
|
|
||||||
case 4:
|
case 4:
|
||||||
|
_a = _d.sent();
|
||||||
|
return [3 /*break*/, 6];
|
||||||
|
case 5:
|
||||||
|
_a = {};
|
||||||
|
_d.label = 6;
|
||||||
|
case 6:
|
||||||
data = _a;
|
data = _a;
|
||||||
|
Object.assign(data, {
|
||||||
|
oakLegalActions: oakLegalActions,
|
||||||
|
});
|
||||||
for (k in data) {
|
for (k in data) {
|
||||||
if (data[k] === undefined) {
|
if (data[k] === undefined) {
|
||||||
Object.assign(data, (_c = {},
|
Object.assign(data, (_c = {},
|
||||||
|
|
@ -213,14 +240,14 @@ function reRender(option, extra) {
|
||||||
Object.assign(data, extra);
|
Object.assign(data, extra);
|
||||||
}
|
}
|
||||||
oakAllowExecuting = false;
|
oakAllowExecuting = false;
|
||||||
_d.label = 5;
|
_d.label = 7;
|
||||||
case 5:
|
|
||||||
_d.trys.push([5, 7, , 8]);
|
|
||||||
return [4 /*yield*/, this.features.runningTree.tryExecute(this.state.oakFullpath)];
|
|
||||||
case 6:
|
|
||||||
oakAllowExecuting = _d.sent();
|
|
||||||
return [3 /*break*/, 8];
|
|
||||||
case 7:
|
case 7:
|
||||||
|
_d.trys.push([7, 9, , 10]);
|
||||||
|
return [4 /*yield*/, this.features.runningTree.tryExecute(this.state.oakFullpath)];
|
||||||
|
case 8:
|
||||||
|
oakAllowExecuting = _d.sent();
|
||||||
|
return [3 /*break*/, 10];
|
||||||
|
case 9:
|
||||||
err_1 = _d.sent();
|
err_1 = _d.sent();
|
||||||
if (err_1 instanceof types_1.OakUserException) {
|
if (err_1 instanceof types_1.OakUserException) {
|
||||||
oakAllowExecuting = err_1;
|
oakAllowExecuting = err_1;
|
||||||
|
|
@ -229,36 +256,11 @@ function reRender(option, extra) {
|
||||||
oakAllowExecuting = false;
|
oakAllowExecuting = false;
|
||||||
throw err_1;
|
throw err_1;
|
||||||
}
|
}
|
||||||
return [3 /*break*/, 8];
|
return [3 /*break*/, 10];
|
||||||
case 8:
|
case 10:
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
oakAllowExecuting: oakAllowExecuting,
|
oakAllowExecuting: oakAllowExecuting,
|
||||||
});
|
});
|
||||||
actions = this.props.oakActions || option.actions;
|
|
||||||
if (!(actions && actions.length > 0)) return [3 /*break*/, 10];
|
|
||||||
(0, assert_1.assert)(this.props.oakId); // actions必须配合id来使用
|
|
||||||
return [4 /*yield*/, Promise.all(actions.map(function (ele) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
||||||
var _a;
|
|
||||||
return tslib_1.__generator(this, function (_b) {
|
|
||||||
switch (_b.label) {
|
|
||||||
case 0:
|
|
||||||
_a = {
|
|
||||||
action: ele
|
|
||||||
};
|
|
||||||
return [4 /*yield*/, this.checkOperation(this.state.oakEntity, ele, { id: this.props.oakId }, ['user', 'row'])];
|
|
||||||
case 1: return [2 /*return*/, (_a.result = _b.sent(),
|
|
||||||
_a)];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}); }))];
|
|
||||||
case 9:
|
|
||||||
testResult = _d.sent();
|
|
||||||
oakLegalActions = testResult.filter(function (ele) { return ele.result; }).map(function (ele) { return ele.action; });
|
|
||||||
Object.assign(data, {
|
|
||||||
oakLegalActions: oakLegalActions,
|
|
||||||
});
|
|
||||||
_d.label = 10;
|
|
||||||
case 10:
|
|
||||||
this.setState(data);
|
this.setState(data);
|
||||||
return [3 /*break*/, 15];
|
return [3 /*break*/, 15];
|
||||||
case 11:
|
case 11:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export declare type I18nOptions = {
|
export declare type I18nOptions = {
|
||||||
version?: string;
|
version?: string;
|
||||||
};
|
};
|
||||||
export declare function getI18next(options?: I18nOptions): any;
|
export declare function getI18next(options?: I18nOptions): import("i18next").i18n;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyo
|
||||||
data: IsList extends true ? RowSelected<ED, T, Proj>[] : RowSelected<ED, T, Proj> | undefined;
|
data: IsList extends true ? RowSelected<ED, T, Proj>[] : RowSelected<ED, T, Proj> | undefined;
|
||||||
features: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
features: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
||||||
props: Partial<WechatMiniprogram.Component.PropertyOptionToData<TProperty>>;
|
props: Partial<WechatMiniprogram.Component.PropertyOptionToData<TProperty>>;
|
||||||
|
legalActions: ED[T]['Action'][];
|
||||||
}) => Promise<FormedData>;
|
}) => Promise<FormedData>;
|
||||||
ns?: T | T[];
|
ns?: T | T[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export class Navigator extends Feature {
|
||||||
(resolve, reject) => {
|
(resolve, reject) => {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url,
|
url,
|
||||||
success: () => resolve(void),
|
success: () => resolve(undefined),
|
||||||
fail: (err) => reject(err)
|
fail: (err) => reject(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ export class Navigator extends Feature {
|
||||||
(resolve, reject) => {
|
(resolve, reject) => {
|
||||||
wx.redirectTo({
|
wx.redirectTo({
|
||||||
url,
|
url,
|
||||||
success: () => resolve(void),
|
success: () => resolve(undefined),
|
||||||
fail: (err) => reject(err)
|
fail: (err) => reject(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +71,7 @@ export class Navigator extends Feature {
|
||||||
(resolve, reject) => {
|
(resolve, reject) => {
|
||||||
wx.navigateBack({
|
wx.navigateBack({
|
||||||
delta,
|
delta,
|
||||||
success: () => resolve(void),
|
success: () => resolve(undefined),
|
||||||
fail: (err) => reject(err)
|
fail: (err) => reject(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,13 +159,36 @@ export async function reRender<
|
||||||
const oakLoadingMore = this.features.runningTree.isLoadingMore(this.state.oakFullpath);
|
const oakLoadingMore = this.features.runningTree.isLoadingMore(this.state.oakFullpath);
|
||||||
const oakExecuting = this.features.runningTree.isExecuting(this.state.oakFullpath);
|
const oakExecuting = this.features.runningTree.isExecuting(this.state.oakFullpath);
|
||||||
|
|
||||||
|
let oakLegalActions: ED[T]['Action'][] = [];
|
||||||
|
const actions: ED[T]['Action'][] = this.props.oakActions || option.actions;
|
||||||
|
if (actions && actions.length > 0) {
|
||||||
|
assert(this.props.oakId); // actions必须配合id来使用
|
||||||
|
const testResult = await Promise.all(
|
||||||
|
actions.map(
|
||||||
|
async ele => ({
|
||||||
|
action: ele,
|
||||||
|
result: await this.checkOperation(this.state.oakEntity, ele, { id: this.props.oakId }, ['user', 'row']),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
oakLegalActions = testResult.filter(
|
||||||
|
ele => ele.result
|
||||||
|
).map(
|
||||||
|
ele => ele.action
|
||||||
|
);
|
||||||
|
}
|
||||||
const data: Record<string, any> = formData
|
const data: Record<string, any> = formData
|
||||||
? await formData.call(this, {
|
? await formData.call(this, {
|
||||||
data: rows as any,
|
data: rows as any,
|
||||||
features,
|
features,
|
||||||
props: this.props,
|
props: this.props,
|
||||||
|
legalActions: oakLegalActions,
|
||||||
})
|
})
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
Object.assign(data, {
|
||||||
|
oakLegalActions,
|
||||||
|
});
|
||||||
for (const k in data) {
|
for (const k in data) {
|
||||||
if (data[k] === undefined) {
|
if (data[k] === undefined) {
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
|
|
@ -201,27 +224,6 @@ export async function reRender<
|
||||||
oakAllowExecuting,
|
oakAllowExecuting,
|
||||||
});
|
});
|
||||||
|
|
||||||
const actions: ED[T]['Action'][] = this.props.oakActions || option.actions;
|
|
||||||
if (actions && actions.length > 0) {
|
|
||||||
assert(this.props.oakId); // actions必须配合id来使用
|
|
||||||
const testResult = await Promise.all(
|
|
||||||
actions.map(
|
|
||||||
async ele => ({
|
|
||||||
action: ele,
|
|
||||||
result: await this.checkOperation(this.state.oakEntity, ele, { id: this.props.oakId }, ['user', 'row']),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const oakLegalActions = testResult.filter(
|
|
||||||
ele => ele.result
|
|
||||||
).map(
|
|
||||||
ele => ele.action
|
|
||||||
);
|
|
||||||
Object.assign(data, {
|
|
||||||
oakLegalActions,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState(data);
|
this.setState(data);
|
||||||
} else {
|
} else {
|
||||||
const data: Record<string, any> = formData
|
const data: Record<string, any> = formData
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ interface ComponentOption<
|
||||||
data: IsList extends true ? RowSelected<ED, T, Proj>[] : RowSelected<ED, T, Proj> | undefined;
|
data: IsList extends true ? RowSelected<ED, T, Proj>[] : RowSelected<ED, T, Proj> | undefined;
|
||||||
features: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
features: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
||||||
props: Partial<WechatMiniprogram.Component.PropertyOptionToData<TProperty>>;
|
props: Partial<WechatMiniprogram.Component.PropertyOptionToData<TProperty>>;
|
||||||
|
legalActions: ED[T]['Action'][];
|
||||||
}) => Promise<FormedData>;
|
}) => Promise<FormedData>;
|
||||||
ns?: T | T[];
|
ns?: T | T[];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue