From 0fa87bb17d6a0c3b6781f860b3f502397a741ecc Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 13 Jan 2017 12:45:37 +0000 Subject: [PATCH] selected row highlight (#1448) * showing selected row Support for showing selected row for the components: - DataTable - DocumentList - Activiti TaskList - Activiti ProcessList fixes #170 * unit test fixes --- .../activiti-processlist.component.ts | 7 ++++++- .../components/activiti-tasklist.component.ts | 18 +++++++++--------- .../datatable/datatable.component.css | 5 +++++ .../datatable/datatable.component.html | 3 ++- .../datatable/datatable.component.ts | 15 +++++++++++---- .../src/data/datatable-adapter.ts | 1 + .../src/data/object-datatable-adapter.ts | 2 ++ .../src/data/share-datatable-adapter.ts | 1 + 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts index 764662dd08..2c7db1ee28 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts @@ -191,8 +191,13 @@ export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges { */ selectFirst() { if (!this.isListEmpty()) { - this.currentInstanceId = this.data.getRows()[0].getValue('id'); + let row = this.data.getRows()[0]; + this.data.selectedRow = row; + this.currentInstanceId = row.getValue('id'); } else { + if (this.data) { + this.data.selectedRow = null; + } this.currentInstanceId = null; } } diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts index db9ae4d8c0..be457cac5d 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts @@ -189,20 +189,20 @@ export class ActivitiTaskList implements OnInit, OnChanges { */ selectTask(taskIdToSelect: string) { if (!this.isListEmpty()) { - let dataRow = this.data.getRows().find(row => row.getValue('id') === taskIdToSelect); - this.currentInstanceId = dataRow ? dataRow.getValue('id') : this.selectFirst(); + let rows = this.data.getRows(); + if (rows.length > 0) { + let dataRow = rows.find(row => row.getValue('id') === taskIdToSelect) || rows[0]; + this.data.selectedRow = dataRow; + this.currentInstanceId = dataRow.getValue('id'); + } } else { + if (this.data) { + this.data.selectedRow = null; + } this.currentInstanceId = null; } } - /** - * Select the first instance of a list if present - */ - selectFirst() { - return this.data.getRows()[0].getValue('id'); - } - /** * Return the current id * @returns {string} diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.css b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.css index edc97ce169..d258331abc 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.css +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.css @@ -114,3 +114,8 @@ border-collapse: unset; border-spacing: 0; } + + +.alfresco-datatable__row--selected { + color: rgb(68,138,255); +} diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html index b7f9035c1d..11be56699a 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html @@ -31,7 +31,8 @@ - +