@@ -184,3 +167,28 @@
+
+
+
+
+
+
Trigger for documents that match all filters specified below.
+
+
+
+ @if (formGroup.get('type').value === WorkflowTriggerType.Consumption) {
+
+
+
+ }
+
+ @if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated) {
+
+ }
+
+
+
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts
index c152e3659..ebede83cd 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts
@@ -22,6 +22,7 @@ import { SwitchComponent } from '../../input/switch/switch.component'
import { EditDialogMode } from '../edit-dialog.component'
import {
DOCUMENT_SOURCE_OPTIONS,
+ WORKFLOW_ACTION_OPTIONS,
WORKFLOW_TYPE_OPTIONS,
WorkflowEditDialogComponent,
} from './workflow-edit-dialog.component'
@@ -32,7 +33,10 @@ import {
DocumentSource,
} from 'src/app/data/workflow-trigger'
import { CdkDragDrop } from '@angular/cdk/drag-drop'
-import { WorkflowAction } from 'src/app/data/workflow-action'
+import {
+ WorkflowAction,
+ WorkflowActionType,
+} from 'src/app/data/workflow-action'
const workflow: Workflow = {
name: 'Workflow 1',
@@ -50,10 +54,12 @@ const workflow: Workflow = {
actions: [
{
id: 1,
+ type: WorkflowActionType.Assignment,
assign_title: 'foo',
},
{
id: 4,
+ type: WorkflowActionType.Assignment,
assign_owner: 2,
},
],
@@ -174,11 +180,17 @@ describe('ConsumptionTemplateEditDialogComponent', () => {
it('should return source options, type options, type name', () => {
// coverage
expect(component.sourceOptions).toEqual(DOCUMENT_SOURCE_OPTIONS)
- expect(component.typeOptions).toEqual(WORKFLOW_TYPE_OPTIONS)
+ expect(component.triggerTypeOptions).toEqual(WORKFLOW_TYPE_OPTIONS)
expect(
- component.getTypeOptionName(WorkflowTriggerType.DocumentAdded)
+ component.getTriggerTypeOptionName(WorkflowTriggerType.DocumentAdded)
).toEqual('Document Added')
- expect(component.getTypeOptionName(null)).toEqual('')
+ expect(component.getTriggerTypeOptionName(null)).toEqual('')
+ expect(component.sourceOptions).toEqual(DOCUMENT_SOURCE_OPTIONS)
+ expect(component.actionTypeOptions).toEqual(WORKFLOW_ACTION_OPTIONS)
+ expect(
+ component.getActionTypeOptionName(WorkflowActionType.Assignment)
+ ).toEqual('Assignment')
+ expect(component.getActionTypeOptionName(null)).toEqual('')
})
it('should support add and remove triggers and actions', () => {
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
index 765d5a3e5..4879d25ba 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
@@ -21,7 +21,10 @@ import {
DocumentSource,
WorkflowTriggerType,
} from 'src/app/data/workflow-trigger'
-import { WorkflowAction } from 'src/app/data/workflow-action'
+import {
+ WorkflowAction,
+ WorkflowActionType,
+} from 'src/app/data/workflow-action'
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'
export const DOCUMENT_SOURCE_OPTIONS = [
@@ -54,6 +57,13 @@ export const WORKFLOW_TYPE_OPTIONS = [
},
]
+export const WORKFLOW_ACTION_OPTIONS = [
+ {
+ id: WorkflowActionType.Assignment,
+ name: $localize`Assignment`,
+ },
+]
+
@Component({
selector: 'pngx-workflow-edit-dialog',
templateUrl: './workflow-edit-dialog.component.html',
@@ -63,6 +73,8 @@ export class WorkflowEditDialogComponent
extends EditDialogComponent
implements OnInit
{
+ public WorkflowTriggerType = WorkflowTriggerType
+
templates: Workflow[]
correspondents: Correspondent[]
documentTypes: DocumentType[]
@@ -170,6 +182,7 @@ export class WorkflowEditDialogComponent
this.actionFields.push(
new FormGroup({
id: new FormControl(action.id),
+ type: new FormControl(action.type),
assign_title: new FormControl(action.assign_title),
assign_tags: new FormControl(action.assign_tags),
assign_owner: new FormControl(action.assign_owner),
@@ -191,12 +204,12 @@ export class WorkflowEditDialogComponent
return DOCUMENT_SOURCE_OPTIONS
}
- get typeOptions() {
+ get triggerTypeOptions() {
return WORKFLOW_TYPE_OPTIONS
}
- getTypeOptionName(type: WorkflowTriggerType): string {
- return this.typeOptions.find((t) => t.id === type)?.name ?? ''
+ getTriggerTypeOptionName(type: WorkflowTriggerType): string {
+ return this.triggerTypeOptions.find((t) => t.id === type)?.name ?? ''
}
addTrigger() {
@@ -214,8 +227,17 @@ export class WorkflowEditDialogComponent
this.updateTriggerActionFields()
}
+ get actionTypeOptions() {
+ return WORKFLOW_ACTION_OPTIONS
+ }
+
+ getActionTypeOptionName(type: WorkflowActionType): string {
+ return this.actionTypeOptions.find((t) => t.id === type)?.name ?? ''
+ }
+
addAction() {
this.object.actions.push({
+ type: WorkflowActionType.Assignment,
assign_title: null,
assign_tags: [],
assign_document_type: null,
diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts b/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
index 9f7039838..4382d56f5 100644
--- a/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
+++ b/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
@@ -22,6 +22,7 @@ import {
DocumentSource,
WorkflowTriggerType,
} from 'src/app/data/workflow-trigger'
+import { WorkflowActionType } from 'src/app/data/workflow-action'
const workflows: Workflow[] = [
{
@@ -40,6 +41,7 @@ const workflows: Workflow[] = [
actions: [
{
id: 1,
+ type: WorkflowActionType.Assignment,
assign_title: 'foo',
},
],
@@ -59,6 +61,7 @@ const workflows: Workflow[] = [
actions: [
{
id: 2,
+ type: WorkflowActionType.Assignment,
assign_title: 'bar',
},
],
diff --git a/src-ui/src/app/data/workflow-action.ts b/src-ui/src/app/data/workflow-action.ts
index a313e0e63..a0da5f03a 100644
--- a/src-ui/src/app/data/workflow-action.ts
+++ b/src-ui/src/app/data/workflow-action.ts
@@ -1,6 +1,11 @@
import { ObjectWithId } from './object-with-id'
+export enum WorkflowActionType {
+ Assignment = 1,
+}
export interface WorkflowAction extends ObjectWithId {
+ type: WorkflowActionType
+
assign_title?: string
assign_tags?: number[] // Tag.id
diff --git a/src-ui/src/app/services/rest/workflow.service.spec.ts b/src-ui/src/app/services/rest/workflow.service.spec.ts
index 28a382034..cdffda3e1 100644
--- a/src-ui/src/app/services/rest/workflow.service.spec.ts
+++ b/src-ui/src/app/services/rest/workflow.service.spec.ts
@@ -8,6 +8,7 @@ import {
DocumentSource,
WorkflowTriggerType,
} from 'src/app/data/workflow-trigger'
+import { WorkflowActionType } from 'src/app/data/workflow-action'
let httpTestingController: HttpTestingController
let service: WorkflowService
@@ -29,6 +30,7 @@ const workflows: Workflow[] = [
actions: [
{
id: 1,
+ type: WorkflowActionType.Assignment,
assign_title: 'foo',
},
],
@@ -48,6 +50,7 @@ const workflows: Workflow[] = [
actions: [
{
id: 2,
+ type: WorkflowActionType.Assignment,
assign_title: 'bar',
},
],
diff --git a/src/documents/migrations/1044_workflow_workflowaction_workflowtrigger_and_more.py b/src/documents/migrations/1044_workflow_workflowaction_workflowtrigger_and_more.py
index a04b7f4b8..4319e13cf 100644
--- a/src/documents/migrations/1044_workflow_workflowaction_workflowtrigger_and_more.py
+++ b/src/documents/migrations/1044_workflow_workflowaction_workflowtrigger_and_more.py
@@ -223,6 +223,14 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
+ (
+ "type",
+ models.PositiveIntegerField(
+ choices=[(1, "Assignment")],
+ default=1,
+ verbose_name="Workflow Action Type",
+ ),
+ ),
(
"assign_title",
models.CharField(
diff --git a/src/documents/models.py b/src/documents/models.py
index 0031b2c43..cba6ad3de 100644
--- a/src/documents/models.py
+++ b/src/documents/models.py
@@ -974,6 +974,15 @@ class WorkflowTrigger(models.Model):
class WorkflowAction(models.Model):
+ class WorkflowActionType(models.IntegerChoices):
+ ASSIGNMENT = 1, _("Assignment")
+
+ type = models.PositiveIntegerField(
+ _("Workflow Action Type"),
+ choices=WorkflowActionType.choices,
+ default=WorkflowActionType.ASSIGNMENT,
+ )
+
assign_title = models.CharField(
_("assign title"),
max_length=256,
diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py
index f9d5fce94..a82227b1a 100644
--- a/src/documents/serialisers.py
+++ b/src/documents/serialisers.py
@@ -1334,6 +1334,7 @@ class WorkflowActionSerializer(serializers.ModelSerializer):
model = WorkflowAction
fields = [
"id",
+ "type",
"assign_title",
"assign_tags",
"assign_correspondent",