]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
fix edit dialog getters
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Mon, 28 Nov 2022 21:58:37 +0000 (13:58 -0800)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Sat, 3 Dec 2022 17:31:39 +0000 (09:31 -0800)
src-ui/src/app/components/common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component.ts
src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.html
src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.ts
src-ui/src/app/components/manage/settings/settings.component.ts

index 98c897c899788429763e6ad8670162744287dcbc..b2edb9219e16f1fe7c7a94d47c854259c7127092 100644 (file)
@@ -8,6 +8,12 @@ import {
 } from 'src/app/data/paperless-mail-account'
 import { MailAccountService } from 'src/app/services/rest/mail-account.service'
 
+const IMAP_SECURITY_OPTIONS = [
+  { id: IMAPSecurity.None, name: $localize`No encryption` },
+  { id: IMAPSecurity.SSL, name: $localize`SSL` },
+  { id: IMAPSecurity.STARTTLS, name: $localize`STARTTLS` },
+]
+
 @Component({
   selector: 'app-mail-account-edit-dialog',
   templateUrl: './mail-account-edit-dialog.component.html',
@@ -39,10 +45,6 @@ export class MailAccountEditDialogComponent extends EditDialogComponent<Paperles
   }
 
   get imapSecurityOptions() {
-    return [
-      { id: IMAPSecurity.None, name: $localize`No encryption` },
-      { id: IMAPSecurity.SSL, name: $localize`SSL` },
-      { id: IMAPSecurity.STARTTLS, name: $localize`STARTTLS` },
-    ]
+    return IMAP_SECURITY_OPTIONS
   }
 }
index dc4260ffd42f6f9b2f204aef0ed722522bab4efc..ef9a5bc479347a721b87649dfb777ed799e5942b 100644 (file)
@@ -21,7 +21,7 @@
         <app-input-text i18n-title title="Filter attachment filename" formControlName="filter_attachment_filename" i18n-hint hint="Only consume documents which entirely match this filename if specified. Wildcards such as *.pdf or *invoice* are allowed. Case insensitive." [error]="error?.filter_attachment_filename"></app-input-text>
       </div>
       <div class="col">
-        <app-input-select i18n-title title="Action" [items]="actionOptions" formControlName="attachment_type" i18n-hint hint="Action is only performed when documents are consumed from the mail. Mails without attachments remain entirely untouched."></app-input-select>
+        <app-input-select i18n-title title="Action" [items]="actionOptions" formControlName="action" i18n-hint hint="Action is only performed when documents are consumed from the mail. Mails without attachments remain entirely untouched."></app-input-select>
         <app-input-text i18n-title title="Action parameter" formControlName="action_parameter" [error]="error?.action_parameter"></app-input-text>
         <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>
index 7644ed353988847a01ba4dab77b37794fac7646e..3dcd7ce01c00047c57d9c4a9df4151bf68cacdcf 100644 (file)
@@ -18,6 +18,70 @@ import { DocumentTypeService } from 'src/app/services/rest/document-type.service
 import { MailAccountService } from 'src/app/services/rest/mail-account.service'
 import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
 
+const ATTACHMENT_TYPE_OPTIONS = [
+  {
+    id: MailFilterAttachmentType.Attachments,
+    name: $localize`Only process attachments.`,
+  },
+  {
+    id: MailFilterAttachmentType.Everything,
+    name: $localize`Process all files, including 'inline' attachments.`,
+  },
+]
+
+const ACTION_OPTIONS = [
+  {
+    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`,
+  },
+]
+
+const METADATA_TITLE_OPTIONS = [
+  {
+    id: MailMetadataTitleOption.FromSubject,
+    name: $localize`Use subject as title`,
+  },
+  {
+    id: MailMetadataTitleOption.FromFilename,
+    name: $localize`Use attachment filename as title`,
+  },
+]
+
+const METADATA_CORRESPONDENT_OPTIONS = [
+  {
+    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`,
+  },
+]
+
 @Component({
   selector: 'app-mail-rule-edit-dialog',
   templateUrl: './mail-rule-edit-dialog.component.html',
@@ -92,74 +156,18 @@ export class MailRuleEditDialogComponent extends EditDialogComponent<PaperlessMa
   }
 
   get attachmentTypeOptions() {
-    return [
-      {
-        id: MailFilterAttachmentType.Attachments,
-        name: $localize`Only process attachments.`,
-      },
-      {
-        id: MailFilterAttachmentType.Everything,
-        name: $localize`Process all files, including 'inline' attachments.`,
-      },
-    ]
+    return ATTACHMENT_TYPE_OPTIONS
   }
 
   get actionOptions() {
-    return [
-      {
-        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`,
-      },
-    ]
+    return ACTION_OPTIONS
   }
 
   get metadataTitleOptions() {
-    return [
-      {
-        id: MailMetadataTitleOption.FromSubject,
-        name: $localize`Use subject as title`,
-      },
-      {
-        id: MailMetadataTitleOption.FromFilename,
-        name: $localize`Use attachment filename as title`,
-      },
-    ]
+    return METADATA_TITLE_OPTIONS
   }
 
   get metadataCorrespondentOptions() {
-    return [
-      {
-        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`,
-      },
-    ]
+    return METADATA_CORRESPONDENT_OPTIONS
   }
 }
index b461e90b752c321e4c0605400e0c90011397ef3b..1c51c90b2d240963b4d8a305beb11a746abdf599 100644 (file)
@@ -524,7 +524,7 @@ export class SettingsComponent
   }
 
   editMailAccount(account: PaperlessMailAccount) {
-    var modal = this.modalService.open(MailAccountEditDialogComponent, {
+    const modal = this.modalService.open(MailAccountEditDialogComponent, {
       backdrop: 'static',
       size: 'xl',
     })
@@ -552,7 +552,7 @@ export class SettingsComponent
   }
 
   deleteMailAccount(account: PaperlessMailAccount) {
-    let modal = this.modalService.open(ConfirmDialogComponent, {
+    const modal = this.modalService.open(ConfirmDialogComponent, {
       backdrop: 'static',
     })
     modal.componentInstance.title = $localize`Confirm delete mail account`
@@ -582,7 +582,7 @@ export class SettingsComponent
   }
 
   editMailRule(rule: PaperlessMailRule) {
-    var modal = this.modalService.open(MailRuleEditDialogComponent, {
+    const modal = this.modalService.open(MailRuleEditDialogComponent, {
       backdrop: 'static',
       size: 'xl',
     })
@@ -611,7 +611,7 @@ export class SettingsComponent
   }
 
   deleteMailRule(rule: PaperlessMailRule) {
-    let modal = this.modalService.open(ConfirmDialogComponent, {
+    const modal = this.modalService.open(ConfirmDialogComponent, {
       backdrop: 'static',
     })
     modal.componentInstance.title = $localize`Confirm delete mail rule`