[ADF-3120] fixed sorting for tasklist and process list (#3435)

* [ADF-3120] fixed sorting for tasklist and process list

* [ADF-3120] removed commented code

* [ADF-3120] fixing another randomly failing test
This commit is contained in:
Vito
2018-06-07 14:25:57 +01:00
committed by Eugenio Romano
parent 581867ad66
commit e988691d0a
7 changed files with 19 additions and 31 deletions

View File

@@ -4,7 +4,7 @@
[data]="data"
[rows]="rows"
[columns]="columns"
[sorting]="dataSort"
[sorting]="sorting"
[loading]="isLoading"
[selectFirstRow]="selectFirstRow"
[multiselect]="multiselect"

View File

@@ -230,12 +230,6 @@ describe('TaskListComponent', () => {
expect(component.getCurrentId()).toBeNull();
});
it('should return the sorting order if sort is defined', () => {
component.sort = 'fakeKey-fakeOrder';
fixture.detectChanges();
expect(component.dataSort).toEqual(['fakeKey', 'fakeOrder']);
});
it('should return selected id for the selected task', () => {
component.rows = [
{ id: '999', name: 'Fake-name' },

View File

@@ -183,10 +183,18 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
ngOnChanges(changes: SimpleChanges) {
if (this.isPropertyChanged(changes)) {
if (this.isSortChanged(changes)) {
this.sorting = this.sort ? this.sort.split('-') : this.sorting;
}
this.reload();
}
}
private isSortChanged(changes: SimpleChanges): boolean {
const actualSort = changes['sort'];
return actualSort && actualSort.currentValue && actualSort.currentValue !== actualSort.previousValue;
}
private isPropertyChanged(changes: SimpleChanges): boolean {
let changed: boolean = true;
@@ -262,14 +270,6 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
}
}
/**
* Return the sorting order
* Sort the tasks based on current value of 'sort' property
*/
get dataSort(): any[] {
return this.sort ? this.sort.split('-') : this.sorting;
}
/**
* Return the current id
*/