[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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 2 deletions

View File

@ -77,6 +77,7 @@ when the process list is empty:
| rowClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when a row in the process list is clicked. |
| showRowContextMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/src/lib/datatable/components/data-cell.event.ts)`>` | Emitted before the context menu is displayed for a row. |
| success | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ProcessListModel`](../../../lib/process-services/src/lib/process-list/models/process-list.model.ts)`>` | Emitted when the list of process instances has been loaded successfully from the server. |
| rowsSelected | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ObjectDataRow[]`](../../../lib/core/src/lib/datatable/data/object-datarow.model.ts)`>` | Emmitted when rows are selected or unselected. |
## Details

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
*