[ACS-8745] handle row selection in process list (#10196)

* ACS-8745 handle row selection in process list

* ACS-8745 add type to event emitter

* ACS-8745 change type in docs

* ACS-8745 review remarks - duplicated methods, redundant property

* ACS-8745 review remarks - docs typo, unit tests
This commit is contained in:
Grzegorz Jaśkowski
2024-09-13 09:35:48 +02:00
committed by GitHub
parent cf9f4cc681
commit 8c01ccf931
4 changed files with 38 additions and 2 deletions

View File

@@ -13,7 +13,10 @@
[contextMenu]="showContextMenu"
(showRowContextMenu)="onShowRowContextMenu($event)"
(rowClick)="onRowClick($event)"
(row-keyup)="onRowKeyUp($any($event))">
(row-keyup)="onRowKeyUp($any($event))"
(row-select)="onRowCheckboxToggle($any($event))"
(row-unselect)="onRowCheckboxToggle($any($event))"
>
<adf-loading-content-template>
<ng-template>
<mat-progress-spinner

View File

@@ -271,6 +271,29 @@ describe('ProcessInstanceListComponent', () => {
expect(triggered).toBeFalsy();
});
it('should emit rowsSelected event when a row is selected', (done) => {
const row = new ObjectDataRow({ obj: fakeProcessInstance.data[0] });
const customEvent = new CustomEvent('row-select', { detail: { selection: [row] } });
component.rowsSelected.subscribe((selection) => {
expect(selection).toEqual([row]);
done();
});
component.onRowCheckboxToggle(customEvent);
});
it('should emit rowsSelected event when a row is unselected', (done) => {
const customEvent = new CustomEvent('row-unselect', { detail: { selection: [] } });
component.rowsSelected.subscribe((selection) => {
expect(selection).toEqual([]);
done();
});
component.onRowCheckboxToggle(customEvent);
});
it('should show custom resolved value in the column', async () => {
appConfig.config['adf-process-list'] = {
presets: {

View File

@@ -32,7 +32,8 @@ import {
EmptyContentComponent,
DataTableComponent,
LoadingContentTemplateDirective,
NoContentTemplateDirective
NoContentTemplateDirective,
ObjectDataRow
} from '@alfresco/adf-core';
import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { ProcessService } from '../../services/process.service';
@@ -181,6 +182,10 @@ export class ProcessInstanceListComponent extends DataTableSchema implements OnC
@Output()
error = new EventEmitter<any>();
/** Emitted when rows are selected/unselected */
@Output()
rowsSelected = new EventEmitter<ObjectDataRow[]>();
requestNode: ProcessInstanceQueryRepresentation;
currentInstanceId: string;
isLoading: boolean = true;
@@ -275,6 +280,10 @@ export class ProcessInstanceListComponent extends DataTableSchema implements OnC
this.rowClick.emit(this.currentInstanceId);
}
onRowCheckboxToggle(event: CustomEvent) {
this.rowsSelected.emit([...event.detail.selection]);
}
/**
* Emit the event rowClick passing the current task id when pressed the Enter key on the selected row
*