@if (getConditionsFormArray(formGroup).length === 0) {
No conditions added. Add one to define document filters.
}
@for (condition of getConditionsFormArray(formGroup).controls; track condition; let conditionIndex = $index) {
-
-
+
+
+
+ @if (isTagsCondition(condition.get('type').value)) {
+
+ } @else {
+
+ }
+
- @if (isTagsCondition(condition.get('type').value)) {
-
- } @else {
-
- }
}
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.scss b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.scss
index 6cfcf86b4..846005755 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.scss
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.scss
@@ -7,3 +7,7 @@
.accordion-button {
font-size: 1rem;
}
+
+:host ::ng-deep .conditions .paperless-input-select.mb-3 {
+ margin-bottom: 0 !important;
+}
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 d475fec65..fa66f97a4 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
@@ -150,20 +150,17 @@ export enum TriggerConditionType {
interface TriggerConditionDefinition {
id: TriggerConditionType
name: string
- hint?: string
- valueLabel: string
inputType: 'tags' | 'select'
allowMultipleEntries: boolean
allowMultipleValues: boolean
selectItems?: 'correspondents' | 'documentTypes' | 'storagePaths'
+ disabled?: boolean
}
const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.TagsAny,
name: $localize`Has any of these tags`,
- hint: $localize`Trigger matches when the document has at least one of the selected tags.`,
- valueLabel: $localize`Tags`,
inputType: 'tags',
allowMultipleEntries: false,
allowMultipleValues: true,
@@ -171,8 +168,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.TagsAll,
name: $localize`Has all of these tags`,
- hint: $localize`Trigger matches only when every selected tag is present.`,
- valueLabel: $localize`Tags`,
inputType: 'tags',
allowMultipleEntries: false,
allowMultipleValues: true,
@@ -180,8 +175,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.TagsNone,
name: $localize`Does not have these tags`,
- hint: $localize`Trigger matches only when none of the selected tags are present.`,
- valueLabel: $localize`Tags`,
inputType: 'tags',
allowMultipleEntries: false,
allowMultipleValues: true,
@@ -189,8 +182,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.CorrespondentIs,
name: $localize`Has correspondent`,
- hint: $localize`Trigger matches when the document has the selected correspondent.`,
- valueLabel: $localize`Correspondent`,
inputType: 'select',
allowMultipleEntries: false,
allowMultipleValues: false,
@@ -199,8 +190,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.CorrespondentNot,
name: $localize`Does not have correspondents`,
- hint: $localize`Trigger matches when the document does not have any of the selected correspondents.`,
- valueLabel: $localize`Correspondents`,
inputType: 'select',
allowMultipleEntries: false,
allowMultipleValues: true,
@@ -209,8 +198,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.DocumentTypeIs,
name: $localize`Has document type`,
- hint: $localize`Trigger matches when the document has the selected document type.`,
- valueLabel: $localize`Document type`,
inputType: 'select',
allowMultipleEntries: false,
allowMultipleValues: false,
@@ -219,8 +206,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.DocumentTypeNot,
name: $localize`Does not have document types`,
- hint: $localize`Trigger matches when the document does not have any of the selected document types.`,
- valueLabel: $localize`Document types`,
inputType: 'select',
allowMultipleEntries: false,
allowMultipleValues: true,
@@ -229,8 +214,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.StoragePathIs,
name: $localize`Has storage path`,
- hint: $localize`Trigger matches when the document has the selected storage path.`,
- valueLabel: $localize`Storage path`,
inputType: 'select',
allowMultipleEntries: false,
allowMultipleValues: false,
@@ -239,8 +222,6 @@ const TRIGGER_CONDITION_DEFINITIONS: TriggerConditionDefinition[] = [
{
id: TriggerConditionType.StoragePathNot,
name: $localize`Does not have storage paths`,
- hint: $localize`Trigger matches when the document does not have any of the selected storage paths.`,
- valueLabel: $localize`Storage paths`,
inputType: 'select',
allowMultipleEntries: false,
allowMultipleValues: true,
@@ -304,6 +285,11 @@ export class WorkflowEditDialogComponent
private allowedActionTypes = []
+ private conditionTypeOptionCache = new WeakMap<
+ FormArray,
+ TriggerConditionDefinition[]
+ >()
+
constructor() {
super()
this.service = inject(WorkflowService)
@@ -723,19 +709,30 @@ export class WorkflowEditDialogComponent
getConditionTypeOptions(formGroup: FormGroup, conditionIndex: number) {
const conditions = this.getConditionsFormArray(formGroup)
+ const options = this.getConditionTypeOptionsForArray(conditions)
+ const currentType = conditions.at(conditionIndex).get('type')
+ .value as TriggerConditionType
+ const usedTypes = conditions.controls.map(
+ (control) => control.get('type').value as TriggerConditionType
+ )
- return this.conditionDefinitions.map((definition) => ({
- id: definition.id,
- name: definition.name,
- disabled:
- !definition.allowMultipleEntries &&
- conditions.controls.some((control, idx) => {
- if (idx === conditionIndex) {
- return false
- }
- return control.get('type').value === definition.id
- }),
- }))
+ options.forEach((option) => {
+ if (option.allowMultipleEntries) {
+ option.disabled = false
+ return
+ }
+
+ const usedElsewhere = usedTypes.some((type, idx) => {
+ if (idx === conditionIndex) {
+ return false
+ }
+ return type === option.id
+ })
+
+ option.disabled = usedElsewhere && option.id !== currentType
+ })
+
+ return options
}
canAddCondition(formGroup: FormGroup): boolean {
@@ -802,17 +799,6 @@ export class WorkflowEditDialogComponent
return this.getConditionDefinition(type)?.name ?? ''
}
- getConditionHint(formGroup: FormGroup, conditionIndex: number): string {
- const conditions = this.getConditionsFormArray(formGroup)
- const type = conditions.at(conditionIndex).get('type')
- .value as TriggerConditionType
- return this.getConditionDefinition(type)?.hint ?? ''
- }
-
- getConditionValueLabel(type: TriggerConditionType): string {
- return this.getConditionDefinition(type)?.valueLabel ?? ''
- }
-
isTagsCondition(type: TriggerConditionType): boolean {
return this.getConditionDefinition(type)?.inputType === 'tags'
}
@@ -876,6 +862,20 @@ export class WorkflowEditDialogComponent
return value
}
+ private getConditionTypeOptionsForArray(
+ conditions: FormArray
+ ): TriggerConditionDefinition[] {
+ let cached = this.conditionTypeOptionCache.get(conditions)
+ if (!cached) {
+ cached = this.conditionDefinitions.map((definition) => ({
+ ...definition,
+ disabled: false,
+ }))
+ this.conditionTypeOptionCache.set(conditions, cached)
+ }
+ return cached
+ }
+
private createTriggerField(
trigger: WorkflowTrigger,
emitEvent: boolean = false
diff --git a/src-ui/src/app/components/common/input/select/select.component.html b/src-ui/src/app/components/common/input/select/select.component.html
index ef7be3b62..eb351cbe6 100644
--- a/src-ui/src/app/components/common/input/select/select.component.html
+++ b/src-ui/src/app/components/common/input/select/select.component.html
@@ -1,66 +1,68 @@