Skip to content

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

Fix: fix doc link input (#9533)

shamooneb481ac1c093
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 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/common/input/document-link/document-link.component.html</context>
- <context context-type="linenumber">59</context>
+ <context context-type="linenumber">58</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/common/permissions-dialog/permissions-dialog.component.html</context>
@@ -5352,18 +5352,18 @@
<source>Remove link</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/common/input/document-link/document-link.component.html</context>
- <context context-type="linenumber">44</context>
+ <context context-type="linenumber">43</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/common/input/document-link/document-link.component.html</context>
- <context context-type="linenumber">51</context>
+ <context context-type="linenumber">50</context>
</context-group>
</trans-unit>
<trans-unit id="1388712764439031120" datatype="html">
<source>Open link</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/common/input/document-link/document-link.component.html</context>
- <context context-type="linenumber">47</context>
+ <context context-type="linenumber">46</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/common/input/url/url.component.html</context>
@@ -5374,7 +5374,7 @@
<source>Not found</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/common/input/document-link/document-link.component.html</context>
- <context context-type="linenumber">52</context>
+ <context context-type="linenumber">51</context>
</context-group>
</trans-unit>
<trans-unit id="5676637575587497817" datatype="html">
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)">
<ng-template ng-label-tmp let-document="item">
<div class="d-flex align-items-center">
@if (!disabled) {
- <button class="btn p-0 lh-1" (click)="unselect(document)" title="Remove link" i18n-title><i-bs name="x"></i-bs></button>
+ <button class="btn p-0 lh-1" (click)="unselect(document)" type="button" title="Remove link" i18n-title><i-bs name="x"></i-bs></button>
}
@if (document.title) {
<a routerLink="/documents/{{document.id}}" class="badge bg-light text-primary" (mousedown)="$event.stopImmediatePropagation();" title="Open link" i18n-title>
<i-bs width="0.9em" height="0.9em" name="file-text"></i-bs>&nbsp;<span>{{document.title}}</span>
</a>
} @else {
- <span class="badge bg-light text-muted" (click)="unselect(document)" title="Remove link" i18n-title>
+ <span class="badge bg-light text-muted" (click)="unselect(document)" type="button" title="Remove link" i18n-title>
<i-bs width="0.9em" height="0.9em" name="exclamation-triangle-fill"></i-bs>&nbsp;<span i18n>Not found</span>
</span>
}
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()
}