diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf
index 8bc640c33..d105ae31d 100644
--- a/src-ui/messages.xlf
+++ b/src-ui/messages.xlf
@@ -146,35 +146,35 @@
Confirm delete
src/app/components/document-detail/document-detail.component.ts
- 192
+ 199
Do you really want to delete document ""?
src/app/components/document-detail/document-detail.component.ts
- 193
+ 200
The files for this document will be deleted permanently. This operation cannot be undone.
src/app/components/document-detail/document-detail.component.ts
- 194
+ 201
Delete document
src/app/components/document-detail/document-detail.component.ts
- 196
+ 203
Error deleting document:
src/app/components/document-detail/document-detail.component.ts
- 203
+ 210
@@ -1288,6 +1288,13 @@
27
+
+ Suggested:
+
+ src/app/components/common/input/select/select.component.html
+ 26
+
+
Save current view
@@ -1509,49 +1516,49 @@
ASN
src/app/services/rest/document.service.ts
- 16
+ 17
Correspondent
src/app/services/rest/document.service.ts
- 17
+ 18
Title
src/app/services/rest/document.service.ts
- 18
+ 19
Document type
src/app/services/rest/document.service.ts
- 19
+ 20
Created
src/app/services/rest/document.service.ts
- 20
+ 21
Added
src/app/services/rest/document.service.ts
- 21
+ 22
Modified
src/app/services/rest/document.service.ts
- 22
+ 23
diff --git a/src-ui/src/app/components/common/input/select/select.component.html b/src-ui/src/app/components/common/input/select/select.component.html
index aa500d0d1..973b09a55 100644
--- a/src-ui/src/app/components/common/input/select/select.component.html
+++ b/src-ui/src/app/components/common/input/select/select.component.html
@@ -22,4 +22,12 @@
{{hint}}
+ 0">
+ Suggested:
+
+ {{s.name}}
+
+
+
+
diff --git a/src-ui/src/app/components/common/input/select/select.component.ts b/src-ui/src/app/components/common/input/select/select.component.ts
index 18f30cf6e..e02aaab72 100644
--- a/src-ui/src/app/components/common/input/select/select.component.ts
+++ b/src-ui/src/app/components/common/input/select/select.component.ts
@@ -30,11 +30,22 @@ export class SelectComponent extends AbstractInputComponent {
@Input()
allowNull: boolean = false
+ @Input()
+ suggestions: number[]
+
@Output()
createNew = new EventEmitter()
-
+
showPlusButton(): boolean {
return this.createNew.observers.length > 0
}
+ getSuggestions() {
+ if (this.suggestions && this.items) {
+ return this.suggestions.filter(id => id != this.value).map(id => this.items.find(item => item.id == id))
+ } else {
+ return []
+ }
+ }
+
}
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.html b/src-ui/src/app/components/common/input/tags/tags.component.html
index c9a0c96d6..22a7e640a 100644
--- a/src-ui/src/app/components/common/input/tags/tags.component.html
+++ b/src-ui/src/app/components/common/input/tags/tags.component.html
@@ -2,30 +2,25 @@
{{hint}}
+ 0">
+ Suggested:
+
+ {{tag.name}}
+
+
+
+
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.ts b/src-ui/src/app/components/common/input/tags/tags.component.ts
index 5501ac5a6..f77d0570d 100644
--- a/src-ui/src/app/components/common/input/tags/tags.component.ts
+++ b/src-ui/src/app/components/common/input/tags/tags.component.ts
@@ -26,9 +26,6 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
writeValue(newValue: number[]): void {
this.value = newValue
- if (this.tags) {
- this.displayValue = newValue
- }
}
registerOnChange(fn: any): void {
this.onChange = fn;
@@ -43,7 +40,6 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
ngOnInit(): void {
this.tagService.listAll().subscribe(result => {
this.tags = result.results
- this.displayValue = this.value
})
}
@@ -53,23 +49,28 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
@Input()
hint
- value: number[]
+ @Input()
+ suggestions: number[]
- displayValue: number[] = []
+ value: number[]
tags: PaperlessTag[]
getTag(id) {
- return this.tags.find(tag => tag.id == id)
+ if (this.tags) {
+ return this.tags.find(tag => tag.id == id)
+ } else {
+ return null
+ }
}
removeTag(id) {
- let index = this.displayValue.indexOf(id)
+ let index = this.value.indexOf(id)
if (index > -1) {
- let oldValue = this.displayValue
+ let oldValue = this.value
oldValue.splice(index, 1)
- this.displayValue = [...oldValue]
- this.onChange(this.displayValue)
+ this.value = [...oldValue]
+ this.onChange(this.value)
}
}
@@ -79,15 +80,23 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
modal.componentInstance.success.subscribe(newTag => {
this.tagService.listAll().subscribe(tags => {
this.tags = tags.results
- this.displayValue = [...this.displayValue, newTag.id]
- this.onChange(this.displayValue)
+ this.value = [...this.value, newTag.id]
+ this.onChange(this.value)
})
})
}
- ngSelectChange() {
- this.value = this.displayValue
- this.onChange(this.displayValue)
+ getSuggestions() {
+ if (this.suggestions && this.tags) {
+ return this.suggestions.filter(id => !this.value.includes(id)).map(id => this.tags.find(tag => tag.id == id))
+ } else {
+ return []
+ }
+ }
+
+ addTag(id) {
+ this.value = [...this.value, id]
+ this.onChange(this.value)
}
}
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html
index 639b9e260..2814a1242 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.html
+++ b/src-ui/src/app/components/document-detail/document-detail.component.html
@@ -60,10 +60,10 @@
+ (createNew)="createCorrespondent()" [suggestions]="suggestions?.correspondents">
-
+ (createNew)="createDocumentType()" [suggestions]="suggestions?.document_types">
+
@@ -145,6 +145,6 @@
-
+
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts
index aa2308eac..a7cce715e 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.ts
@@ -19,6 +19,7 @@ import { PDFDocumentProxy } from 'ng2-pdf-viewer';
import { ToastService } from 'src/app/services/toast.service';
import { TextComponent } from '../common/input/text/text.component';
import { SettingsService, SETTINGS_KEYS } from 'src/app/services/settings.service';
+import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions';
@Component({
selector: 'app-document-detail',
@@ -40,6 +41,8 @@ export class DocumentDetailComponent implements OnInit {
documentId: number
document: PaperlessDocument
metadata: PaperlessDocumentMetadata
+ suggestions: PaperlessDocumentSuggestions
+
title: string
previewUrl: string
downloadUrl: string
@@ -95,6 +98,7 @@ export class DocumentDetailComponent implements OnInit {
this.previewUrl = this.documentsService.getPreviewUrl(this.documentId)
this.downloadUrl = this.documentsService.getDownloadUrl(this.documentId)
this.downloadOriginalUrl = this.documentsService.getDownloadUrl(this.documentId, true)
+ this.suggestions = null
if (this.openDocumentService.getOpenDocument(this.documentId)) {
this.updateComponent(this.openDocumentService.getOpenDocument(this.documentId))
} else {
@@ -112,6 +116,9 @@ export class DocumentDetailComponent implements OnInit {
this.documentsService.getMetadata(doc.id).subscribe(result => {
this.metadata = result
})
+ this.documentsService.getSuggestions(doc.id).subscribe(result => {
+ this.suggestions = result
+ })
this.title = this.documentTitlePipe.transform(doc.title)
this.documentForm.patchValue(doc)
}
diff --git a/src-ui/src/app/data/paperless-document-suggestions.ts b/src-ui/src/app/data/paperless-document-suggestions.ts
new file mode 100644
index 000000000..71459eff2
--- /dev/null
+++ b/src-ui/src/app/data/paperless-document-suggestions.ts
@@ -0,0 +1,9 @@
+export interface PaperlessDocumentSuggestions {
+
+ tags?: number[]
+
+ correspondents?: number[]
+
+ document_types?: number[]
+
+}
\ No newline at end of file
diff --git a/src-ui/src/app/services/rest/document.service.ts b/src-ui/src/app/services/rest/document.service.ts
index dd2c32fa8..19b18cfeb 100644
--- a/src-ui/src/app/services/rest/document.service.ts
+++ b/src-ui/src/app/services/rest/document.service.ts
@@ -11,6 +11,7 @@ import { CorrespondentService } from './correspondent.service';
import { DocumentTypeService } from './document-type.service';
import { TagService } from './tag.service';
import { FILTER_RULE_TYPES } from 'src/app/data/filter-rule-type';
+import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions';
export const DOCUMENT_SORT_FIELDS = [
{ field: 'archive_serial_number', name: $localize`ASN` },
@@ -129,4 +130,8 @@ export class DocumentService extends AbstractPaperlessService
return this.http.post(this.getResourceUrl(null, 'selection_data'), {"documents": ids})
}
+ getSuggestions(id: number): Observable {
+ return this.http.get(this.getResourceUrl(id, 'suggestions'))
+ }
+
}