fix(plugin-workflow): fix toJSON type check (#2772)
* fix(plugin-workflow): fix toJSON type check * fix(plugin-workflow): fix type check logic order
This commit is contained in:
parent
1defb5db51
commit
f280dcfb00
@ -33,7 +33,14 @@ export default class FormTrigger extends Trigger {
|
||||
middleware = async (context, next) => {
|
||||
await next();
|
||||
|
||||
const { resourceName, actionName } = context.action;
|
||||
const {
|
||||
resourceName,
|
||||
actionName,
|
||||
params: { triggerWorkflows },
|
||||
} = context.action;
|
||||
if (!triggerWorkflows) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((resourceName === 'workflows' && actionName === 'trigger') || !['create', 'update'].includes(actionName)) {
|
||||
return;
|
||||
@ -42,11 +49,8 @@ export default class FormTrigger extends Trigger {
|
||||
this.trigger(context);
|
||||
};
|
||||
|
||||
async trigger(context) {
|
||||
const { triggerWorkflows, values } = context.action.params;
|
||||
if (!triggerWorkflows) {
|
||||
return;
|
||||
}
|
||||
private async trigger(context) {
|
||||
const { triggerWorkflows = '', values } = context.action.params;
|
||||
|
||||
const { currentUser } = context.state;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { Model } from '@nocobase/database';
|
||||
|
||||
export function toJSON(data: Model | Model[]): object {
|
||||
if (typeof data !== 'object' || !data) {
|
||||
return data;
|
||||
}
|
||||
if (Array.isArray(data)) {
|
||||
return data.map(toJSON);
|
||||
}
|
||||
if (!(data instanceof Model) || !data) {
|
||||
return data;
|
||||
}
|
||||
const result = data.get();
|
||||
Object.keys((<typeof Model>data.constructor).associations).forEach((key) => {
|
||||
if (result[key] != null) {
|
||||
if (result[key] != null && typeof result[key] === 'object') {
|
||||
result[key] = toJSON(result[key]);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user