This commit is contained in:
shamoon
2024-10-23 21:43:17 -07:00
parent 3cb3bad862
commit 2c05247d84
12 changed files with 106 additions and 116 deletions

View File

@@ -120,18 +120,18 @@
<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>
<p class="small" i18n>Set scheduled trigger offset 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>
<pngx-input-number i18n-title title="Offset" formControlName="schedule_offset_days" i18n-hint hint="Offset in days. Use 0 for immediate." [error]="error?.schedule_offset_days"></pngx-input-number>
<pngx-input-check i18n-title title="Repeat" formControlName="schedule_is_recurring" i18n-hint hint="Repeat the trigger after the delay." [error]="error?.schedule_is_recurring"></pngx-input-check>
</div>
<div class="col-4">
<pngx-input-select i18n-title title="Relative to" formControlName="schedule_delay_field" [items]="scheduleDelayFieldOptions" [error]="error?.schedule_delay_field"></pngx-input-select>
<pngx-input-select i18n-title title="Relative to" formControlName="schedule_date_field" [items]="scheduleDateFieldOptions" [error]="error?.schedule_date_field"></pngx-input-select>
</div>
@if (formGroup.get('schedule_delay_field').value === 'custom_field') {
@if (formGroup.get('schedule_date_field').value === 'custom_field') {
<div class="col-4">
<pngx-input-select i18n-title title="Delay custom 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>
<pngx-input-select i18n-title title="Delay custom field" formControlName="schedule_date_custom_field" [items]="dateCustomFields" i18n-hint hint="Custom field to use for date." [error]="error?.schedule_date_custom_field"></pngx-input-select>
</div>
}
</div>

View File

@@ -19,7 +19,7 @@ import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service
import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
import {
DocumentSource,
ScheduleDelayField,
ScheduleDateField,
WorkflowTrigger,
WorkflowTriggerType,
} from 'src/app/data/workflow-trigger'
@@ -49,21 +49,21 @@ export const DOCUMENT_SOURCE_OPTIONS = [
},
]
export const SCHEDULE_DELAY_FIELD_OPTIONS = [
export const SCHEDULE_DATE_FIELD_OPTIONS = [
{
id: ScheduleDelayField.Added,
id: ScheduleDateField.Added,
name: $localize`Added`,
},
{
id: ScheduleDelayField.Created,
id: ScheduleDateField.Created,
name: $localize`Created`,
},
{
id: ScheduleDelayField.Modified,
id: ScheduleDateField.Modified,
name: $localize`Modified`,
},
{
id: ScheduleDelayField.CustomField,
id: ScheduleDateField.CustomField,
name: $localize`Custom Field`,
},
]
@@ -338,11 +338,11 @@ export class WorkflowEditDialogComponent
filter_has_document_type: new FormControl(
trigger.filter_has_document_type
),
schedule_delay: new FormControl(trigger.schedule_delay),
schedule_offset_days: new FormControl(trigger.schedule_offset_days),
schedule_is_recurring: new FormControl(trigger.schedule_is_recurring),
schedule_delay_field: new FormControl(trigger.schedule_delay_field),
schedule_delay_custom_field: new FormControl(
trigger.schedule_delay_custom_field
schedule_date_field: new FormControl(trigger.schedule_date_field),
schedule_date_custom_field: new FormControl(
trigger.schedule_date_custom_field
),
}),
{ emitEvent }
@@ -418,8 +418,8 @@ export class WorkflowEditDialogComponent
return WORKFLOW_TYPE_OPTIONS
}
get scheduleDelayFieldOptions() {
return SCHEDULE_DELAY_FIELD_OPTIONS
get scheduleDateFieldOptions() {
return SCHEDULE_DATE_FIELD_OPTIONS
}
get dateCustomFields() {
@@ -448,10 +448,10 @@ export class WorkflowEditDialogComponent
matching_algorithm: MATCH_NONE,
match: '',
is_insensitive: true,
schedule_delay: null,
schedule_offset_days: null,
schedule_is_recurring: false,
schedule_delay_field: ScheduleDelayField.Added,
schedule_delay_custom_field: null,
schedule_date_field: ScheduleDateField.Added,
schedule_date_custom_field: null,
}
this.object.triggers.push(trigger)
this.createTriggerField(trigger)

View File

@@ -13,7 +13,7 @@ export enum WorkflowTriggerType {
Scheduled = 4,
}
export enum ScheduleDelayField {
export enum ScheduleDateField {
Added = 'added',
Created = 'created',
Modified = 'modified',
@@ -43,11 +43,11 @@ export interface WorkflowTrigger extends ObjectWithId {
filter_has_document_type?: number // DocumentType.id
schedule_delay?: string
schedule_offset_days?: number
schedule_is_recurring?: boolean
schedule_delay_field?: ScheduleDelayField
schedule_date_field?: ScheduleDateField
schedule_delay_custom_field?: number // CustomField.id
schedule_date_custom_field?: number // CustomField.id
}