mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Mail rule edit dialog
This commit is contained in:
parent
6f25917c86
commit
9231df7a4a
@ -78,6 +78,7 @@ import { SettingsService } from './services/settings.service'
|
|||||||
import { TasksComponent } from './components/manage/tasks/tasks.component'
|
import { TasksComponent } from './components/manage/tasks/tasks.component'
|
||||||
import { TourNgBootstrapModule } from 'ngx-ui-tour-ng-bootstrap'
|
import { TourNgBootstrapModule } from 'ngx-ui-tour-ng-bootstrap'
|
||||||
import { MailAccountEditDialogComponent } from './components/common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component'
|
import { MailAccountEditDialogComponent } from './components/common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component'
|
||||||
|
import { MailRuleEditDialogComponent } from './components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component'
|
||||||
|
|
||||||
import localeBe from '@angular/common/locales/be'
|
import localeBe from '@angular/common/locales/be'
|
||||||
import localeCs from '@angular/common/locales/cs'
|
import localeCs from '@angular/common/locales/cs'
|
||||||
@ -144,7 +145,6 @@ function initializeApp(settings: SettingsService) {
|
|||||||
TagEditDialogComponent,
|
TagEditDialogComponent,
|
||||||
DocumentTypeEditDialogComponent,
|
DocumentTypeEditDialogComponent,
|
||||||
StoragePathEditDialogComponent,
|
StoragePathEditDialogComponent,
|
||||||
MailAccountEditDialogComponent,
|
|
||||||
TagComponent,
|
TagComponent,
|
||||||
ClearableBadge,
|
ClearableBadge,
|
||||||
PageHeaderComponent,
|
PageHeaderComponent,
|
||||||
@ -184,6 +184,8 @@ function initializeApp(settings: SettingsService) {
|
|||||||
DocumentAsnComponent,
|
DocumentAsnComponent,
|
||||||
DocumentCommentsComponent,
|
DocumentCommentsComponent,
|
||||||
TasksComponent,
|
TasksComponent,
|
||||||
|
MailAccountEditDialogComponent,
|
||||||
|
MailRuleEditDialogComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
[closeOnSelect]="false"
|
[closeOnSelect]="false"
|
||||||
[clearSearchOnAdd]="true"
|
[clearSearchOnAdd]="true"
|
||||||
[hideSelected]="true"
|
[hideSelected]="true"
|
||||||
[addTag]="createTagRef"
|
[addTag]="allowCreate ? createTagRef : false"
|
||||||
addTagText="Add tag"
|
addTagText="Add tag"
|
||||||
i18n-addTagText
|
i18n-addTagText
|
||||||
(change)="onChange(value)"
|
(change)="onChange(value)"
|
||||||
@ -31,7 +31,7 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-select>
|
</ng-select>
|
||||||
|
|
||||||
<button class="btn btn-outline-secondary" type="button" (click)="createTag()">
|
<button *ngIf="allowCreate" class="btn btn-outline-secondary" type="button" (click)="createTag()">
|
||||||
<svg class="buttonicon" fill="currentColor">
|
<svg class="buttonicon" fill="currentColor">
|
||||||
<use xlink:href="assets/bootstrap-icons.svg#plus" />
|
<use xlink:href="assets/bootstrap-icons.svg#plus" />
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -54,6 +54,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
|||||||
@Input()
|
@Input()
|
||||||
suggestions: number[]
|
suggestions: number[]
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
allowCreate: boolean = true
|
||||||
|
|
||||||
value: number[]
|
value: number[]
|
||||||
|
|
||||||
tags: PaperlessTag[]
|
tags: PaperlessTag[]
|
||||||
|
@ -35,6 +35,7 @@ import { MailAccountService as MailAccountService } from 'src/app/services/rest/
|
|||||||
import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
|
import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { MailAccountEditDialogComponent } from '../../common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component'
|
import { MailAccountEditDialogComponent } from '../../common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component'
|
||||||
|
import { MailRuleEditDialogComponent } from '../../common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings',
|
selector: 'app-settings',
|
||||||
@ -483,6 +484,7 @@ export class SettingsComponent
|
|||||||
})
|
})
|
||||||
modal.componentInstance.dialogMode = 'edit'
|
modal.componentInstance.dialogMode = 'edit'
|
||||||
modal.componentInstance.object = account
|
modal.componentInstance.object = account
|
||||||
|
// TODO: saving
|
||||||
// modal.componentInstance.success
|
// modal.componentInstance.success
|
||||||
// .pipe(
|
// .pipe(
|
||||||
// switchMap((newStoragePath) => {
|
// switchMap((newStoragePath) => {
|
||||||
@ -500,5 +502,26 @@ export class SettingsComponent
|
|||||||
|
|
||||||
editMailRule(rule: PaperlessMailRule) {
|
editMailRule(rule: PaperlessMailRule) {
|
||||||
console.log(rule)
|
console.log(rule)
|
||||||
|
|
||||||
|
var modal = this.modalService.open(MailRuleEditDialogComponent, {
|
||||||
|
backdrop: 'static',
|
||||||
|
size: 'xl',
|
||||||
|
})
|
||||||
|
modal.componentInstance.dialogMode = 'edit'
|
||||||
|
modal.componentInstance.object = rule
|
||||||
|
// TODO: saving
|
||||||
|
// modal.componentInstance.success
|
||||||
|
// .pipe(
|
||||||
|
// switchMap((newStoragePath) => {
|
||||||
|
// return this.storagePathService
|
||||||
|
// .listAll()
|
||||||
|
// .pipe(map((storagePaths) => ({ newStoragePath, storagePaths })))
|
||||||
|
// })
|
||||||
|
// )
|
||||||
|
// .pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
|
// .subscribe(({ newStoragePath, storagePaths }) => {
|
||||||
|
// this.storagePaths = storagePaths.results
|
||||||
|
// this.documentForm.get('storage_path').setValue(newStoragePath.id)
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,20 @@ export enum MailFilterAttachmentType {
|
|||||||
Everything = 2,
|
Everything = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MailFilterAttachmentTypeOptions: Array<{
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
}> = [
|
||||||
|
{
|
||||||
|
id: MailFilterAttachmentType.Attachments,
|
||||||
|
name: $localize`Only process attachments.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MailFilterAttachmentType.Everything,
|
||||||
|
name: $localize`Process all files, including 'inline' attachments.`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
export enum MailAction {
|
export enum MailAction {
|
||||||
Delete = 1,
|
Delete = 1,
|
||||||
Move = 2,
|
Move = 2,
|
||||||
@ -17,11 +31,42 @@ export enum MailAction {
|
|||||||
Tag = 5,
|
Tag = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MailActionOptions: Array<{ id: number; name: string }> = [
|
||||||
|
{ id: MailAction.Delete, name: $localize`Delete` },
|
||||||
|
{ id: MailAction.Move, name: $localize`Move to specified folder` },
|
||||||
|
{
|
||||||
|
id: MailAction.MarkRead,
|
||||||
|
name: $localize`Mark as read, don't process read mails`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MailAction.Flag,
|
||||||
|
name: $localize`Flag the mail, don't process flagged mails`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MailAction.Tag,
|
||||||
|
name: $localize`Tag the mail with specified tag, don't process tagged mails`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
export enum MailMetadataTitleOption {
|
export enum MailMetadataTitleOption {
|
||||||
FromSubject = 1,
|
FromSubject = 1,
|
||||||
FromFilename = 2,
|
FromFilename = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MailMetadataTitleOptionOptions: Array<{
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
}> = [
|
||||||
|
{
|
||||||
|
id: MailMetadataTitleOption.FromSubject,
|
||||||
|
name: $localize`Use subject as title`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MailMetadataTitleOption.FromFilename,
|
||||||
|
name: $localize`Use attachment filename as title`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
export enum MailMetadataCorrespondentOption {
|
export enum MailMetadataCorrespondentOption {
|
||||||
FromNothing = 1,
|
FromNothing = 1,
|
||||||
FromEmail = 2,
|
FromEmail = 2,
|
||||||
@ -29,6 +74,28 @@ export enum MailMetadataCorrespondentOption {
|
|||||||
FromCustom = 4,
|
FromCustom = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MailMetadataCorrespondentOptionOptions: Array<{
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
}> = [
|
||||||
|
{
|
||||||
|
id: MailMetadataCorrespondentOption.FromNothing,
|
||||||
|
name: $localize`Do not assign a correspondent`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MailMetadataCorrespondentOption.FromEmail,
|
||||||
|
name: $localize`Use mail address`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MailMetadataCorrespondentOption.FromName,
|
||||||
|
name: $localize`Use name (or mail address if not available)`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: MailMetadataCorrespondentOption.FromCustom,
|
||||||
|
name: $localize`Use correspondent selected below`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
export interface PaperlessMailRule extends ObjectWithId {
|
export interface PaperlessMailRule extends ObjectWithId {
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
|
@ -242,10 +242,12 @@ a, a:hover,
|
|||||||
}
|
}
|
||||||
|
|
||||||
.input-group {
|
.input-group {
|
||||||
.ng-select-container {
|
ng-select:not(:last-child) {
|
||||||
height: 100%;
|
.ng-select-container {
|
||||||
border-top-right-radius: 0;
|
height: 100%;
|
||||||
border-bottom-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user