+
+
-
-
- @if (suggestions?.suggested_tags.length > 0) {
-
Tags
- @for (tag of suggestions.suggested_tags; track tag) {
-
{{ 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) {
-
{{ 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) {
-
{{ correspondent }}
+ @if (suggestions?.suggested_correspondents.length > 0) {
+
Correspondents
+ @for (correspondent of suggestions.suggested_correspondents; track correspondent) {
+
+ }
}
- }
-
+
+
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 01407dfc6..6d202a1b1 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
@@ -29,4 +29,21 @@ describe('SuggestionsDropdownComponent', () => {
}
expect(component.totalSuggestions).toBe(4)
})
+
+ it('should emit getSuggestions when clickSuggest is called and suggestions are null', () => {
+ jest.spyOn(component.getSuggestions, 'emit')
+ component.suggestions = null
+ component.clickSuggest()
+ expect(component.getSuggestions.emit).toHaveBeenCalled()
+ })
+
+ it('should toggle dropdown when clickSuggest is called and suggestions are not null', () => {
+ component.suggestions = {
+ suggested_correspondents: [],
+ suggested_tags: [],
+ suggested_document_types: [],
+ }
+ component.clickSuggest()
+ expect(component.dropdown.open).toBeTruthy()
+ })
})
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 bbdb12c60..485c68627 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
@@ -1,5 +1,11 @@
-import { Component, EventEmitter, Input, Output } from '@angular/core'
-import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'
+import {
+ Component,
+ EventEmitter,
+ Input,
+ Output,
+ ViewChild,
+} from '@angular/core'
+import { NgbDropdown, NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { DocumentSuggestions } from 'src/app/data/document-suggestions'
import { pngxPopperOptions } from 'src/app/utils/popper-options'
@@ -13,6 +19,8 @@ import { pngxPopperOptions } from 'src/app/utils/popper-options'
export class SuggestionsDropdownComponent {
public popperOptions = pngxPopperOptions
+ @ViewChild('dropdown') dropdown: NgbDropdown
+
@Input()
suggestions: DocumentSuggestions = null
@@ -35,6 +43,14 @@ export class SuggestionsDropdownComponent {
@Output()
addCorrespondent: EventEmitter
= new EventEmitter()
+ public clickSuggest(): void {
+ if (!this.suggestions) {
+ this.getSuggestions.emit(this)
+ } else {
+ this.dropdown.toggle()
+ }
+ }
+
get totalSuggestions(): number {
return (
this.suggestions?.suggested_correspondents?.length +