mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Messing with scheduled trigger type
This commit is contained in:
@@ -119,6 +119,22 @@
|
||||
<div [formGroup]="formGroup">
|
||||
<input type="hidden" formControlName="id" />
|
||||
<pngx-input-select i18n-title title="Trigger type" [horizontal]="true" [items]="triggerTypeOptions" formControlName="type"></pngx-input-select>
|
||||
@if (formGroup.get('type').value === WorkflowTriggerType.Scheduled) {
|
||||
<p class="small" i18n>Set scheduled trigger delay and which field to use.</p>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<pngx-input-text i18n-title title="Delay" formControlName="schedule_delay" i18n-hint hint="Delay time string such as '3months', '1y'." [error]="error?.schedule_delay"></pngx-input-text>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<pngx-input-select i18n-title title="Delay field" formControlName="schedule_delay_field" [items]="scheduleDelayFieldOptions" [error]="error?.schedule_delay_field"></pngx-input-select>
|
||||
</div>
|
||||
@if (formGroup.get('schedule_delay_field').value === 'custom_field') {
|
||||
<div class="col-4">
|
||||
<pngx-input-select i18n-title title="Custom delay field" formControlName="schedule_delay_custom_field" [items]="dateCustomFields" i18n-hint hint="Custom field to use for delay." [error]="error?.schedule_delay_custom_field"></pngx-input-select>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<p class="small" i18n>Trigger for documents that match <em>all</em> filters specified below.</p>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@@ -128,7 +144,7 @@
|
||||
<pngx-input-text i18n-title title="Filter path" formControlName="filter_path" i18n-hint hint="Apply to documents that match this path. Wildcards specified as * are allowed. Case-normalized.</a>" [error]="error?.filter_path"></pngx-input-text>
|
||||
<pngx-input-select i18n-title title="Filter mail rule" [items]="mailRules" [allowNull]="true" formControlName="filter_mailrule" i18n-hint hint="Apply to documents consumed via this mail rule." [error]="error?.filter_mailrule"></pngx-input-select>
|
||||
}
|
||||
@if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated) {
|
||||
@if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated || formGroup.get('type').value === WorkflowTriggerType.Scheduled) {
|
||||
<pngx-input-select i18n-title title="Content matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></pngx-input-select>
|
||||
@if (patternRequired) {
|
||||
<pngx-input-text i18n-title title="Content matching pattern" formControlName="match" [error]="error?.match"></pngx-input-text>
|
||||
@@ -138,7 +154,7 @@
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated) {
|
||||
@if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated || formGroup.get('type').value === WorkflowTriggerType.Scheduled) {
|
||||
<div class="col-md-6">
|
||||
<pngx-input-tags [allowCreate]="false" i18n-title title="Has any of tags" formControlName="filter_has_tags"></pngx-input-tags>
|
||||
<pngx-input-select i18n-title title="Has correspondent" [items]="correspondents" [allowNull]="true" formControlName="filter_has_correspondent"></pngx-input-select>
|
||||
|
@@ -16,9 +16,10 @@ import { EditDialogComponent } from '../edit-dialog.component'
|
||||
import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
|
||||
import { MailRule } from 'src/app/data/mail-rule'
|
||||
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
|
||||
import { CustomField } from 'src/app/data/custom-field'
|
||||
import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
|
||||
import {
|
||||
DocumentSource,
|
||||
ScheduleDelayField,
|
||||
WorkflowTrigger,
|
||||
WorkflowTriggerType,
|
||||
} from 'src/app/data/workflow-trigger'
|
||||
@@ -48,6 +49,25 @@ export const DOCUMENT_SOURCE_OPTIONS = [
|
||||
},
|
||||
]
|
||||
|
||||
export const SCHEDULE_DELAY_FIELD_OPTIONS = [
|
||||
{
|
||||
id: ScheduleDelayField.Added,
|
||||
name: $localize`Added`,
|
||||
},
|
||||
{
|
||||
id: ScheduleDelayField.Created,
|
||||
name: $localize`Created`,
|
||||
},
|
||||
{
|
||||
id: ScheduleDelayField.Modified,
|
||||
name: $localize`Modified`,
|
||||
},
|
||||
{
|
||||
id: ScheduleDelayField.CustomField,
|
||||
name: $localize`Custom Field`,
|
||||
},
|
||||
]
|
||||
|
||||
export const WORKFLOW_TYPE_OPTIONS = [
|
||||
{
|
||||
id: WorkflowTriggerType.Consumption,
|
||||
@@ -61,6 +81,10 @@ export const WORKFLOW_TYPE_OPTIONS = [
|
||||
id: WorkflowTriggerType.DocumentUpdated,
|
||||
name: $localize`Document Updated`,
|
||||
},
|
||||
{
|
||||
id: WorkflowTriggerType.Scheduled,
|
||||
name: $localize`Scheduled`,
|
||||
},
|
||||
]
|
||||
|
||||
export const WORKFLOW_ACTION_OPTIONS = [
|
||||
@@ -314,6 +338,11 @@ export class WorkflowEditDialogComponent
|
||||
filter_has_document_type: new FormControl(
|
||||
trigger.filter_has_document_type
|
||||
),
|
||||
schedule_delay: new FormControl(trigger.schedule_delay),
|
||||
schedule_delay_field: new FormControl(trigger.schedule_delay_field),
|
||||
schedule_delay_custom_field: new FormControl(
|
||||
trigger.schedule_delay_custom_field
|
||||
),
|
||||
}),
|
||||
{ emitEvent }
|
||||
)
|
||||
@@ -388,6 +417,16 @@ export class WorkflowEditDialogComponent
|
||||
return WORKFLOW_TYPE_OPTIONS
|
||||
}
|
||||
|
||||
get scheduleDelayFieldOptions() {
|
||||
return SCHEDULE_DELAY_FIELD_OPTIONS
|
||||
}
|
||||
|
||||
get dateCustomFields() {
|
||||
return this.customFields?.filter(
|
||||
(f) => f.data_type === CustomFieldDataType.Date
|
||||
)
|
||||
}
|
||||
|
||||
getTriggerTypeOptionName(type: WorkflowTriggerType): string {
|
||||
return this.triggerTypeOptions.find((t) => t.id === type)?.name ?? ''
|
||||
}
|
||||
@@ -408,6 +447,9 @@ export class WorkflowEditDialogComponent
|
||||
matching_algorithm: MATCH_NONE,
|
||||
match: '',
|
||||
is_insensitive: true,
|
||||
schedule_delay: null,
|
||||
schedule_delay_field: ScheduleDelayField.Added,
|
||||
schedule_delay_custom_field: null,
|
||||
}
|
||||
this.object.triggers.push(trigger)
|
||||
this.createTriggerField(trigger)
|
||||
|
@@ -10,6 +10,14 @@ export enum WorkflowTriggerType {
|
||||
Consumption = 1,
|
||||
DocumentAdded = 2,
|
||||
DocumentUpdated = 3,
|
||||
Scheduled = 4,
|
||||
}
|
||||
|
||||
export enum ScheduleDelayField {
|
||||
Added = 'added',
|
||||
Created = 'created',
|
||||
Modified = 'modified',
|
||||
CustomField = 'custom_field',
|
||||
}
|
||||
|
||||
export interface WorkflowTrigger extends ObjectWithId {
|
||||
@@ -34,4 +42,10 @@ export interface WorkflowTrigger extends ObjectWithId {
|
||||
filter_has_correspondent?: number // Correspondent.id
|
||||
|
||||
filter_has_document_type?: number // DocumentType.id
|
||||
|
||||
schedule_delay?: string
|
||||
|
||||
schedule_delay_field?: ScheduleDelayField
|
||||
|
||||
schedule_delay_custom_field?: number // CustomField.id
|
||||
}
|
||||
|
Reference in New Issue
Block a user