Select the currentTask (#2598)

This commit is contained in:
Maurizio Vitale 2017-11-02 15:30:23 +00:00 committed by Eugenio Romano
parent 3478b06716
commit 5ca66bb75f
2 changed files with 21 additions and 0 deletions

View File

@ -278,6 +278,26 @@ describe('TaskListComponent', () => {
expect(component.getCurrentId()).toBeNull();
});
it('should return selected true for the selected task', () => {
component.data = new ObjectDataTableAdapter(
[
{id: '999', name: 'Fake-name'},
{id: '888', name: 'Fake-name-888'}
],
[
{type: 'text', key: 'id', title: 'Id'},
{type: 'text', key: 'name', title: 'Name'}
]
);
component.selectTask('888');
const dataRow = component.data.getRows();
expect(dataRow).toBeDefined();
expect(dataRow[0].getValue('id')).toEqual('999');
expect(dataRow[0].isSelected).toEqual(false);
expect(dataRow[1].getValue('id')).toEqual('888');
expect(dataRow[1].isSelected).toEqual(true);
});
it('should throw an exception when the response is wrong', (done) => {
let state = new SimpleChange(null, 'open', true);
let assignment = new SimpleChange(null, 'fake-assignee', true);

View File

@ -234,6 +234,7 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit {
if (rows.length > 0) {
let dataRow = rows.find(row => row.getValue('id') === taskIdToSelect) || rows[0];
this.data.selectedRow = dataRow;
dataRow.isSelected = true;
this.currentInstanceId = dataRow.getValue('id');
}
} else {