mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-26 22:49:01 -06:00
Tweakhancement: display document id, with copy (#11896)
This commit is contained in:
@@ -1,9 +1,18 @@
|
|||||||
<div class="row pt-3 pb-3 pb-md-2 align-items-center">
|
<div class="row pt-3 pb-3 pb-md-2 align-items-center">
|
||||||
<div class="col-md text-truncate">
|
<div class="col-md text-truncate">
|
||||||
<h3 class="text-truncate" style="line-height: 1.4">
|
<h3 class="d-flex align-items-center mb-1" style="line-height: 1.4">
|
||||||
{{title}}
|
<span class="text-truncate">{{title}}</span>
|
||||||
|
@if (id) {
|
||||||
|
<span class="badge bg-primary text-primary-text-contrast ms-3 small fs-normal cursor-pointer" (click)="copyID()">
|
||||||
|
@if (copied) {
|
||||||
|
<i-bs width="1em" height="1em" name="clipboard-check"></i-bs> <ng-container i18n>Copied!</ng-container>
|
||||||
|
} @else {
|
||||||
|
ID: {{id}}
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
@if (subTitle) {
|
@if (subTitle) {
|
||||||
<span class="h6 mb-0 d-block d-md-inline fw-normal ms-md-3 text-truncate" style="line-height: 1.4">{{subTitle}}</span>
|
<span class="h6 mb-0 mt-1 d-block d-md-inline fw-normal ms-md-3 text-truncate" style="line-height: 1.4">{{subTitle}}</span>
|
||||||
}
|
}
|
||||||
@if (info) {
|
@if (info) {
|
||||||
<button class="btn btn-sm btn-link text-muted me-auto p-0 p-md-2" title="What's this?" i18n-title type="button" [ngbPopover]="infoPopover" [autoClose]="true">
|
<button class="btn btn-sm btn-link text-muted me-auto p-0 p-md-2" title="What's this?" i18n-title type="button" [ngbPopover]="infoPopover" [autoClose]="true">
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
h3 {
|
h3 {
|
||||||
min-height: calc(1.325rem + 0.9vw);
|
min-height: calc(1.325rem + 0.9vw);
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
font-size: 0.65rem;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Clipboard } from '@angular/cdk/clipboard'
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||||
import { Title } from '@angular/platform-browser'
|
import { Title } from '@angular/platform-browser'
|
||||||
import { environment } from 'src/environments/environment'
|
import { environment } from 'src/environments/environment'
|
||||||
@@ -7,6 +8,7 @@ describe('PageHeaderComponent', () => {
|
|||||||
let component: PageHeaderComponent
|
let component: PageHeaderComponent
|
||||||
let fixture: ComponentFixture<PageHeaderComponent>
|
let fixture: ComponentFixture<PageHeaderComponent>
|
||||||
let titleService: Title
|
let titleService: Title
|
||||||
|
let clipboard: Clipboard
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -15,6 +17,7 @@ describe('PageHeaderComponent', () => {
|
|||||||
}).compileComponents()
|
}).compileComponents()
|
||||||
|
|
||||||
titleService = TestBed.inject(Title)
|
titleService = TestBed.inject(Title)
|
||||||
|
clipboard = TestBed.inject(Clipboard)
|
||||||
fixture = TestBed.createComponent(PageHeaderComponent)
|
fixture = TestBed.createComponent(PageHeaderComponent)
|
||||||
component = fixture.componentInstance
|
component = fixture.componentInstance
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
@@ -24,7 +27,8 @@ describe('PageHeaderComponent', () => {
|
|||||||
component.title = 'Foo'
|
component.title = 'Foo'
|
||||||
component.subTitle = 'Bar'
|
component.subTitle = 'Bar'
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(fixture.nativeElement.textContent).toContain('Foo Bar')
|
expect(fixture.nativeElement.textContent).toContain('Foo')
|
||||||
|
expect(fixture.nativeElement.textContent).toContain('Bar')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should set html title', () => {
|
it('should set html title', () => {
|
||||||
@@ -32,4 +36,16 @@ describe('PageHeaderComponent', () => {
|
|||||||
component.title = 'Foo Bar'
|
component.title = 'Foo Bar'
|
||||||
expect(titleSpy).toHaveBeenCalledWith(`Foo Bar - ${environment.appTitle}`)
|
expect(titleSpy).toHaveBeenCalledWith(`Foo Bar - ${environment.appTitle}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should copy id to clipboard, reset after 3 seconds', () => {
|
||||||
|
jest.useFakeTimers()
|
||||||
|
component.id = 42 as any
|
||||||
|
jest.spyOn(clipboard, 'copy').mockReturnValue(true)
|
||||||
|
component.copyID()
|
||||||
|
expect(clipboard.copy).toHaveBeenCalledWith('42')
|
||||||
|
expect(component.copied).toBe(true)
|
||||||
|
|
||||||
|
jest.advanceTimersByTime(3000)
|
||||||
|
expect(component.copied).toBe(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Clipboard } from '@angular/cdk/clipboard'
|
||||||
import { Component, Input, inject } from '@angular/core'
|
import { Component, Input, inject } from '@angular/core'
|
||||||
import { Title } from '@angular/platform-browser'
|
import { Title } from '@angular/platform-browser'
|
||||||
import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'
|
||||||
@@ -13,8 +14,11 @@ import { environment } from 'src/environments/environment'
|
|||||||
})
|
})
|
||||||
export class PageHeaderComponent {
|
export class PageHeaderComponent {
|
||||||
private titleService = inject(Title)
|
private titleService = inject(Title)
|
||||||
|
private clipboard = inject(Clipboard)
|
||||||
|
|
||||||
_title = ''
|
private _title = ''
|
||||||
|
public copied: boolean = false
|
||||||
|
private copyTimeout: any
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set title(title: string) {
|
set title(title: string) {
|
||||||
@@ -26,6 +30,9 @@ export class PageHeaderComponent {
|
|||||||
return this._title
|
return this._title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
id: number
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
subTitle: string = ''
|
subTitle: string = ''
|
||||||
|
|
||||||
@@ -34,4 +41,12 @@ export class PageHeaderComponent {
|
|||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
infoLink: string
|
infoLink: string
|
||||||
|
|
||||||
|
public copyID() {
|
||||||
|
this.copied = this.clipboard.copy(this.id.toString())
|
||||||
|
clearTimeout(this.copyTimeout)
|
||||||
|
this.copyTimeout = setTimeout(() => {
|
||||||
|
this.copied = false
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<pngx-page-header [(title)]="title">
|
<pngx-page-header [(title)]="title" [id]="documentId">
|
||||||
@if (archiveContentRenderType === ContentRenderType.PDF && !useNativePdfViewer) {
|
@if (archiveContentRenderType === ContentRenderType.PDF && !useNativePdfViewer) {
|
||||||
@if (previewNumPages) {
|
@if (previewNumPages) {
|
||||||
<div class="input-group input-group-sm d-none d-md-flex">
|
<div class="input-group input-group-sm d-none d-md-flex">
|
||||||
|
|||||||
Reference in New Issue
Block a user