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 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) {
|
||||
ctx.body = {
|
||||
data: [],
|
||||
meta: {
|
||||
stageCount: 0,
|
||||
workflowCount,
|
||||
},
|
||||
meta,
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { stages: workflowStages } = await workflowService.getAssignedWorkflow(modelUID, {
|
||||
populate: 'stages',
|
||||
});
|
||||
|
||||
const data = workflowStages.filter((stage) => stage.id !== entityStageId);
|
||||
ctx.body = {
|
||||
data,
|
||||
meta: {
|
||||
stageCount: data.length,
|
||||
workflowCount,
|
||||
},
|
||||
meta,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user