Summary
Rewrite all ProcessStep service functions to work with the previousStepId linked list model instead of order Int. Supersedes #595 and #596.
Functions to Rewrite
getProcessTemplateAsSequence(id)
- Fetch all steps for template
- Resolve linked list into
ProcessStepSequence[] tree starting from root steps (parentStepId=null, previousStepId=null)
- For each step, collect its branches (steps with
parentStepId=step.id) as separate sequences
addProcessStep(templateId, data)
- Append to root sequence: find last step in root (step with
parentStepId=null where no other step has previousStepId=that.id), set new step's previousStepId to it
- Support optional
afterStepId to insert mid-sequence
addBranchStep(templateId, parentStepId, data)
- Start a new branch off
parentStepId
- Find last step in existing branches for that parent, or create first step with
previousStepId=null
- Each distinct branch is a separate linked sequence
deleteProcessStep(stepId, templateId)
- Re-link: set
previousStepId of step's successor to step's previousStepId
- Soft-delete the step
moveProcessStep(templateId, stepId, direction)
- Swap
previousStepId links with the adjacent step in the same sequence
Purchase queries
- Update
getPurchaseProcess and getBatchPurchaseProcessData to include previousStepId
Blocked By
Blocked by #611 (schema) and #612 (types)
Supersedes #595, #596
Part of #530
Summary
Rewrite all
ProcessStepservice functions to work with thepreviousStepIdlinked list model instead oforder Int. Supersedes #595 and #596.Functions to Rewrite
getProcessTemplateAsSequence(id)ProcessStepSequence[]tree starting from root steps (parentStepId=null, previousStepId=null)parentStepId=step.id) as separate sequencesaddProcessStep(templateId, data)parentStepId=nullwhere no other step haspreviousStepId=that.id), set new step'spreviousStepIdto itafterStepIdto insert mid-sequenceaddBranchStep(templateId, parentStepId, data)parentStepIdpreviousStepId=nulldeleteProcessStep(stepId, templateId)previousStepIdof step's successor to step'spreviousStepIdmoveProcessStep(templateId, stepId, direction)previousStepIdlinks with the adjacent step in the same sequencePurchase queries
getPurchaseProcessandgetBatchPurchaseProcessDatato includepreviousStepIdBlocked By
Blocked by #611 (schema) and #612 (types)
Supersedes #595, #596
Part of #530