Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix: dont overcount same title or date suggestions

shamoon6cdb93cd590f
diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts
index 7dfaf376f..4395c6038 100644
--- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts
+++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts
@@ -154,6 +154,19 @@ describe('SuggestionsDropdownComponent', () => {
expect(fixture.nativeElement.textContent).not.toContain('existing value')
})
+ it('should not count title or date suggestions matching the current values', () => {
+ fixture.componentRef.setInput('suggestions', {
+ title: 'Current title',
+ dates: ['2026-01-04', '2026-02-01'],
+ })
+ expect(component.fieldSuggestions).toBe(3)
+
+ fixture.componentRef.setInput('appliedTitle', 'Current title')
+ fixture.componentRef.setInput('appliedCreated', '2026-01-04')
+ expect(component.fieldSuggestions).toBe(1)
+ expect(component.totalSuggestions).toBe(1)
+ })
+
it('should show when a completed request returned no suggestions', () => {
fixture.componentRef.setInput('suggestions', {
correspondents: [],
diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts
index 6290e4867..2c04f6ecc 100644
--- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts
+++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts
@@ -34,6 +34,8 @@ export class SuggestionsDropdownComponent {
readonly appliedCorrespondent = input<number>(null)
readonly appliedDocumentType = input<number>(null)
readonly appliedStoragePath = input<number>(null)
+ readonly appliedTitle = input<string>(null)
+ readonly appliedCreated = input<string>(null)
@Output()
getSuggestions: EventEmitter<SuggestionSource> = new EventEmitter()
@@ -134,11 +136,24 @@ export class SuggestionsDropdownComponent {
get fieldSuggestions(): number {
return (
this.reusableSuggestions +
- (this.suggestions()?.title ? 1 : 0) +
- (this.suggestions()?.dates?.length ?? 0)
+ this.unappliedTitleSuggestions +
+ this.unappliedDateSuggestions
)
}
+ // hide a title or date suggestion equal to the current value
+ private get unappliedTitleSuggestions(): number {
+ const title = this.suggestions()?.title
+ return title && title !== this.appliedTitle() ? 1 : 0
+ }
+
+ private get unappliedDateSuggestions(): number {
+ const created = this.appliedCreated()
+ return (this.suggestions()?.dates ?? []).filter(
+ (date) => !created || date !== created
+ ).length
+ }
+
private countUnapplied(suggested: number[], applied: number[]): number {
return (suggested ?? []).filter((id) => !(applied ?? []).includes(id))
.length
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 c0b7b6321..184b623ab 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
@@ -141,6 +141,8 @@
[appliedCorrespondent]="documentForm.value.correspondent"
[appliedDocumentType]="documentForm.value.document_type"
[appliedStoragePath]="documentForm.value.storage_path"
+ [appliedTitle]="documentForm.value.title"
+ [appliedCreated]="documentForm.value.created"
(getSuggestions)="getSuggestions($event)"
(sourceChange)="suggestionSourceOverride.set($event)"
(addTag)="createTag($event)"