mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Feature: Implement custom fields for documents (#4502)
Adds custom fields of certain data types, attachable to documents and searchable Co-Authored-By: Trenton H <797416+stumpylog@users.noreply.github.com>
This commit is contained in:
@@ -46,6 +46,8 @@ export const FILTER_OWNER_ANY = 33
|
||||
export const FILTER_OWNER_ISNULL = 34
|
||||
export const FILTER_OWNER_DOES_NOT_INCLUDE = 35
|
||||
|
||||
export const FILTER_CUSTOM_FIELDS = 36
|
||||
|
||||
export const FILTER_RULE_TYPES: FilterRuleType[] = [
|
||||
{
|
||||
id: FILTER_TITLE,
|
||||
@@ -271,6 +273,12 @@ export const FILTER_RULE_TYPES: FilterRuleType[] = [
|
||||
datatype: 'number',
|
||||
multi: true,
|
||||
},
|
||||
{
|
||||
id: FILTER_CUSTOM_FIELDS,
|
||||
filtervar: 'custom_fields__icontains',
|
||||
datatype: 'string',
|
||||
multi: false,
|
||||
},
|
||||
]
|
||||
|
||||
export interface FilterRuleType {
|
||||
|
9
src-ui/src/app/data/paperless-custom-field-instance.ts
Normal file
9
src-ui/src/app/data/paperless-custom-field-instance.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ObjectWithId } from './object-with-id'
|
||||
import { PaperlessCustomField } from './paperless-custom-field'
|
||||
|
||||
export interface PaperlessCustomFieldInstance extends ObjectWithId {
|
||||
document: number // PaperlessDocument
|
||||
field: number // PaperlessCustomField
|
||||
created: Date
|
||||
value?: any
|
||||
}
|
48
src-ui/src/app/data/paperless-custom-field.ts
Normal file
48
src-ui/src/app/data/paperless-custom-field.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { ObjectWithId } from './object-with-id'
|
||||
|
||||
export enum PaperlessCustomFieldDataType {
|
||||
String = 'string',
|
||||
Url = 'url',
|
||||
Date = 'date',
|
||||
Boolean = 'boolean',
|
||||
Integer = 'integer',
|
||||
Float = 'float',
|
||||
Monetary = 'monetary',
|
||||
}
|
||||
|
||||
export const DATA_TYPE_LABELS = [
|
||||
{
|
||||
id: PaperlessCustomFieldDataType.Boolean,
|
||||
name: $localize`Boolean`,
|
||||
},
|
||||
{
|
||||
id: PaperlessCustomFieldDataType.Date,
|
||||
name: $localize`Date`,
|
||||
},
|
||||
{
|
||||
id: PaperlessCustomFieldDataType.Integer,
|
||||
name: $localize`Integer`,
|
||||
},
|
||||
{
|
||||
id: PaperlessCustomFieldDataType.Float,
|
||||
name: $localize`Number`,
|
||||
},
|
||||
{
|
||||
id: PaperlessCustomFieldDataType.Monetary,
|
||||
name: $localize`Monetary`,
|
||||
},
|
||||
{
|
||||
id: PaperlessCustomFieldDataType.String,
|
||||
name: $localize`Text`,
|
||||
},
|
||||
{
|
||||
id: PaperlessCustomFieldDataType.Url,
|
||||
name: $localize`Url`,
|
||||
},
|
||||
]
|
||||
|
||||
export interface PaperlessCustomField extends ObjectWithId {
|
||||
data_type: PaperlessCustomFieldDataType
|
||||
name: string
|
||||
created?: Date
|
||||
}
|
@@ -5,6 +5,7 @@ import { Observable } from 'rxjs'
|
||||
import { PaperlessStoragePath } from './paperless-storage-path'
|
||||
import { ObjectWithPermissions } from './object-with-permissions'
|
||||
import { PaperlessDocumentNote } from './paperless-document-note'
|
||||
import { PaperlessCustomFieldInstance } from './paperless-custom-field-instance'
|
||||
|
||||
export interface SearchHit {
|
||||
score?: number
|
||||
@@ -58,4 +59,6 @@ export interface PaperlessDocument extends ObjectWithPermissions {
|
||||
notes?: PaperlessDocumentNote[]
|
||||
|
||||
__search_hit__?: SearchHit
|
||||
|
||||
custom_fields?: PaperlessCustomFieldInstance[]
|
||||
}
|
||||
|
Reference in New Issue
Block a user