[ADF-3039] Task List - Enanchement (#3404)

* * Created DataColumnSchemaAssembler component to get column schema from html and app.config.json
* Removed column related  method  from tasklist.

* * Removed data property from the tasklist component
* Using rows input property instead of data input property of the datatable

* *  Renamed  DataColumnSchemaAssembler to DataTableSchema
* Refactored DataTableSchema component

* * Changed schem property into an  input schemaColumns property  in dataTable component

* * Added selectFirstRow input property to select a first row of datatable
* Removed unnecessary method from tasklist component

* * Added test case for the recent changes
* Added mock object for the tasklist spec

* * Added testcases for recent changes in the datatable component

* * Updated datatable and tasklist document for the recent changes

* * Refactored process-service and task list component
* Updated datatable document.

* [ADF-3039] Task List - Enanchement
* Changed schemaColumn name to columns
* Updated datatable documentation.
*  data input Annotated  with @deprecated in the tasklist component

* * Added an sorting input to the datatable.
* Updated datatable and tasklist documentation
* Added method to get current sorting order.

* * After rebasing

* * Revert  sorting changes

* * After rebase

* * fixed conflicts

* * Fixed failing testcase after rebased.
This commit is contained in:
siva kumar
2018-06-01 14:09:09 +05:30
committed by Maurizio Vitale
parent 2f12f518ef
commit d4f57b8786
12 changed files with 546 additions and 420 deletions

View File

@@ -71,6 +71,14 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
@Input()
sorting: any[] = [];
/** The columns that the datatable will show. */
@Input()
columns: any[] = [];
/* Toggles default selection of the first row */
@Input()
selectFirstRow: boolean = true;
/** Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode,
* you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows.
*/
@@ -158,8 +166,6 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
private clickObserver: Observer<DataRowEvent>;
private click$: Observable<DataRowEvent>;
private schema: DataColumn[] = [];
private differ: any;
private rowMenuCache: object = {};
@@ -293,7 +299,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
}
private initTable() {
this.data = new ObjectDataTableAdapter(this.rows, this.schema);
this.data = new ObjectDataTableAdapter(this.rows, this.columns);
this.setupData(this.data);
this.rowMenuCache = {};
}
@@ -323,16 +329,32 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
this.resetSelection();
}
this.data.setRows(this.convertToRowsData(rows));
this.selectFirst();
}
}
private selectFirst() {
if (this.selectFirstRow) {
if (this.data && this.data.getRows().length > 0) {
let row = this.data.getRows()[0];
row.isSelected = true;
this.data.selectedRow = row;
}
}
}
private setTableSchema() {
if (this.columnList && this.columnList.columns) {
this.schema = this.columnList.columns.map(c => <DataColumn> c);
let schema = [];
if (!this.columns || this.columns.length === 0) {
schema = this.getSchemaFromHtml();
} else {
schema = this.columns.concat(this.getSchemaFromHtml());
}
if (this.data && this.schema && this.schema.length > 0) {
this.data.setColumns(this.schema);
this.columns = schema;
if (this.data && this.columns && this.columns.length > 0) {
this.data.setColumns(this.columns);
}
}
@@ -342,6 +364,14 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
}
}
public getSchemaFromHtml(): any {
let schema = [];
if (this.columnList && this.columnList.columns && this.columnList.columns.length > 0) {
schema = this.columnList.columns.map(c => <DataColumn> c);
}
return schema;
}
onRowClick(row: DataRow, e: MouseEvent) {
if (e) {
e.preventDefault();