Dynamic adding / removing workflow triggers + actions
This commit is contained in:
@@ -241,7 +241,7 @@
|
||||
ngbPopover="Workflows" i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end"
|
||||
container="body" triggers="mouseenter:mouseleave" popoverClass="popover-slim">
|
||||
<svg class="sidebaricon" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#boxes" />
|
||||
<use xlink:href="assets/bootstrap-icons.svg#arrow-left-right" />
|
||||
</svg><span> <ng-container i18n>Workflows</ng-container></span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -21,13 +21,29 @@
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
<p class="small" i18n>Trigger Workflow On:</p>
|
||||
<div class="d-flex">
|
||||
<p class="p-2" i18n>Trigger Workflow On:</p>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary ms-auto mb-3" (click)="addTrigger()">
|
||||
<svg class="sidebaricon me-1" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#plus-circle" />
|
||||
</svg>
|
||||
<ng-container i18n>Add Trigger</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
<div ngbAccordion [closeOthers]="true">
|
||||
@for (trigger of object.triggers; track trigger; let i = $index){
|
||||
<div ngbAccordionItem [formGroup]="triggerFields.controls[i]">
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>{{getTypeOptionName(triggerFields.controls[i].value.type)}} ({{i + 1}})</button>
|
||||
</h2>
|
||||
<div ngbAccordionHeader>
|
||||
<button ngbAccordionButton>{{i + 1}}. {{getTypeOptionName(triggerFields.controls[i].value.type)}}
|
||||
|
||||
<button type="button" class="btn btn-link text-danger ms-3" (click)="removeTrigger(i)">
|
||||
<svg class="sidebaricon me-1" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#trash" />
|
||||
</svg>
|
||||
<ng-container i18n>Delete</ng-container>
|
||||
</button>
|
||||
</button>
|
||||
</div>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
|
||||
@@ -64,13 +80,29 @@
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
<p class="small" i18n>Apply Actions:</p>
|
||||
<div class="d-flex">
|
||||
<p class="p-2" i18n>Apply Actions:</p>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary ms-auto mb-3" (click)="addAction()">
|
||||
<svg class="sidebaricon me-1" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#plus-circle" />
|
||||
</svg>
|
||||
<ng-container i18n>Add Action</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
<div ngbAccordion [closeOthers]="true">
|
||||
@for (action of object.actions; track action; let i = $index){
|
||||
<div ngbAccordionItem [formGroup]="actionFields.controls[i]">
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>{{i + 1}}</button>
|
||||
</h2>
|
||||
<div ngbAccordionHeader>
|
||||
<button ngbAccordionButton><ng-container i18n>Action</ng-container> {{i + 1}}
|
||||
|
||||
<button type="button" class="btn btn-link text-danger ms-3" (click)="removeAction(i)">
|
||||
<svg class="sidebaricon me-1" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#trash" />
|
||||
</svg>
|
||||
<ng-container i18n>Delete</ng-container>
|
||||
</button>
|
||||
</button>
|
||||
</div>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
.btn.text-danger {
|
||||
&:hover, &:focus {
|
||||
color: rgba(var(--bs-danger-rgb), var(--bs-text-opacity)) !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,4 +195,47 @@ export class WorkflowEditDialogComponent
|
||||
getTypeOptionName(type: WorkflowTriggerType): string {
|
||||
return this.typeOptions.find((t) => t.id === type).name ?? ''
|
||||
}
|
||||
|
||||
addTrigger() {
|
||||
this.object.triggers.push({
|
||||
type: WorkflowTriggerType.Consumption,
|
||||
sources: [],
|
||||
filter_filename: null,
|
||||
filter_path: null,
|
||||
filter_mailrule: null,
|
||||
filter_has_tags: [],
|
||||
filter_has_correspondent: null,
|
||||
filter_has_document_type: null,
|
||||
})
|
||||
|
||||
this.updateTriggerActionFields()
|
||||
}
|
||||
|
||||
addAction() {
|
||||
this.object.actions.push({
|
||||
assign_title: null,
|
||||
assign_tags: [],
|
||||
assign_document_type: null,
|
||||
assign_correspondent: null,
|
||||
assign_storage_path: null,
|
||||
assign_owner: null,
|
||||
assign_view_users: [],
|
||||
assign_view_groups: [],
|
||||
assign_change_users: [],
|
||||
assign_change_groups: [],
|
||||
assign_custom_fields: [],
|
||||
})
|
||||
|
||||
this.updateTriggerActionFields()
|
||||
}
|
||||
|
||||
removeTrigger(index: number) {
|
||||
this.object.triggers.splice(index, 1)
|
||||
this.updateTriggerActionFields()
|
||||
}
|
||||
|
||||
removeAction(index: number) {
|
||||
this.object.actions.splice(index, 1)
|
||||
this.updateTriggerActionFields()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user