Co-authored-by: sealday <sealday@gmail.com> Reviewed-on: daoyoucloud/tachybase#1163
This commit is contained in:
parent
c15e594855
commit
d7a3142ada
@ -1,4 +1,4 @@
|
||||
import actions, { Context, utils } from '@tachybase/actions';
|
||||
import actions, { Context, Next, utils } from '@tachybase/actions';
|
||||
import { Op, Repository } from '@tachybase/database';
|
||||
|
||||
import Plugin from '../Plugin';
|
||||
@ -161,21 +161,25 @@ export async function sync(context: Context, next) {
|
||||
await next();
|
||||
}
|
||||
|
||||
export async function trigger(ctx: Context) {
|
||||
const plugin = ctx.app.getPlugin(Plugin) as Plugin;
|
||||
const workflow = (await ctx.db.getRepository('workflows').findById(ctx.action.params.filterByTk)) as WorkflowModel;
|
||||
// NOTE: 这里的updateData是通过前端传过来的,需要 decodeURIComponent,
|
||||
// updateData 的约定结构是形如: updateData: { primaryKey: "id", targetKeys: []}
|
||||
const updateData = JSON.parse(decodeURIComponent(ctx.action.params?.updateData || ''));
|
||||
plugin.trigger(
|
||||
workflow,
|
||||
{
|
||||
data: {
|
||||
updateData,
|
||||
httpContext: ctx,
|
||||
user: ctx?.auth?.user,
|
||||
export async function trigger(ctx: Context, next: Next) {
|
||||
if (!ctx.action.params.triggerWorkflows) {
|
||||
const plugin = ctx.app.getPlugin(Plugin) as Plugin;
|
||||
const workflow = (await ctx.db.getRepository('workflows').findById(ctx.action.params.filterByTk)) as WorkflowModel;
|
||||
// NOTE: 这里的updateData是通过前端传过来的,需要 decodeURIComponent,
|
||||
// updateData 的约定结构是形如: updateData: { primaryKey: "id", targetKeys: []}
|
||||
const updateData = JSON.parse(decodeURIComponent(ctx.action.params?.updateData || ''));
|
||||
plugin.trigger(
|
||||
workflow,
|
||||
{
|
||||
data: {
|
||||
updateData,
|
||||
httpContext: ctx,
|
||||
user: ctx?.auth?.user,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ httpContext: ctx },
|
||||
);
|
||||
{ httpContext: ctx },
|
||||
);
|
||||
} else {
|
||||
await next();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user