mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-06 05:59:25 +08:00
fix(plugin-workflow-manual): allow pass node when no assignee (#4139)
This commit is contained in:
parent
b6940596f5
commit
8a2bcd9a74
@ -96,13 +96,17 @@ export default class extends Instruction {
|
|||||||
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id).flat().filter(Boolean))];
|
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id).flat().filter(Boolean))];
|
||||||
|
|
||||||
const job = await processor.saveJob({
|
const job = await processor.saveJob({
|
||||||
status: JOB_STATUS.PENDING,
|
status: assignees.length ? JOB_STATUS.PENDING : JOB_STATUS.RESOLVED,
|
||||||
result: mode ? [] : null,
|
result: mode ? [] : null,
|
||||||
nodeId: node.id,
|
nodeId: node.id,
|
||||||
nodeKey: node.key,
|
nodeKey: node.key,
|
||||||
upstreamId: prevJob?.id ?? null,
|
upstreamId: prevJob?.id ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!assignees.length) {
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: batch create users jobs
|
// NOTE: batch create users jobs
|
||||||
const UserJobModel = this.workflow.app.db.getModel('users_jobs');
|
const UserJobModel = this.workflow.app.db.getModel('users_jobs');
|
||||||
await UserJobModel.bulkCreate(
|
await UserJobModel.bulkCreate(
|
||||||
|
@ -50,6 +50,32 @@ describe('workflow > instructions > manual > assignees', () => {
|
|||||||
|
|
||||||
afterEach(() => app.destroy());
|
afterEach(() => app.destroy());
|
||||||
|
|
||||||
|
describe('no', () => {
|
||||||
|
it('empty assignees', async () => {
|
||||||
|
const n1 = await workflow.createNode({
|
||||||
|
type: 'manual',
|
||||||
|
config: {
|
||||||
|
assignees: [],
|
||||||
|
forms: {
|
||||||
|
f1: {
|
||||||
|
actions: [{ status: JOB_STATUS.RESOLVED, key: 'resolve' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const post = await PostRepo.create({
|
||||||
|
values: { title: 't1', category: { title: 'c1' } },
|
||||||
|
context: { state: { currentUser: users[0] } },
|
||||||
|
});
|
||||||
|
|
||||||
|
await sleep(500);
|
||||||
|
|
||||||
|
const [pending] = await workflow.getExecutions();
|
||||||
|
expect(pending.status).toBe(EXECUTION_STATUS.RESOLVED);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('multiple', () => {
|
describe('multiple', () => {
|
||||||
it('assignees from nested array', async () => {
|
it('assignees from nested array', async () => {
|
||||||
const n1 = await workflow.createNode({
|
const n1 = await workflow.createNode({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user