mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3284] filterParam checking in onChanges (#3561)
* filterParam checking in onChanges * test improvement
This commit is contained in:
@@ -196,4 +196,25 @@ describe('ProcessFiltersComponent', () => {
|
|||||||
expect(filterList.getCurrentFilter()).toBe(filter);
|
expect(filterList.getCurrentFilter()).toBe(filter);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it ('should select current process filter', (done) => {
|
||||||
|
spyOn(processFilterService, 'getProcessFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
|
||||||
|
const appId = '1';
|
||||||
|
let change = new SimpleChange(null, appId, true);
|
||||||
|
filterList.ngOnChanges({ 'appId': change });
|
||||||
|
|
||||||
|
expect(filterList.currentFilter).toBeUndefined();
|
||||||
|
|
||||||
|
const selectedFilter = new FilterProcessRepresentationModel({
|
||||||
|
name: 'FakeMyTasks',
|
||||||
|
filter: { state: 'open', assignment: 'fake-assignee' }
|
||||||
|
});
|
||||||
|
|
||||||
|
filterList.success.subscribe(() => {
|
||||||
|
filterList.selectProcessFilter(selectedFilter);
|
||||||
|
expect(filterList.currentFilter.name).toEqual('FakeMyTasks');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
filterList.ngOnInit();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -78,15 +78,16 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
let appId = changes['appId'];
|
const appId = changes['appId'];
|
||||||
|
const appName = changes['appName'];
|
||||||
|
const filter = changes['filterParam'];
|
||||||
|
|
||||||
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
||||||
this.getFiltersByAppId(appId.currentValue);
|
this.getFiltersByAppId(appId.currentValue);
|
||||||
return;
|
} else if (appName && appName.currentValue) {
|
||||||
}
|
|
||||||
let appName = changes['appName'];
|
|
||||||
if (appName && appName.currentValue) {
|
|
||||||
this.getFiltersByAppName(appName.currentValue);
|
this.getFiltersByAppName(appName.currentValue);
|
||||||
return;
|
} else if (filter && filter.currentValue !== filter.previousValue) {
|
||||||
|
this.selectProcessFilter(filter.currentValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user