Skip to content

Commit

Permalink
[ACS-8745] handle row selection in process list (#10196)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
g-jaskowski authored Sep 13, 2024
1 parent cf9f4cc commit 8c01ccf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/process-services/components/process-list.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 8c01ccf

Please sign in to comment.