This commit is contained in:
shamoon
2026-02-08 23:47:06 -08:00
parent 1f64f6caff
commit e3d3feca23
7 changed files with 37 additions and 40 deletions

View File

@@ -42,14 +42,14 @@ export class CustomFieldsComponent
extends LoadingComponentWithPermissions extends LoadingComponentWithPermissions
implements OnInit implements OnInit
{ {
private customFieldsService = inject(CustomFieldsService) private readonly customFieldsService = inject(CustomFieldsService)
permissionsService = inject(PermissionsService) public readonly permissionsService = inject(PermissionsService)
private modalService = inject(NgbModal) private readonly modalService = inject(NgbModal)
private toastService = inject(ToastService) private readonly toastService = inject(ToastService)
private documentListViewService = inject(DocumentListViewService) private readonly documentListViewService = inject(DocumentListViewService)
private settingsService = inject(SettingsService) private readonly settingsService = inject(SettingsService)
private documentService = inject(DocumentService) private readonly documentService = inject(DocumentService)
private savedViewService = inject(SavedViewService) private readonly savedViewService = inject(SavedViewService)
public fields: CustomField[] = [] public fields: CustomField[] = []

View File

@@ -136,7 +136,7 @@ export class DocumentAttributesComponent
] ]
@ViewChild('activeOutlet', { read: NgComponentOutlet }) @ViewChild('activeOutlet', { read: NgComponentOutlet })
private activeOutlet?: NgComponentOutlet private readonly activeOutlet?: NgComponentOutlet
private lastHeaderLoading: boolean private lastHeaderLoading: boolean

View File

@@ -36,7 +36,7 @@ import { ManagementListComponent } from '../management-list.component'
], ],
}) })
export class CorrespondentListComponent extends ManagementListComponent<Correspondent> { export class CorrespondentListComponent extends ManagementListComponent<Correspondent> {
private datePipe = inject(CustomDatePipe) private readonly datePipe = inject(CustomDatePipe)
constructor() { constructor() {
super() super()

View File

@@ -29,19 +29,19 @@
<table class="table table-striped align-middle shadow-sm mb-0"> <table class="table table-striped align-middle shadow-sm mb-0">
<thead> <thead>
<tr> <tr>
<th scope="col"> <th>
<div class="form-check m-0 ms-2 me-n2"> <div class="form-check m-0 ms-2 me-n2">
<input type="checkbox" class="form-check-input" id="all-objects" [(ngModel)]="togggleAll" [disabled]="data.length === 0" (change)="selectPage($event.target.checked); $event.stopPropagation();"> <input type="checkbox" class="form-check-input" id="all-objects" [(ngModel)]="togggleAll" [disabled]="data.length === 0" (change)="$event.target.checked ? selectPage() : clearSelection(); $event.stopPropagation();">
<label class="form-check-label" for="all-objects"></label> <label class="form-check-label" for="all-objects"></label>
</div> </div>
</th> </th>
<th scope="col" class="fw-normal" pngxSortable="name" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Name</th> <th class="fw-normal" pngxSortable="name" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Name</th>
<th scope="col" class="fw-normal d-none d-sm-table-cell" pngxSortable="matching_algorithm" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Matching</th> <th class="fw-normal d-none d-sm-table-cell" pngxSortable="matching_algorithm" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Matching</th>
<th scope="col" class="fw-normal" pngxSortable="document_count" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Document count</th> <th class="fw-normal" pngxSortable="document_count" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Document count</th>
@for (column of extraColumns; track column) { @for (column of extraColumns; track column) {
<th scope="col" class="fw-normal" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }" pngxSortable="{{column.key}}" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)">{{column.name}}</th> <th class="fw-normal" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }" pngxSortable="{{column.key}}" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)">{{column.name}}</th>
} }
<th scope="col" class="fw-normal" i18n>Actions</th> <th class="fw-normal" i18n>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -84,16 +84,16 @@
<label class="form-check-label" for="{{typeName}}{{object.id}}"></label> <label class="form-check-label" for="{{typeName}}{{object.id}}"></label>
</div> </div>
</td> </td>
<td scope="row" class="name-cell" style="--depth: {{depth}}"> <td class="name-cell" style="--depth: {{depth}}">
@if (depth > 0) { @if (depth > 0) {
<div class="indicator"></div> <div class="indicator"></div>
} }
<button class="btn btn-link ms-0 ps-0 text-start" (click)="userCanEdit(object) ? openEditDialog(object) : null; $event.stopPropagation()">{{ object.name }}</button> <button class="btn btn-link ms-0 ps-0 text-start" (click)="userCanEdit(object) ? openEditDialog(object) : null; $event.stopPropagation()">{{ object.name }}</button>
</td> </td>
<td scope="row" class="d-none d-sm-table-cell">{{ getMatching(object) }}</td> <td class="d-none d-sm-table-cell">{{ getMatching(object) }}</td>
<td scope="row">{{ getDocumentCount(object) }}</td> <td>{{ getDocumentCount(object) }}</td>
@for (column of extraColumns; track column) { @for (column of extraColumns; track column) {
<td scope="row" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }"> <td [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }">
@if (column.badgeFn) { @if (column.badgeFn) {
<span <span
class="badge" class="badge"
@@ -109,7 +109,7 @@
} }
</td> </td>
} }
<td scope="row"> <td>
<div class="btn-toolbar gap-2"> <div class="btn-toolbar gap-2">
<div class="btn-group d-block d-sm-none"> <div class="btn-group d-block d-sm-none">
<div ngbDropdown container="body" class="d-inline-block"> <div ngbDropdown container="body" class="d-inline-block">

View File

@@ -304,12 +304,12 @@ describe('ManagementListComponent', () => {
}) })
it('selectPage should select current page items or clear selection', () => { it('selectPage should select current page items or clear selection', () => {
component.selectPage(true) component.selectPage()
expect(component.selectedObjects).toEqual(new Set(tags.map((t) => t.id))) expect(component.selectedObjects).toEqual(new Set(tags.map((t) => t.id)))
expect(component.togggleAll).toBe(true) expect(component.togggleAll).toBe(true)
component.togggleAll = true component.togggleAll = true
component.selectPage(false) component.clearSelection()
expect(component.selectedObjects.size).toBe(0) expect(component.selectedObjects.size).toBe(0)
expect(component.togggleAll).toBe(false) expect(component.togggleAll).toBe(false)
}) })

