mirror of
https://github.com/strapi/strapi.git
synced 2025-09-23 07:22:51 +00:00
chore(ee): clean up controller
This commit is contained in:
parent
8461088555
commit
6bb9d68da2
@ -149,30 +149,31 @@ module.exports = {
|
|||||||
const entityStageId = entity[ENTITY_STAGE_ATTRIBUTE]?.id;
|
const entityStageId = entity[ENTITY_STAGE_ATTRIBUTE]?.id;
|
||||||
const canTransition = stagePermissions.can(STAGE_TRANSITION_UID, entityStageId);
|
const canTransition = stagePermissions.can(STAGE_TRANSITION_UID, entityStageId);
|
||||||
|
|
||||||
const workflowCount = await workflowService.count();
|
const [workflowCount, { stages: workflowStages }] = await Promise.all([
|
||||||
|
workflowService.count(),
|
||||||
|
workflowService.getAssignedWorkflow(modelUID, {
|
||||||
|
populate: 'stages',
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
stageCount: workflowStages.length,
|
||||||
|
workflowCount,
|
||||||
|
};
|
||||||
|
|
||||||
if (!canTransition) {
|
if (!canTransition) {
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
data: [],
|
data: [],
|
||||||
meta: {
|
meta,
|
||||||
stageCount: 0,
|
|
||||||
workflowCount,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { stages: workflowStages } = await workflowService.getAssignedWorkflow(modelUID, {
|
|
||||||
populate: 'stages',
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = workflowStages.filter((stage) => stage.id !== entityStageId);
|
const data = workflowStages.filter((stage) => stage.id !== entityStageId);
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
data,
|
data,
|
||||||
meta: {
|
meta,
|
||||||
stageCount: data.length,
|
|
||||||
workflowCount,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user