mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Mail rule edit dialog
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<form [formGroup]="objectForm" (ngSubmit)="save()">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modal-basic-title">{{getTitle()}}</h4>
|
||||
<button type="button" [disabled]="!closeEnabled" class="btn-close" aria-label="Close" (click)="cancel()">
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text>
|
||||
<app-input-text i18n-title title="Order" formControlName="order" [error]="error?.order"></app-input-text>
|
||||
<app-input-text i18n-title title="Account" formControlName="account" [error]="error?.account"></app-input-text>
|
||||
<app-input-text i18n-title title="Folder" formControlName="folder" [error]="error?.folder"></app-input-text>
|
||||
<app-input-text i18n-title title="Filter from" formControlName="filter_from" [error]="error?.filter_from"></app-input-text>
|
||||
<app-input-text i18n-title title="Filter body" formControlName="filter_body" [error]="error?.filter_body"></app-input-text>
|
||||
<app-input-text i18n-title title="Filter attachment filename" formControlName="filter_attachment_filename" [error]="error?.filter_attachment_filename"></app-input-text>
|
||||
</div>
|
||||
<div class="col">
|
||||
<app-input-number i18n-title title="Maximum age" formControlName="maximum_age" [error]="error?.maximum_age"></app-input-number>
|
||||
<app-input-select i18n-title title="Attachment type" [items]="attachmentTypeOptions" formControlName="attachment_type"></app-input-select>
|
||||
<app-input-select i18n-title title="Action" [items]="actionOptions" formControlName="attachment_type"></app-input-select>
|
||||
<app-input-text i18n-title title="Action parameter" formControlName="action_parameter" [error]="error?.action_parameter"></app-input-text>
|
||||
</div>
|
||||
<div class="col">
|
||||
<app-input-select i18n-title title="Assign title from" [items]="metadataTitleOptions" formControlName="assign_title_from"></app-input-select>
|
||||
<app-input-tags [allowCreate]="false" formControlName="assign_tags"></app-input-tags>
|
||||
<app-input-select i18n-title title="Assign document type" [items]="documentTypes" formControlName="assign_document_type"></app-input-select>
|
||||
<app-input-select i18n-title title="Assign correspondent from" [items]="metadataCorrespondentOptions" formControlName="assign_correspondent_from"></app-input-select>
|
||||
<app-input-select i18n-title title="Assign correspondent" [items]="correspondents" formControlName="assign_correspondent"></app-input-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" (click)="cancel()" i18n [disabled]="networkActive">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary" i18n [disabled]="networkActive">Save</button>
|
||||
</div>
|
||||
</form>
|
@@ -0,0 +1,98 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { first } from 'rxjs'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
|
||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
|
||||
import {
|
||||
MailAction,
|
||||
MailActionOptions,
|
||||
MailFilterAttachmentType,
|
||||
MailFilterAttachmentTypeOptions,
|
||||
MailMetadataCorrespondentOption,
|
||||
MailMetadataCorrespondentOptionOptions,
|
||||
MailMetadataTitleOption,
|
||||
MailMetadataTitleOptionOptions,
|
||||
PaperlessMailRule,
|
||||
} from 'src/app/data/paperless-mail-rule'
|
||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
|
||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
|
||||
import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-mail-rule-edit-dialog',
|
||||
templateUrl: './mail-rule-edit-dialog.component.html',
|
||||
styleUrls: ['./mail-rule-edit-dialog.component.scss'],
|
||||
})
|
||||
export class MailRuleEditDialogComponent extends EditDialogComponent<PaperlessMailRule> {
|
||||
correspondents: PaperlessCorrespondent[]
|
||||
documentTypes: PaperlessDocumentType[]
|
||||
|
||||
constructor(
|
||||
service: MailRuleService,
|
||||
activeModal: NgbActiveModal,
|
||||
correspondentService: CorrespondentService,
|
||||
documentTypeService: DocumentTypeService
|
||||
) {
|
||||
super(service, activeModal)
|
||||
|
||||
correspondentService
|
||||
.listAll()
|
||||
.pipe(first())
|
||||
.subscribe((result) => (this.correspondents = result.results))
|
||||
|
||||
documentTypeService
|
||||
.listAll()
|
||||
.pipe(first())
|
||||
.subscribe((result) => (this.documentTypes = result.results))
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
return $localize`Create new mail rule`
|
||||
}
|
||||
|
||||
getEditTitle() {
|
||||
return $localize`Edit mail rule`
|
||||
}
|
||||
|
||||
getForm(): FormGroup {
|
||||
return new FormGroup({
|
||||
name: new FormControl(null),
|
||||
order: new FormControl(null),
|
||||
account: new FormControl(null),
|
||||
folder: new FormControl('INBOX'),
|
||||
filter_from: new FormControl(null),
|
||||
filter_subject: new FormControl(null),
|
||||
filter_body: new FormControl(null),
|
||||
filter_attachment_filename: new FormControl(null),
|
||||
maximum_age: new FormControl(null),
|
||||
attachment_type: new FormControl(MailFilterAttachmentType.Attachments),
|
||||
action: new FormControl(MailAction.MarkRead),
|
||||
action_parameter: new FormControl(null),
|
||||
assign_title_from: new FormControl(MailMetadataTitleOption.FromSubject),
|
||||
assign_tags: new FormControl(null),
|
||||
assign_document_type: new FormControl(null),
|
||||
assign_correspondent_from: new FormControl(
|
||||
MailMetadataCorrespondentOption.FromNothing
|
||||
),
|
||||
assign_correspondent: new FormControl(null),
|
||||
})
|
||||
}
|
||||
|
||||
get attachmentTypeOptions() {
|
||||
return MailFilterAttachmentTypeOptions
|
||||
}
|
||||
|
||||
get actionOptions() {
|
||||
return MailActionOptions
|
||||
}
|
||||
|
||||
get metadataTitleOptions() {
|
||||
return MailMetadataTitleOptionOptions
|
||||
}
|
||||
|
||||
get metadataCorrespondentOptions() {
|
||||
return MailMetadataCorrespondentOptionOptions
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user