View File

@@ -69,13 +69,14 @@ export abstract class ManagementListComponent<T extends MatchingModel>
implements OnInit, OnDestroy implements OnInit, OnDestroy
{ {
protected service: AbstractNameFilterService<T> protected service: AbstractNameFilterService<T>
private modalService: NgbModal = inject(NgbModal) private readonly modalService: NgbModal = inject(NgbModal)
protected editDialogComponent: any protected editDialogComponent: any
private toastService: ToastService = inject(ToastService) private readonly toastService: ToastService = inject(ToastService)
private documentListViewService: DocumentListViewService = inject( private readonly documentListViewService: DocumentListViewService = inject(
DocumentListViewService DocumentListViewService
) )
private permissionsService: PermissionsService = inject(PermissionsService) private readonly permissionsService: PermissionsService =
inject(PermissionsService)
protected filterRuleType: number protected filterRuleType: number
public typeName: string public typeName: string
public typeNamePlural: string public typeNamePlural: string
@@ -196,7 +197,7 @@ export abstract class ManagementListComponent<T extends MatchingModel>
} }
openCreateDialog() { openCreateDialog() {
var activeModal = this.modalService.open(this.editDialogComponent, { const activeModal = this.modalService.open(this.editDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
activeModal.componentInstance.dialogMode = EditDialogMode.CREATE activeModal.componentInstance.dialogMode = EditDialogMode.CREATE
@@ -215,7 +216,7 @@ export abstract class ManagementListComponent<T extends MatchingModel>
} }
openEditDialog(object: T) { openEditDialog(object: T) {
var activeModal = this.modalService.open(this.editDialogComponent, { const activeModal = this.modalService.open(this.editDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
activeModal.componentInstance.object = object activeModal.componentInstance.object = object
@@ -243,7 +244,7 @@ export abstract class ManagementListComponent<T extends MatchingModel>
} }
openDeleteDialog(object: T) { openDeleteDialog(object: T) {
var activeModal = this.modalService.open(ConfirmDialogComponent, { const activeModal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
activeModal.componentInstance.title = $localize`Confirm delete` activeModal.componentInstance.title = $localize`Confirm delete`
@@ -343,13 +344,9 @@ export abstract class ManagementListComponent<T extends MatchingModel>
this.clearSelection() this.clearSelection()
} }
selectPage(select: boolean) { selectPage() {
if (select) { this.selectedObjects = new Set(this.getSelectableIDs(this.data))
this.selectedObjects = new Set(this.getSelectableIDs(this.data)) this.togggleAll = this.areAllPageItemsSelected()
this.togggleAll = this.areAllPageItemsSelected()
} else {
this.clearSelection()
}
} }
selectAll() { selectAll() {

View File

@@ -138,12 +138,12 @@ describe('TagListComponent', () => {
} }
component.data = [parent as any] component.data = [parent as any]
component.selectPage(true) component.selectPage()
expect(component.selectedObjects.has(10)).toBe(true) expect(component.selectedObjects.has(10)).toBe(true)
expect(component.selectedObjects.has(11)).toBe(true) expect(component.selectedObjects.has(11)).toBe(true)
component.selectPage(false) component.clearSelection()
expect(component.selectedObjects.size).toBe(0) expect(component.selectedObjects.size).toBe(0)
}) })
}) })