Merge branch 'dev' into feature/ocr-templates

This commit is contained in:
shamoon committed 2026-11-02 21:44:11 -08:00
commit 2b620a2823
408 files changed
+6392 -5987

No files matched your search

@@ -33,9 +33,9 @@
i18n-title
>
@if (copiedIndex() === $index) {
<i-bs name="clipboard-check"></i-bs>
<pngx-bs-icon name="clipboard-check"></pngx-bs-icon>
} @else {
<i-bs name="clipboard"></i-bs>
<pngx-bs-icon name="clipboard"></pngx-bs-icon>
}
<span class="visually-hidden" i18n>Copy content</span>
</button>
@@ -1,6 +1,5 @@
import { Clipboard } from '@angular/cdk/clipboard'
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { DocumentBarcodesComponent } from './document-barcodes.component'
const barcodes = [
@@ -16,10 +15,7 @@ describe('DocumentBarcodesComponent', () => {
beforeEach(async () => {
TestBed.configureTestingModule({
imports: [
DocumentBarcodesComponent,
NgxBootstrapIconsModule.pick(allIcons),
],
imports: [DocumentBarcodesComponent],
}).compileComponents()
fixture = TestBed.createComponent(DocumentBarcodesComponent)
@@ -53,15 +49,15 @@ describe('DocumentBarcodesComponent', () => {
fixture.detectChanges()
expect(copySpy).toHaveBeenCalledWith('ASN00123')
expect(component.copiedIndex()).toEqual(0)
expect(buttons[0].querySelector('i-bs').getAttribute('name')).toEqual(
'clipboard-check'
)
expect(
buttons[0].querySelector('pngx-bs-icon').getAttribute('name')
).toEqual('clipboard-check')
jest.advanceTimersByTime(3000)
fixture.detectChanges()
expect(component.copiedIndex()).toBeNull()
expect(buttons[0].querySelector('i-bs').getAttribute('name')).toEqual(
'clipboard'
)
expect(
buttons[0].querySelector('pngx-bs-icon').getAttribute('name')
).toEqual('clipboard')
jest.useRealTimers()
})
@@ -1,12 +1,12 @@
import { Clipboard } from '@angular/cdk/clipboard'
import { Component, inject, input, OnDestroy, signal } from '@angular/core'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { BootstrapIconComponent } from 'src/app/components/common/bootstrap-icon/bootstrap-icon.component'
import { DocumentBarcode } from 'src/app/data/document-barcode'
@Component({
selector: 'pngx-document-barcodes',
templateUrl: './document-barcodes.component.html',
imports: [NgxBootstrapIconsModule],
imports: [BootstrapIconComponent],
})
export class DocumentBarcodesComponent implements OnDestroy {
private readonly clipboard = inject(Clipboard)
@@ -1,6 +1,6 @@
<pngx-page-header [title]="title()" [id]="documentId()">
<button type="button" class="btn btn-sm btn-outline-danger me-md-4" (click)="delete()" [disabled]="!userIsOwner" *pngxIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.Document }" aria-label="Delete" i18n-aria-label>
<i-bs width="1.2em" height="1.2em" name="trash"></i-bs><span class="d-none d-lg-inline ps-1" i18n>Delete</span>
<pngx-bs-icon width="1.2em" height="1.2em" name="trash"></pngx-bs-icon><span class="d-none d-lg-inline ps-1" i18n>Delete</span>
</button>
<pngx-document-version-dropdown
@@ -13,12 +13,12 @@
(versionsUpdated)="onVersionsUpdated($event)"
/>
<div class="btn-group ms-4">
<div class="btn-group ms-md-4">
<button (click)="download()" class="btn btn-sm btn-outline-primary" [disabled]="downloading()" aria-label="Download" i18n-aria-label>
@if (downloading()) {
<div class="spinner-border spinner-border-sm" role="status"></div>
} @else {
<i-bs width="1.2em" height="1.2em" name="download"></i-bs>
<pngx-bs-icon width="1.2em" height="1.2em" name="download"></pngx-bs-icon>
}
<span class="d-none d-lg-inline ps-1" i18n>Download</span>
</button>
@@ -40,25 +40,25 @@
</div>
</div>
<div class="ms-auto" ngbDropdown>
<div class="ms-md-auto" ngbDropdown>
<button class="btn btn-sm btn-outline-primary" id="actionsDropdown" ngbDropdownToggle aria-label="Actions" i18n-aria-label>
<i-bs name="three-dots"></i-bs><div class="d-none d-sm-inline ms-1"><ng-container i18n>Actions</ng-container></div>
<pngx-bs-icon name="three-dots"></pngx-bs-icon><div class="d-none d-sm-inline ms-1"><ng-container i18n>Actions</ng-container></div>
</button>
<div ngbDropdownMenu aria-labelledby="actionsDropdown" class="shadow">
<button ngbDropdownItem (click)="reprocess()" [disabled]="!userCanEdit || !userIsOwner">
<i-bs width="1em" height="1em" name="arrow-counterclockwise" class="me-2"></i-bs><span i18n>Reprocess</span>
<pngx-bs-icon width="1em" height="1em" name="arrow-counterclockwise" class="me-2"></pngx-bs-icon><span i18n>Reprocess</span>
</button>
<button ngbDropdownItem (click)="printDocument()" [hidden]="useNativePdfViewer || isMobile">
<i-bs width="1em" height="1em" name="printer" class="me-2"></i-bs><span i18n>Print</span>
<pngx-bs-icon width="1em" height="1em" name="printer" class="me-2"></pngx-bs-icon><span i18n>Print</span>
</button>
<button ngbDropdownItem (click)="moreLike()">
<i-bs width="1em" height="1em" name="diagram-3" class="me-2"></i-bs><span i18n>More like this</span>
<pngx-bs-icon width="1em" height="1em" name="diagram-3" class="me-2"></pngx-bs-icon><span i18n>More like this</span>
</button>
<button ngbDropdownItem (click)="editPdf()" [disabled]="!userIsOwner || !userCanEdit || originalContentRenderType !== ContentRenderType.PDF">
<i-bs name="pencil" class="me-2"></i-bs><ng-container i18n>PDF Editor</ng-container>
<pngx-bs-icon name="pencil" class="me-2"></pngx-bs-icon><ng-container i18n>PDF Editor</ng-container>
</button>
<div class="d-flex" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.OcrTemplate }">
@@ -79,23 +79,23 @@
@if (userIsOwner && (requiresPassword || password)) {
<button ngbDropdownItem (click)="removePassword()" [disabled]="!password">
<i-bs name="unlock" class="me-2"></i-bs><ng-container i18n>Remove Password</ng-container>
<pngx-bs-icon name="unlock" class="me-2"></pngx-bs-icon><ng-container i18n>Remove Password</ng-container>
</button>
}
</div>
</div>
<div class="ms-auto" ngbDropdown>
<div class="ms-md-auto" ngbDropdown>
<button class="btn btn-sm btn-outline-primary" id="sendDropdown" ngbDropdownToggle aria-label="Send" i18n-aria-label>
<i-bs name="send"></i-bs><div class="d-none d-sm-inline ms-1"><ng-container i18n>Send</ng-container></div>
<pngx-bs-icon name="send"></pngx-bs-icon><div class="d-none d-sm-inline ms-1"><ng-container i18n>Send</ng-container></div>
</button>
<div ngbDropdownMenu aria-labelledby="sendDropdown" class="shadow">
<button ngbDropdownItem (click)="openShareLinks()" *pngxIfPermissions="{ action: PermissionAction.Add, type: PermissionType.ShareLink }">
<i-bs name="link" class="me-2"></i-bs><span i18n>Share Links</span>
<pngx-bs-icon name="link" class="me-2"></pngx-bs-icon><span i18n>Share Links</span>
</button>
@if (emailEnabled) {
<button ngbDropdownItem (click)="openEmailDocument()">
<i-bs name="envelope" class="me-2"></i-bs><span i18n>Email</span>
<pngx-bs-icon name="envelope" class="me-2"></pngx-bs-icon><span i18n>Email</span>
</button>
}
</div>
@@ -111,13 +111,13 @@
<div class="btn-toolbar mb-1 pb-3 gap-2 row-gap-2 border-bottom">
<div class="btn-group">
<button type="button" class="btn btn-sm btn-outline-secondary" i18n-title title="Close" (click)="close()">
<i-bs width="1.2em" height="1.2em" name="x"></i-bs>
<pngx-bs-icon width="1.2em" height="1.2em" name="x"></pngx-bs-icon>
</button>
<button type="button" class="btn btn-sm btn-outline-secondary" i18n-title title="Previous" (click)="previousDoc()" [disabled]="!hasPrevious()">
<i-bs width="1.2em" height="1.2em" name="arrow-left"></i-bs>
<pngx-bs-icon width="1.2em" height="1.2em" name="arrow-left"></pngx-bs-icon>
</button>
<button type="button" class="btn btn-sm btn-outline-secondary" i18n-title title="Next" (click)="nextDoc()" [disabled]="!hasNext()">
<i-bs width="1.2em" height="1.2em" name="arrow-right"></i-bs>
<pngx-bs-icon width="1.2em" height="1.2em" name="arrow-right"></pngx-bs-icon>
</button>
</div>
@@ -324,7 +324,7 @@
</tr>
<tr class="align-middle">
<td i18n>Original SHA256 checksum</td>
<td><span class="badge bg-light font-monospace text-wrap text-break text-start">{{metadata()?.original_checksum}}</span></td>
<td><span class="badge bg-light text-dark font-monospace text-wrap text-break text-start">{{metadata()?.original_checksum}}</span></td>
</tr>
<tr>
<td i18n>Original file size</td>
@@ -454,13 +454,26 @@
<ng-template #saveButtons>
<div class="btn-group">
<ng-container *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Document }">
<button type="submit" class="order-3 btn btn-sm btn-primary" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Save</button>
<button type="submit" class="order-3 btn btn-sm btn-primary" title="Save" i18n-title [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">
<pngx-bs-icon class="d-md-none" width="1.2em" height="1.2em" name="floppy"></pngx-bs-icon><span class="d-none d-md-inline" i18n>Save</span>
</button>
@if (hasNext()) {
<button type="button" class="order-1 btn btn-sm btn-outline-primary" (click)="saveEditNext()" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Save &amp; next</button>
<button type="button" class="order-1 btn btn-sm btn-outline-primary d-none d-md-inline-block" (click)="saveEditNext()" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Save &amp; next</button>
} @else {
<button type="button" class="order-2 btn btn-sm btn-outline-primary" (click)="save(true)" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Save &amp; close</button>
<button type="button" class="order-2 btn btn-sm btn-outline-primary d-none d-md-inline-block" (click)="save(true)" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Save &amp; close</button>
}
<button type="button" class="order-0 btn btn-sm btn-outline-secondary" (click)="discard()" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Discard</button>
<button type="button" class="order-0 btn btn-sm btn-outline-secondary" (click)="discard()" title="Discard" i18n-title [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">
<pngx-bs-icon class="d-md-none" width="1.2em" height="1.2em" name="arrow-counterclockwise"></pngx-bs-icon><span class="d-none d-md-inline" i18n>Discard</span>
</button>
<div class="btn-group order-4 d-md-none" ngbDropdown placement="bottom-end top-end" role="group">
<button type="button" class="btn btn-sm btn-outline-primary dropdown-toggle dropdown-toggle-split" ngbDropdownToggle aria-label="More save options" i18n-aria-label [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true"></button>
<div class="dropdown-menu shadow" ngbDropdownMenu>
@if (hasNext()) {
<button type="button" ngbDropdownItem (click)="saveEditNext()" i18n>Save &amp; next</button>
}
<button type="button" ngbDropdownItem (click)="save(true)" i18n>Save &amp; close</button>
</div>
</div>
</ng-container>
</div>
</ng-template>
@@ -481,7 +494,7 @@
@switch (archiveContentRenderType) {
@case (ContentRenderType.PDF) {
@if (!useNativePdfViewer) {
<div class="preview-sticky pdf-viewer-container">
<div class="preview-sticky pdf-viewer-container" tabindex="-1">
<pngx-pdf-viewer
[src]="pdfSource()"
[sourceRevision]="previewRevision()"
@@ -493,7 +506,7 @@
(loadError)="onError($event)"
(afterLoadComplete)="pdfPreviewLoaded($event)">
</pngx-pdf-viewer>
<div class="position-absolute bottom-0 start-50 translate-middle-x z-1 mb-3 d-flex gap-2 p-1 bg-body border rounded shadow">
<div class="preview-controls position-absolute bottom-0 start-50 translate-middle-x z-1 mb-3 d-flex gap-2 p-1 bg-body border rounded shadow">
@if (previewNumPages()) {
<div class="input-group input-group-sm w-auto flex-nowrap">
<input class="form-control flex-grow-0 w-auto" type="number" min="1" [max]="previewNumPages()" [ngModelOptions]="{standalone: true}" [ngModel]="previewCurrentPage()" (ngModelChange)="previewCurrentPage.set($event)" aria-label="Page" i18n-aria-label />
@@ -501,8 +514,8 @@
</div>
}
<div class="input-group input-group-sm w-auto flex-nowrap">
<button class="btn btn-outline-secondary" (click)="decreaseZoom()" aria-label="Zoom out" i18n-aria-label>
<i-bs width="1em" height="1em" name="dash"></i-bs>
<button class="btn btn-outline-secondary" type="button" (click)="decreaseZoom()" aria-label="Zoom out" i18n-aria-label>
<pngx-bs-icon width="1em" height="1em" name="dash"></pngx-bs-icon>
</button>
<select class="form-select" (change)="setZoom($event.target.value)" [ngModelOptions]="{standalone: true}" [ngModel]="currentZoom" aria-label="Zoom" i18n-aria-label>
@for (setting of zoomSettings; track setting) {
@@ -511,8 +524,8 @@
</option>
}
</select>
<button class="btn btn-outline-secondary" (click)="increaseZoom()" aria-label="Zoom in" i18n-aria-label>
<i-bs width="1em" height="1em" name="plus"></i-bs>
<button class="btn btn-outline-secondary" type="button" (click)="increaseZoom()" aria-label="Zoom in" i18n-aria-label>
<pngx-bs-icon width="1em" height="1em" name="plus"></pngx-bs-icon>
</button>
</div>
</div>
@@ -12,6 +12,22 @@
width: 100%;
height: 100%;
}
&:focus {
outline: none;
}
.preview-controls {
opacity: 0;
pointer-events: none;
transition: opacity 0.15s ease-in-out;
}
&:hover .preview-controls,
&:focus-within .preview-controls {
opacity: 1;
pointer-events: auto;
}
}
.btn-group .dropdown-toggle-split {
@@ -48,8 +64,11 @@ textarea.rtl {
.btn-group .btn.order-3 {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-top-right-radius: var(--bs-border-radius-sm);
border-bottom-right-radius: var(--bs-border-radius-sm);
@media screen and (min-width: 768px) {
border-top-right-radius: var(--bs-border-radius-sm);
border-bottom-right-radius: var(--bs-border-radius-sm);
}
}
.preview-sticky img {
@@ -22,7 +22,6 @@ import {
NgbModal,
NgbModalRef,
} from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { DeviceDetectorService } from 'ngx-device-detector'
import { Subject, of, throwError } from 'rxjs'
import { routes } from 'src/app/app-routing.module'
@@ -152,11 +151,7 @@ describe('DocumentDetailComponent', () => {
beforeEach(async () => {
TestBed.configureTestingModule({
imports: [
DocumentDetailComponent,
RouterModule.forRoot(routes),
NgxBootstrapIconsModule.pick(allIcons),
],
imports: [DocumentDetailComponent, RouterModule.forRoot(routes)],
providers: [
DocumentTitlePipe,
{
@@ -890,31 +885,31 @@ describe('DocumentDetailComponent', () => {
fixture.detectChanges()
expect(
fixture.debugElement
.queryAll(By.css('button'))
.find((b) => b.nativeElement.textContent === 'Save')
.queryAll(By.css('button.btn'))
.find((b) => b.nativeElement.textContent.trim() === 'Save')
).not.toBeUndefined()
expect(
fixture.debugElement
.queryAll(By.css('button'))
.find((b) => b.nativeElement.textContent === 'Save & close')
.queryAll(By.css('button.btn'))
.find((b) => b.nativeElement.textContent.trim() === 'Save & close')
).not.toBeUndefined()
expect(
fixture.debugElement
.queryAll(By.css('button'))
.find((b) => b.nativeElement.textContent === 'Save & next')
.queryAll(By.css('button.btn'))
.find((b) => b.nativeElement.textContent.trim() === 'Save & next')
).toBeUndefined()
nextSpy.mockReturnValue(true)
component.networkActive.set(true)
fixture.detectChanges()
expect(
fixture.debugElement
.queryAll(By.css('button'))
.find((b) => b.nativeElement.textContent === 'Save & close')
.queryAll(By.css('button.btn'))
.find((b) => b.nativeElement.textContent.trim() === 'Save & close')
).toBeUndefined()
expect(
fixture.debugElement
.queryAll(By.css('button'))
.find((b) => b.nativeElement.textContent === 'Save & next')
.queryAll(By.css('button.btn'))
.find((b) => b.nativeElement.textContent.trim() === 'Save & next')
).not.toBeUndefined()
})
@@ -26,7 +26,6 @@ import {
NgbNavModule,
} from '@ng-bootstrap/ng-bootstrap'
import { dirtyCheck, DirtyComponent } from '@ngneat/dirty-check-forms'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { DeviceDetectorService } from 'ngx-device-detector'
import { BehaviorSubject, merge, Observable, of, Subject, timer } from 'rxjs'
import {
@@ -41,6 +40,7 @@ import {
takeUntil,
tap,
} from 'rxjs/operators'
import { BootstrapIconComponent } from 'src/app/components/common/bootstrap-icon/bootstrap-icon.component'
import { Correspondent } from 'src/app/data/correspondent'
import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
import { CustomFieldInstance } from 'src/app/data/custom-field-instance'
@@ -200,7 +200,7 @@ interface IncomingDocumentUpdate {
SafeUrlPipe,
NgbNavModule,
NgbDropdownModule,
NgxBootstrapIconsModule,
BootstrapIconComponent,
TextAreaComponent,
RouterModule,
PngxPdfViewerComponent,
@@ -47,6 +47,8 @@
<span>{{ change.key | titlecase }}</span>:&nbsp;
@if (change.key === 'content') {
<code class="text-primary">{{ change.value[1]?.substring(0,100) }}...</code>
} @else if (change.key === 'tags') {
<code class="text-primary">{{ getTagNames($any(change.value[1])) | async }}</code>
} @else {
<code class="text-primary">{{ getPrettyName(change.key, change.value[1]) | async }}</code>
}
@@ -4,7 +4,6 @@ import { DatePipe } from '@angular/common'
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { of } from 'rxjs'
import { AuditLogAction } from 'src/app/data/auditlog-entry'
import { DataType } from 'src/app/data/datatype'
@@ -12,6 +11,7 @@ import { CorrespondentService } from 'src/app/services/rest/correspondent.servic
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
import { DocumentService } from 'src/app/services/rest/document.service'
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { TagService } from 'src/app/services/rest/tag.service'
import { UserService } from 'src/app/services/rest/user.service'
import { DocumentHistoryComponent } from './document-history.component'
@@ -26,11 +26,7 @@ describe('DocumentHistoryComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
DocumentHistoryComponent,
NgbCollapseModule,
NgxBootstrapIconsModule.pick(allIcons),
],
imports: [DocumentHistoryComponent, NgbCollapseModule],
providers: [
DatePipe,
provideHttpClient(withInterceptorsFromDi()),
@@ -174,6 +170,39 @@ describe('DocumentHistoryComponent', () => {
})
})
it('should render bulk tag history with names and preserve missing tag IDs', () => {
const getCachedSpy = jest
.spyOn(TestBed.inject(TagService), 'getCached')
.mockImplementation((id) =>
of(id === 1 ? { id: 1, name: 'Invoice' } : null)
)
component.entries.set([
{
id: 1,
action: AuditLogAction.Update,
timestamp: '2021-01-01T00:00:00Z',
remote_addr: null,
changes: JSON.parse('{"tags":[[],[1,2345]]}'),
},
])
component.loading.set(false)
fixture.detectChanges()
expect(fixture.nativeElement.querySelector('code').textContent).toBe(
'Invoice, 2345'
)
fixture.detectChanges()
expect(getCachedSpy).toHaveBeenCalledTimes(2)
})
it('should handle removal of all tags without a lookup', () => {
const getCachedSpy = jest.spyOn(TestBed.inject(TagService), 'getCached')
component.getTagNames([]).subscribe((result) => {
expect(result).toBe('')
})
expect(getCachedSpy).not.toHaveBeenCalled()
})
it('getPrettyName should return the value as is for other types', () => {
const id = '123'
component.getPrettyName('other', id).subscribe((result) => {
@@ -1,8 +1,7 @@
import { AsyncPipe, KeyValuePipe, TitleCasePipe } from '@angular/common'
import { Component, Input, OnInit, inject, signal } from '@angular/core'
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { Observable, first, map, of, shareReplay } from 'rxjs'
import { Observable, first, forkJoin, map, of, shareReplay } from 'rxjs'
import { AuditLogAction, AuditLogEntry } from 'src/app/data/auditlog-entry'
import { DataType } from 'src/app/data/datatype'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
@@ -10,6 +9,7 @@ import { CorrespondentService } from 'src/app/services/rest/correspondent.servic
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
import { DocumentService } from 'src/app/services/rest/document.service'
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { TagService } from 'src/app/services/rest/tag.service'
import { UserService } from 'src/app/services/rest/user.service'
@Component({
@@ -22,7 +22,6 @@ import { UserService } from 'src/app/services/rest/user.service'
AsyncPipe,
KeyValuePipe,
TitleCasePipe,
NgxBootstrapIconsModule,
],
})
export class DocumentHistoryComponent implements OnInit {
@@ -30,6 +29,7 @@ export class DocumentHistoryComponent implements OnInit {
private readonly correspondentService = inject(CorrespondentService)
private readonly storagePathService = inject(StoragePathService)
private readonly documentTypeService = inject(DocumentTypeService)
private readonly tagService = inject(TagService)
private readonly userService = inject(UserService)
public AuditLogAction = AuditLogAction
@@ -63,6 +63,30 @@ export class DocumentHistoryComponent implements OnInit {
}
}
getTagNames(tagIds: number[]): Observable<string> {
const cacheKey = `tags:${JSON.stringify(tagIds)}`
const cachedNames = this.prettyNameCache.get(cacheKey)
if (cachedNames) {
return cachedNames
}
const tagNames$ = tagIds.length
? forkJoin(
tagIds.map((tagId) =>
this.tagService.getCached(tagId).pipe(
first(),
map((tag) => tag?.name ?? String(tagId))
)
)
).pipe(map((names) => names.join(', ')))
: of('')
const names$ = tagNames$.pipe(
shareReplay({ bufferSize: 1, refCount: true })
)
this.prettyNameCache.set(cacheKey, names$)
return names$
}
getPrettyName(type: DataType | string, id: string): Observable<string> {
const cacheKey = `${type}:${id}`
const cached = this.prettyNameCache.get(cacheKey)
@@ -1,6 +1,6 @@
<div class="btn-group" ngbDropdown autoClose="outside">
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" ngbDropdownToggle aria-label="Versions" i18n-aria-label>
<i-bs name="file-earmark-diff"></i-bs>
<pngx-bs-icon name="file-earmark-diff"></pngx-bs-icon>
<span class="d-none d-lg-inline ps-1" i18n>Versions</span>
@if (versions.length > 1) {
<span class="badge text-bg-secondary ms-1">{{ versions.length }}</span>
@@ -35,7 +35,7 @@
title="Upload a new version"
i18n-title
>
<i-bs name="file-earmark-plus"></i-bs><span class="ps-1" i18n>Upload</span>
<pngx-bs-icon name="file-earmark-plus"></pngx-bs-icon><span class="ps-1" i18n>Upload</span>
</button>
<button
class="btn btn-sm btn-outline-secondary w-100"
@@ -44,7 +44,7 @@
title="Use an existing document"
i18n-title
>
<i-bs name="file-earmark"></i-bs><span class="ps-1" i18n>Existing</span>
<pngx-bs-icon name="file-earmark"></pngx-bs-icon><span class="ps-1" i18n>Existing</span>
</button>
</div>
} @else {
@@ -81,9 +81,9 @@
>
<div class="check mx-3">
@if (selectedVersionId === version.id) {
<i-bs name="check-circle"></i-bs>
<pngx-bs-icon name="check-circle"></pngx-bs-icon>
} @else {
<i-bs class="text-muted" name="circle"></i-bs>
<pngx-bs-icon class="text-muted" name="circle"></pngx-bs-icon>
}
</div>
<div class="d-flex flex-column">
@@ -121,9 +121,9 @@
(click)="isEditingVersion(version.id) ? submitEditedVersionLabel(version, $event) : beginEditingVersion(version, $event)"
>
@if (isEditingVersion(version.id)) {
<i-bs width=".8rem" height=".8rem" name="check-lg"></i-bs>
<pngx-bs-icon width=".8rem" height=".8rem" name="check-lg"></pngx-bs-icon>
} @else {
<i-bs width=".8rem" height=".8rem" name="pencil"></i-bs>
<pngx-bs-icon width=".8rem" height=".8rem" name="pencil"></pngx-bs-icon>
}
</button>
}
@@ -3,13 +3,12 @@ import { SimpleChange, signal } from '@angular/core'
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { By } from '@angular/platform-browser'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { Subject, of, throwError } from 'rxjs'
import { DocumentVersionInfo } from 'src/app/data/document'
import {
PermissionAction,
PermissionsService,
PermissionType,
PermissionsService,
} from 'src/app/services/permissions.service'
import { DocumentService } from 'src/app/services/rest/document.service'
import { SettingsService } from 'src/app/services/settings.service'
@@ -64,10 +63,7 @@ describe('DocumentVersionDropdownComponent', () => {
}
await TestBed.configureTestingModule({
imports: [
DocumentVersionDropdownComponent,
NgxBootstrapIconsModule.pick(allIcons),
],
imports: [DocumentVersionDropdownComponent],
providers: [
DatePipe,
{
@@ -12,7 +12,6 @@ import {
} from '@angular/core'
import { FormsModule } from '@angular/forms'
import { NgbDropdownModule, NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { merge, of, Subject } from 'rxjs'
import {
filter,
@@ -24,6 +23,7 @@ import {
takeUntil,
tap,
} from 'rxjs/operators'
import { BootstrapIconComponent } from 'src/app/components/common/bootstrap-icon/bootstrap-icon.component'
import { DocumentVersionInfo } from 'src/app/data/document'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
@@ -44,7 +44,7 @@ import { AddExistingDocumentVersionDialogComponent } from './add-existing-docume
imports: [
FormsModule,
NgbDropdownModule,
NgxBootstrapIconsModule,
BootstrapIconComponent,
ConfirmButtonComponent,
IfPermissionsDirective,
SlicePipe,
@@ -2,10 +2,10 @@
<button type="button" class="btn btn-outline-secondary btn-sm me-2"
(click)="expand = !expand" aria-label="Toggle document metadata" i18n-aria-label>
@if (!expand) {
<i-bs width="1.2em" height="1.2em" name="caret-down"></i-bs>
<pngx-bs-icon width="1.2em" height="1.2em" name="caret-down"></pngx-bs-icon>
}
@if (expand) {
<i-bs width="1.2em" height="1.2em" name="caret-up"></i-bs>
<pngx-bs-icon width="1.2em" height="1.2em" name="caret-up"></pngx-bs-icon>
}
</button>
{{title}}
@@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { MetadataCollapseComponent } from './metadata-collapse.component'
const metadata = [
@@ -24,10 +23,7 @@ describe('MetadataCollapseComponent', () => {
beforeEach(async () => {
TestBed.configureTestingModule({
providers: [],
imports: [
MetadataCollapseComponent,
NgxBootstrapIconsModule.pick(allIcons),
],
imports: [MetadataCollapseComponent],
}).compileComponents()
fixture = TestBed.createComponent(MetadataCollapseComponent)
@@ -1,12 +1,12 @@
import { Component, Input } from '@angular/core'
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { BootstrapIconComponent } from 'src/app/components/common/bootstrap-icon/bootstrap-icon.component'
@Component({
selector: 'pngx-metadata-collapse',
templateUrl: './metadata-collapse.component.html',
styleUrls: ['./metadata-collapse.component.scss'],
imports: [NgbCollapseModule, NgxBootstrapIconsModule],
imports: [NgbCollapseModule, BootstrapIconComponent],
})
export class MetadataCollapseComponent {
constructor() {}