From eb481ac1c09383d4876f8667e872a253b078bcf6 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 31 Mar 2025 19:35:05 -0700 Subject: [PATCH] Fix: fix doc link input (#9533) --- src-ui/messages.xlf | 10 +++++----- .../input/document-link/document-link.component.html | 7 +++---- .../document-link/document-link.component.spec.ts | 5 +++++ .../input/document-link/document-link.component.ts | 4 ++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 683d6db5b..7a7e95891 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -715,7 +715,7 @@ src/app/components/common/input/document-link/document-link.component.html - 59 + 58 src/app/components/common/permissions-dialog/permissions-dialog.component.html @@ -5352,18 +5352,18 @@ Remove link src/app/components/common/input/document-link/document-link.component.html - 44 + 43 src/app/components/common/input/document-link/document-link.component.html - 51 + 50 Open link src/app/components/common/input/document-link/document-link.component.html - 47 + 46 src/app/components/common/input/url/url.component.html @@ -5374,7 +5374,7 @@ Not found src/app/components/common/input/document-link/document-link.component.html - 52 + 51 diff --git a/src-ui/src/app/components/common/input/document-link/document-link.component.html b/src-ui/src/app/components/common/input/document-link/document-link.component.html index 08fe17bc1..6eb380f10 100644 --- a/src-ui/src/app/components/common/input/document-link/document-link.component.html +++ b/src-ui/src/app/components/common/input/document-link/document-link.component.html @@ -30,25 +30,24 @@ [placeholder]="placeholder" [notFoundText]="notFoundText" [multiple]="true" - bindValue="id" [compareWith]="compareDocuments" [trackByFn]="trackByFn" [minTermLength]="2" [loading]="loading" [typeahead]="documentsInput$" (mousedown)="$event.stopImmediatePropagation()" - (change)="onChange(selectedDocuments)"> + (change)="onChange(selectedDocumentIDs)">
@if (!disabled) { - + } @if (document.title) {  {{document.title}} } @else { - +  Not found } diff --git a/src-ui/src/app/components/common/input/document-link/document-link.component.spec.ts b/src-ui/src/app/components/common/input/document-link/document-link.component.spec.ts index 196260f2f..7021012ab 100644 --- a/src-ui/src/app/components/common/input/document-link/document-link.component.spec.ts +++ b/src-ui/src/app/components/common/input/document-link/document-link.component.spec.ts @@ -74,6 +74,11 @@ describe('DocumentLinkComponent', () => { expect(component.selectedDocuments).toEqual([documents[1], documents[0]]) }) + it('should retrieve document IDs from selected documents', () => { + component.selectedDocuments = documents + expect(component.selectedDocumentIDs).toEqual([1, 12, 16, 23]) + }) + it('should search API on select text input', () => { const listSpy = jest.spyOn(documentService, 'listFiltered') listSpy.mockImplementation( diff --git a/src-ui/src/app/components/common/input/document-link/document-link.component.ts b/src-ui/src/app/components/common/input/document-link/document-link.component.ts index a9e6f115a..c5b613ba4 100644 --- a/src-ui/src/app/components/common/input/document-link/document-link.component.ts +++ b/src-ui/src/app/components/common/input/document-link/document-link.component.ts @@ -71,6 +71,10 @@ export class DocumentLinkComponent @Input() placeholder: string = $localize`Search for documents` + get selectedDocumentIDs(): number[] { + return this.selectedDocuments.map((d) => d.id) + } + constructor(private documentsService: DocumentService) { super() }