mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[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:
parent
cf9f4cc681
commit
8c01ccf931
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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: {
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user