diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html index aca9fd72e..87411b8c5 100644 --- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html +++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html @@ -1,6 +1,6 @@
- - @if (aiEnabled()) { -
- +
+ -
-
- @if (novelSuggestions === 0 && fieldSuggestions === 0) { -
- No novel suggestions -
+
+
+ @if (novelSuggestions === 0 && fieldSuggestions === 0) { +
+ No novel suggestions +
+ } + @if (suggestions()?.suggested_tags?.length > 0) { + Tags + @for (tag of suggestions().suggested_tags; track tag) { + } - @if (suggestions()?.suggested_tags?.length > 0) { - Tags - @for (tag of suggestions().suggested_tags; track tag) { - - } + } + @if (suggestions()?.suggested_document_types?.length > 0) { +
Document Types
+ @for (type of suggestions().suggested_document_types; track type) { + } - @if (suggestions()?.suggested_document_types?.length > 0) { -
Document Types
- @for (type of suggestions().suggested_document_types; track type) { - - } + } + @if (suggestions()?.suggested_correspondents?.length > 0) { +
Correspondents
+ @for (correspondent of suggestions().suggested_correspondents; track correspondent) { + } - @if (suggestions()?.suggested_correspondents?.length > 0) { -
Correspondents
- @for (correspondent of suggestions().suggested_correspondents; track correspondent) { - - } - } - @if (fieldSuggestions > 0) { -
- {fieldSuggestions, plural, =1 {1 suggestion available below} other {{{fieldSuggestions}} suggestions available below}} -
- } -
+ } + @if (fieldSuggestions > 0) { +
+ {fieldSuggestions, plural, =1 {1 suggestion available below} other {{{fieldSuggestions}} suggestions available below}} +
+ }
- } +
@if (aiEnabled()) { 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 4395c6038..6cc7cb173 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 @@ -251,6 +251,37 @@ describe('SuggestionsDropdownComponent', () => { expect(fixture.nativeElement.textContent).toContain('No novel suggestions') }) + it('should open ML date suggestions with AI disabled', () => { + const getSuggestions = jest.spyOn(component.getSuggestions, 'emit') + fixture.componentRef.setInput('aiEnabled', false) + fixture.componentRef.setInput('fetchedSources', [SuggestionSource.ML]) + fixture.componentRef.setInput('suggestions', { + dates: ['2026-01-04', '2026-02-01'], + }) + fixture.componentRef.setInput('appliedCreated', '2026-01-04') + fixture.detectChanges() + + const button = fixture.nativeElement.querySelector('button') + expect(button.disabled).toBeFalsy() + expect(button.querySelector('.badge').textContent.trim()).toBe('1') + + button.click() + fixture.detectChanges() + + expect(component.dropdown.isOpen()).toBeTruthy() + expect(fixture.nativeElement.textContent).toContain( + '1 suggestion available below' + ) + expect(getSuggestions).not.toHaveBeenCalled() + expect( + fixture.nativeElement.querySelector('button[title="Suggestion options"]') + ).toBeNull() + + button.click() + fixture.detectChanges() + expect(component.dropdown.isOpen()).toBeFalsy() + }) + it('should fetch unfetched sources and show existing suggestions', () => { jest.spyOn(component.getSuggestions, 'emit') fixture.componentRef.setInput('aiEnabled', true) 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 2c04f6ecc..73086ab12 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 @@ -53,11 +53,7 @@ export class SuggestionsDropdownComponent { addCorrespondent: EventEmitter = new EventEmitter() public clickSuggest(): void { - if ( - this.disabled() || - this.loading() || - (this.suggestions() && !this.aiEnabled()) - ) { + if (this.disabled() || this.loading()) { return }