feat: Implement delete step rest API endpoint
This commit is contained in:
@@ -207,7 +207,9 @@ class Step extends Base {
|
||||
|
||||
const additionalFields = setupField.additionalFields;
|
||||
if (additionalFields) {
|
||||
const keyArgument = additionalFields.arguments.find(argument => argument.name === 'key');
|
||||
const keyArgument = additionalFields.arguments.find(
|
||||
(argument) => argument.name === 'key'
|
||||
);
|
||||
const dynamicFieldsKey = keyArgument.value;
|
||||
|
||||
const dynamicFields = await this.createDynamicFields(
|
||||
@@ -289,6 +291,25 @@ class Step extends Base {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
async delete() {
|
||||
await this.$relatedQuery('executionSteps').delete();
|
||||
await this.$query().delete();
|
||||
|
||||
const flow = await this.$relatedQuery('flow');
|
||||
|
||||
const nextSteps = await flow
|
||||
.$relatedQuery('steps')
|
||||
.where('position', '>', this.position);
|
||||
|
||||
const nextStepQueries = nextSteps.map(async (nextStep) => {
|
||||
await nextStep.$query().patch({
|
||||
position: nextStep.position - 1,
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all(nextStepQueries);
|
||||
}
|
||||
}
|
||||
|
||||
export default Step;
|
||||
|
Reference in New Issue
Block a user