[ADF-2505] ADF Processlist multi selection issues. (#3115)

* [ADF-2505] Added new input to check if first row has to be selected

* [ADF-2505] Reset selection when data changes

* [ADF-2505] Added documentation
This commit is contained in:
Deepak Paul
2018-03-23 13:46:06 +05:30
committed by Eugenio Romano
parent 845bdebfc9
commit 12f29d5524
4 changed files with 46 additions and 14 deletions

View File

@@ -19,6 +19,7 @@ import {
DataColumn,
DataRowEvent,
DataSorting,
DataTableComponent,
DataTableAdapter,
ObjectDataColumn,
ObjectDataRow,
@@ -41,7 +42,8 @@ import {
Input,
OnChanges,
Output,
SimpleChanges
SimpleChanges,
ViewChild
} from '@angular/core';
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
import { processPresetsDefaultModel } from '../models/process-preset.model';
@@ -59,6 +61,8 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
@ViewChild('dataTable') dataTable: DataTableComponent;
/** The id of the app. */
@Input()
appId: number;
@@ -108,6 +112,10 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
@Input()
selectionMode: string = 'single'; // none|single|multiple
/* Toggles default selection of the first row */
@Input()
selectFirstRow: boolean = true;
/** Emitted when a row in the process list is clicked. */
@Output()
rowClick: EventEmitter<string> = new EventEmitter<string>();
@@ -243,6 +251,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
*/
private renderInstances(instances: any[]) {
instances = this.optimizeNames(instances);
this.dataTable.resetSelection();
this.setDatatableSorting();
this.data.setRows(instances);
}
@@ -266,16 +275,18 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
* Select the first instance of a list if present
*/
selectFirst() {
if (!this.isListEmpty()) {
let row = this.data.getRows()[0];
row.isSelected = true;
this.data.selectedRow = row;
this.currentInstanceId = row.getValue('id');
} else {
if (this.data) {
this.data.selectedRow = null;
if (this.selectFirstRow) {
if (!this.isListEmpty()) {
let row = this.data.getRows()[0];
row.isSelected = true;
this.data.selectedRow = row;
this.currentInstanceId = row.getValue('id');
} else {
if (this.data) {
this.data.selectedRow = null;
}
this.currentInstanceId = null;
}
this.currentInstanceId = null;
}
}