Use the doc title on the frontend

This commit is contained in:
shamoon
2026-09-05 20:59:20 -07:00
parent 649923d639
commit abd08e8000
4 changed files with 22 additions and 3 deletions
@@ -29,9 +29,14 @@
@for (link of links(); track link.id) {
<tr>
<td>
<a routerLink="/documents/{{ link.document }}">
<ng-container i18n>Document #{{ link.document }}</ng-container>
</a>
<a routerLink="/documents/{{ link.document }}">{{ link.document_title | documentTitle }}</a>
<span class="badge bg-primary text-primary-text-contrast ms-3 small fs-normal cursor-pointer" (click)="copyDocumentID(link.document)">
@if (copiedDocumentID() === link.document) {
<i-bs width="1em" height="1em" name="clipboard-check" class="me-1"></i-bs><ng-container i18n>Copied!</ng-container>
} @else {
ID: {{link.document}}
}
</span>
</td>
<td>{{ link.created | date: 'short' }}</td>
<td>
@@ -18,6 +18,7 @@ describe('ShareLinkListComponent', () => {
const link = {
id: 1,
document: 42,
document_title: 'Test document',
slug: 'share-slug',
created: new Date().toISOString(),
expiration: null,
@@ -61,6 +62,7 @@ describe('ShareLinkListComponent', () => {
expect(service.list).toHaveBeenCalledWith(1, 25, 'created', true)
expect(component.links()).toEqual([link])
expect(fixture.nativeElement.textContent).toContain('Test document')
expect(fixture.nativeElement.textContent).toContain('Document #42')
})
@@ -10,6 +10,7 @@ import { LoadingComponentWithPermissions } from 'src/app/components/loading-comp
import { FileVersion, ShareLink } from 'src/app/data/share-link'
import { SHARE_LINK_BUNDLE_FILE_VERSION_LABELS } from 'src/app/data/share-link-bundle'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
import {
PermissionAction,
PermissionType,
@@ -24,6 +25,7 @@ import { environment } from 'src/environments/environment'
imports: [
CommonModule,
ConfirmButtonComponent,
DocumentTitlePipe,
IfPermissionsDirective,
NgbPaginationModule,
NgxBootstrapIconsModule,
@@ -42,6 +44,7 @@ export class ShareLinkListComponent
readonly total = signal(0)
readonly page = signal(1)
readonly copiedID = signal<number | null>(null)
readonly copiedDocumentID = signal<number | null>(null)
readonly error = signal<string | null>(null)
readonly pageSize = 25
readonly PermissionAction = PermissionAction
@@ -114,4 +117,11 @@ export class ShareLinkListComponent
},
})
}
copyDocumentID(documentID: number): void {
if (this.clipboard.copy(documentID.toString())) {
this.copiedDocumentID.set(documentID)
setTimeout(() => this.copiedDocumentID.set(null), 3000)
}
}
}
+2
View File
@@ -26,5 +26,7 @@ export interface ShareLink extends ObjectWithPermissions {
document: number // Document
document_title?: string
file_version: string
}