Drag n drop reordering of workflow actions
This commit is contained in:
parent
18ebae7dd0
commit
f387d315cd
@ -92,9 +92,9 @@
|
|||||||
<ng-container i18n>Add Action</ng-container>
|
<ng-container i18n>Add Action</ng-container>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div ngbAccordion [closeOthers]="true">
|
<div ngbAccordion [closeOthers]="true" cdkDropList (cdkDropListDropped)="onActionDrop($event)">
|
||||||
@for (action of object.actions; track action; let i = $index){
|
@for (action of object.actions; track action; let i = $index){
|
||||||
<div ngbAccordionItem [formGroup]="actionFields.controls[i]">
|
<div ngbAccordionItem cdkDrag [formGroup]="actionFields.controls[i]">
|
||||||
<div ngbAccordionHeader>
|
<div ngbAccordionHeader>
|
||||||
<button ngbAccordionButton><ng-container i18n>Action</ng-container> {{i + 1}}
|
<button ngbAccordionButton><ng-container i18n>Action</ng-container> {{i + 1}}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ import {
|
|||||||
DocumentSource,
|
DocumentSource,
|
||||||
WorkflowTriggerType,
|
WorkflowTriggerType,
|
||||||
} from 'src/app/data/workflow-trigger'
|
} from 'src/app/data/workflow-trigger'
|
||||||
|
import { WorkflowAction } from 'src/app/data/workflow-action'
|
||||||
|
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'
|
||||||
|
|
||||||
export const DOCUMENT_SOURCE_OPTIONS = [
|
export const DOCUMENT_SOURCE_OPTIONS = [
|
||||||
{
|
{
|
||||||
@ -239,4 +241,15 @@ export class WorkflowEditDialogComponent
|
|||||||
this.object.actions.splice(index, 1)
|
this.object.actions.splice(index, 1)
|
||||||
this.updateTriggerActionFields()
|
this.updateTriggerActionFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onActionDrop(event: CdkDragDrop<WorkflowAction[]>) {
|
||||||
|
moveItemInArray(
|
||||||
|
this.object.actions,
|
||||||
|
event.previousIndex,
|
||||||
|
event.currentIndex
|
||||||
|
)
|
||||||
|
// removing id will effectively re-create the actions in this order
|
||||||
|
this.object.actions.forEach((a) => (a.id = null))
|
||||||
|
this.updateTriggerActionFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user