mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Enhancement: support assigning custom fields via consumption templates (#4727)
This commit is contained in:
		| @@ -35,6 +35,7 @@ | ||||
|               <pngx-input-select i18n-title title="Assign document type" [items]="documentTypes" [allowNull]="true" formControlName="assign_document_type"></pngx-input-select> | ||||
|               <pngx-input-select i18n-title title="Assign correspondent" [items]="correspondents" [allowNull]="true" formControlName="assign_correspondent"></pngx-input-select> | ||||
|               <pngx-input-select i18n-title title="Assign storage path" [items]="storagePaths" [allowNull]="true" formControlName="assign_storage_path"></pngx-input-select> | ||||
|               <pngx-input-select i18n-title title="Assign custom fields" multiple="true" [items]="customFields" [allowNull]="true" formControlName="assign_custom_fields"></pngx-input-select> | ||||
|           </div> | ||||
|           <div class="col"> | ||||
|             <pngx-input-select i18n-title title="Assign owner" [items]="users" bindLabel="username" formControlName="assign_owner" [allowNull]="true"></pngx-input-select> | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import { TagsComponent } from '../../input/tags/tags.component' | ||||
| import { TextComponent } from '../../input/text/text.component' | ||||
| import { EditDialogMode } from '../edit-dialog.component' | ||||
| import { ConsumptionTemplateEditDialogComponent } from './consumption-template-edit-dialog.component' | ||||
| import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' | ||||
|  | ||||
| describe('ConsumptionTemplateEditDialogComponent', () => { | ||||
|   let component: ConsumptionTemplateEditDialogComponent | ||||
| @@ -93,6 +94,15 @@ describe('ConsumptionTemplateEditDialogComponent', () => { | ||||
|               }), | ||||
|           }, | ||||
|         }, | ||||
|         { | ||||
|           provide: CustomFieldsService, | ||||
|           useValue: { | ||||
|             listAll: () => | ||||
|               of({ | ||||
|                 results: [], | ||||
|               }), | ||||
|           }, | ||||
|         }, | ||||
|       ], | ||||
|       imports: [ | ||||
|         HttpClientTestingModule, | ||||
|   | ||||
| @@ -18,6 +18,8 @@ import { SettingsService } from 'src/app/services/settings.service' | ||||
| import { EditDialogComponent } from '../edit-dialog.component' | ||||
| import { MailRuleService } from 'src/app/services/rest/mail-rule.service' | ||||
| import { PaperlessMailRule } from 'src/app/data/paperless-mail-rule' | ||||
| import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' | ||||
| import { PaperlessCustomField } from 'src/app/data/paperless-custom-field' | ||||
|  | ||||
| export const DOCUMENT_SOURCE_OPTIONS = [ | ||||
|   { | ||||
| @@ -45,6 +47,7 @@ export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent< | ||||
|   documentTypes: PaperlessDocumentType[] | ||||
|   storagePaths: PaperlessStoragePath[] | ||||
|   mailRules: PaperlessMailRule[] | ||||
|   customFields: PaperlessCustomField[] | ||||
|  | ||||
|   constructor( | ||||
|     service: ConsumptionTemplateService, | ||||
| @@ -54,7 +57,8 @@ export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent< | ||||
|     storagePathService: StoragePathService, | ||||
|     mailRuleService: MailRuleService, | ||||
|     userService: UserService, | ||||
|     settingsService: SettingsService | ||||
|     settingsService: SettingsService, | ||||
|     customFieldsService: CustomFieldsService | ||||
|   ) { | ||||
|     super(service, activeModal, userService, settingsService) | ||||
|  | ||||
| @@ -77,6 +81,11 @@ export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent< | ||||
|       .listAll() | ||||
|       .pipe(first()) | ||||
|       .subscribe((result) => (this.mailRules = result.results)) | ||||
|  | ||||
|     customFieldsService | ||||
|       .listAll() | ||||
|       .pipe(first()) | ||||
|       .subscribe((result) => (this.customFields = result.results)) | ||||
|   } | ||||
|  | ||||
|   getCreateTitle() { | ||||
| @@ -106,6 +115,7 @@ export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent< | ||||
|       assign_view_groups: new FormControl([]), | ||||
|       assign_change_users: new FormControl([]), | ||||
|       assign_change_groups: new FormControl([]), | ||||
|       assign_custom_fields: new FormControl([]), | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -38,4 +38,6 @@ export interface PaperlessConsumptionTemplate extends ObjectWithId { | ||||
|   assign_change_users?: number[] // [PaperlessUser.id] | ||||
|  | ||||
|   assign_change_groups?: number[] // [PaperlessGroup.id] | ||||
|  | ||||
|   assign_custom_fields?: number[] // [PaperlessCustomField.id] | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon