mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -214,7 +214,7 @@ describe('TaskAttachmentList', () => {
|
|||||||
}));
|
}));
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'taskId': change });
|
component.ngOnChanges({ 'taskId': change });
|
||||||
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.nativeElement.querySelector('div[adf-empty-list-header]').innerText.trim()).toEqual('ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER');
|
expect(fixture.nativeElement.querySelector('div[adf-empty-list-header]').innerText.trim()).toEqual('ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER');
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<adf-datatable #dataTable
|
<adf-datatable #dataTable
|
||||||
[data]="data"
|
[data]="data"
|
||||||
[sorting]="dataSort"
|
[sorting]="sorting"
|
||||||
[loading]="isLoading"
|
[loading]="isLoading"
|
||||||
[selectionMode]="selectionMode"
|
[selectionMode]="selectionMode"
|
||||||
[multiselect]="multiselect"
|
[multiselect]="multiselect"
|
||||||
|
@@ -253,12 +253,6 @@ describe('ProcessInstanceListComponent', () => {
|
|||||||
expect(component.getCurrentId()).toBeNull();
|
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 true for the selected process', () => {
|
it('should return selected true for the selected process', () => {
|
||||||
component.data = new ObjectDataTableAdapter(
|
component.data = new ObjectDataTableAdapter(
|
||||||
[
|
[
|
||||||
|
@@ -174,10 +174,18 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.isPropertyChanged(changes)) {
|
if (this.isPropertyChanged(changes)) {
|
||||||
|
if (this.isSortChanged(changes)) {
|
||||||
|
this.sorting = this.sort ? this.sort.split('-') : this.sorting;
|
||||||
|
}
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isSortChanged(changes: SimpleChanges): boolean {
|
||||||
|
const actualSort = changes['sort'];
|
||||||
|
return actualSort && actualSort.currentValue && actualSort.currentValue !== actualSort.previousValue;
|
||||||
|
}
|
||||||
|
|
||||||
private isPropertyChanged(changes: SimpleChanges): boolean {
|
private isPropertyChanged(changes: SimpleChanges): boolean {
|
||||||
let changed: boolean = false;
|
let changed: boolean = false;
|
||||||
|
|
||||||
@@ -293,14 +301,6 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sort the process based on current value of 'sort' property
|
|
||||||
* Return the sorting order
|
|
||||||
*/
|
|
||||||
get dataSort(): any[] {
|
|
||||||
return this.sort ? this.sort.split('-') : this.sorting;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current id
|
* Return the current id
|
||||||
*/
|
*/
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
[data]="data"
|
[data]="data"
|
||||||
[rows]="rows"
|
[rows]="rows"
|
||||||
[columns]="columns"
|
[columns]="columns"
|
||||||
[sorting]="dataSort"
|
[sorting]="sorting"
|
||||||
[loading]="isLoading"
|
[loading]="isLoading"
|
||||||
[selectFirstRow]="selectFirstRow"
|
[selectFirstRow]="selectFirstRow"
|
||||||
[multiselect]="multiselect"
|
[multiselect]="multiselect"
|
||||||
|
@@ -230,12 +230,6 @@ describe('TaskListComponent', () => {
|
|||||||
expect(component.getCurrentId()).toBeNull();
|
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', () => {
|
it('should return selected id for the selected task', () => {
|
||||||
component.rows = [
|
component.rows = [
|
||||||
{ id: '999', name: 'Fake-name' },
|
{ id: '999', name: 'Fake-name' },
|
||||||
|
@@ -183,10 +183,18 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
|||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.isPropertyChanged(changes)) {
|
if (this.isPropertyChanged(changes)) {
|
||||||
|
if (this.isSortChanged(changes)) {
|
||||||
|
this.sorting = this.sort ? this.sort.split('-') : this.sorting;
|
||||||
|
}
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isSortChanged(changes: SimpleChanges): boolean {
|
||||||
|
const actualSort = changes['sort'];
|
||||||
|
return actualSort && actualSort.currentValue && actualSort.currentValue !== actualSort.previousValue;
|
||||||
|
}
|
||||||
|
|
||||||
private isPropertyChanged(changes: SimpleChanges): boolean {
|
private isPropertyChanged(changes: SimpleChanges): boolean {
|
||||||
let changed: boolean = true;
|
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
|
* Return the current id
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user