]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: fix doc link input (#9533)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Tue, 1 Apr 2025 02:35:05 +0000 (19:35 -0700)
committerGitHub <noreply@github.com>
Tue, 1 Apr 2025 02:35:05 +0000 (19:35 -0700)
src-ui/messages.xlf
src-ui/src/app/components/common/input/document-link/document-link.component.html
src-ui/src/app/components/common/input/document-link/document-link.component.spec.ts
src-ui/src/app/components/common/input/document-link/document-link.component.ts

index 683d6db5b248e426277fffafb1ee5bb1106ad42b..7a7e958914d6683779718dbccc34bdfc35c1d843 100644 (file)
         </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>
         <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>
         <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">
index 08fe17bc13e01d797f8fb7abbf91746ae7b177f2..6eb380f106eae630038a7e27684ca2477b4a726d 100644 (file)
     [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>
         }
index 196260f2f8bb3821bc219a3a9c1deecb1b1f2f55..7021012ab3de5acfa7204bd3046678c51ad8ed03 100644 (file)
@@ -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(
index a9e6f115a1010ecf7649536ee4041ee3323c4c3b..c5b613ba4988dee5e4ce8dc12eba181bc036e24a 100644 (file)
@@ -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()
   }