Fix: dont overcount same title or date suggestions

This commit is contained in:
shamoon committed 2026-10-05 20:18:09 -07:00
1 parent 85fcf66691
commit 6cdb93cd59
3 files changed
+32 -2

No files matched your search

@@ -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