mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA_3292] - Add queued task as part of default task filter (#5747)
* [ACA_3292] - Add queued task as default task filter * don't emit event if the filter is undefined * fix unit test Co-authored-by: Silviu Popa <p3701014@L3700101120.ness.com>
This commit is contained in:
@@ -98,6 +98,7 @@
|
|||||||
},
|
},
|
||||||
"ADF_CLOUD_TASK_FILTERS": {
|
"ADF_CLOUD_TASK_FILTERS": {
|
||||||
"MY_TASKS": "My Tasks",
|
"MY_TASKS": "My Tasks",
|
||||||
|
"QUEUED_TASKS": "Queued Tasks",
|
||||||
"COMPLETED_TASKS": "Completed Tasks"
|
"COMPLETED_TASKS": "Completed Tasks"
|
||||||
},
|
},
|
||||||
"ADF_CLOUD_PROCESS_FILTERS": {
|
"ADF_CLOUD_PROCESS_FILTERS": {
|
||||||
|
@@ -272,6 +272,20 @@ describe('TaskFiltersCloudComponent', () => {
|
|||||||
expect(component.selectFilterAndEmit).toHaveBeenCalledWith(fakeGlobalFilter[1]);
|
expect(component.selectFilterAndEmit).toHaveBeenCalledWith(fakeGlobalFilter[1]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should reset the filter when the param is undefined', async(() => {
|
||||||
|
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||||
|
spyOn(component, 'selectFilterAndEmit');
|
||||||
|
component.currentFilter = null;
|
||||||
|
|
||||||
|
const filterName = undefined;
|
||||||
|
const change = new SimpleChange(null, filterName, false);
|
||||||
|
component.ngOnChanges({ 'filterParam': change });
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(component.selectFilterAndEmit).toHaveBeenCalledWith(undefined);
|
||||||
|
expect(component.currentFilter).toEqual(undefined);
|
||||||
|
}));
|
||||||
|
|
||||||
it('should reload filters by appName on binding changes', () => {
|
it('should reload filters by appName on binding changes', () => {
|
||||||
spyOn(component, 'getFilters').and.stub();
|
spyOn(component, 'getFilters').and.stub();
|
||||||
const appName = 'my-app-1';
|
const appName = 'my-app-1';
|
||||||
|
@@ -117,8 +117,12 @@ export class TaskFiltersCloudComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public selectFilterAndEmit(newParamFilter: FilterParamsModel) {
|
public selectFilterAndEmit(newParamFilter: FilterParamsModel) {
|
||||||
this.selectFilter(newParamFilter);
|
if (newParamFilter) {
|
||||||
this.filterClick.emit(this.currentFilter);
|
this.selectFilter(newParamFilter);
|
||||||
|
this.filterClick.emit(this.currentFilter);
|
||||||
|
} else {
|
||||||
|
this.currentFilter = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -250,7 +250,7 @@ describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService',
|
|||||||
it('should create default task filters if there are no task filter preferences', (done) => {
|
it('should create default task filters if there are no task filter preferences', (done) => {
|
||||||
const appName = 'fakeAppName';
|
const appName = 'fakeAppName';
|
||||||
service.getTaskListFilters(appName).subscribe((res) => {
|
service.getTaskListFilters(appName).subscribe((res) => {
|
||||||
expect(res.length).toEqual(2);
|
expect(res.length).toEqual(3);
|
||||||
|
|
||||||
expect(res[0].name).toEqual('ADF_CLOUD_TASK_FILTERS.MY_TASKS');
|
expect(res[0].name).toEqual('ADF_CLOUD_TASK_FILTERS.MY_TASKS');
|
||||||
expect(res[0].key).toEqual('my-tasks');
|
expect(res[0].key).toEqual('my-tasks');
|
||||||
@@ -259,17 +259,24 @@ describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService',
|
|||||||
expect(res[0].status).toEqual('ASSIGNED');
|
expect(res[0].status).toEqual('ASSIGNED');
|
||||||
expect(res[0].assignee).toEqual(identityUserMock.username);
|
expect(res[0].assignee).toEqual(identityUserMock.username);
|
||||||
|
|
||||||
expect(res[1].name).toEqual('ADF_CLOUD_TASK_FILTERS.COMPLETED_TASKS');
|
expect(res[1].name).toEqual('ADF_CLOUD_TASK_FILTERS.QUEUED_TASKS');
|
||||||
expect(res[1].key).toEqual('completed-tasks');
|
expect(res[1].key).toEqual('queued-tasks');
|
||||||
expect(res[1].appName).toEqual(appName);
|
expect(res[1].appName).toEqual(appName);
|
||||||
expect(res[1].icon).toEqual('done');
|
expect(res[1].icon).toEqual('queue');
|
||||||
expect(res[1].status).toEqual('COMPLETED');
|
expect(res[1].status).toEqual('CREATED');
|
||||||
|
|
||||||
|
expect(res[2].name).toEqual('ADF_CLOUD_TASK_FILTERS.COMPLETED_TASKS');
|
||||||
|
expect(res[2].key).toEqual('completed-tasks');
|
||||||
|
expect(res[2].appName).toEqual(appName);
|
||||||
|
expect(res[2].icon).toEqual('done');
|
||||||
|
expect(res[2].status).toEqual('COMPLETED');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
expect(getPreferencesSpy).toHaveBeenCalled();
|
expect(getPreferencesSpy).toHaveBeenCalled();
|
||||||
|
|
||||||
const localData = JSON.parse(localStorage.getItem(`task-filters-${appName}-${identityUserMock.username}`));
|
const localData = JSON.parse(localStorage.getItem(`task-filters-${appName}-${identityUserMock.username}`));
|
||||||
expect(localData.length).toEqual(2);
|
expect(localData.length).toEqual(3);
|
||||||
|
|
||||||
expect(localData[0].name).toEqual('ADF_CLOUD_TASK_FILTERS.MY_TASKS');
|
expect(localData[0].name).toEqual('ADF_CLOUD_TASK_FILTERS.MY_TASKS');
|
||||||
expect(localData[0].key).toEqual('my-tasks');
|
expect(localData[0].key).toEqual('my-tasks');
|
||||||
@@ -278,10 +285,16 @@ describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService',
|
|||||||
expect(localData[0].status).toEqual('ASSIGNED');
|
expect(localData[0].status).toEqual('ASSIGNED');
|
||||||
expect(localData[0].assignee).toEqual(identityUserMock.username);
|
expect(localData[0].assignee).toEqual(identityUserMock.username);
|
||||||
|
|
||||||
expect(localData[1].name).toEqual('ADF_CLOUD_TASK_FILTERS.COMPLETED_TASKS');
|
expect(localData[1].name).toEqual('ADF_CLOUD_TASK_FILTERS.QUEUED_TASKS');
|
||||||
expect(localData[1].key).toEqual('completed-tasks');
|
expect(localData[1].key).toEqual('queued-tasks');
|
||||||
expect(localData[1].appName).toEqual(appName);
|
expect(localData[1].appName).toEqual(appName);
|
||||||
expect(localData[1].icon).toEqual('done');
|
expect(localData[1].icon).toEqual('queue');
|
||||||
expect(localData[1].status).toEqual('COMPLETED');
|
expect(localData[1].status).toEqual('CREATED');
|
||||||
|
|
||||||
|
expect(localData[2].name).toEqual('ADF_CLOUD_TASK_FILTERS.COMPLETED_TASKS');
|
||||||
|
expect(localData[2].key).toEqual('completed-tasks');
|
||||||
|
expect(localData[2].appName).toEqual(appName);
|
||||||
|
expect(localData[2].icon).toEqual('done');
|
||||||
|
expect(localData[2].status).toEqual('COMPLETED');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -276,6 +276,16 @@ export class TaskFilterCloudService {
|
|||||||
sort: 'createdDate',
|
sort: 'createdDate',
|
||||||
order: 'DESC'
|
order: 'DESC'
|
||||||
}),
|
}),
|
||||||
|
new TaskFilterCloudModel({
|
||||||
|
name: 'ADF_CLOUD_TASK_FILTERS.QUEUED_TASKS',
|
||||||
|
key: 'queued-tasks',
|
||||||
|
icon: 'queue',
|
||||||
|
appName: appName,
|
||||||
|
status: 'CREATED',
|
||||||
|
assignee: '',
|
||||||
|
sort: 'createdDate',
|
||||||
|
order: 'DESC'
|
||||||
|
}),
|
||||||
new TaskFilterCloudModel({
|
new TaskFilterCloudModel({
|
||||||
name: 'ADF_CLOUD_TASK_FILTERS.COMPLETED_TASKS',
|
name: 'ADF_CLOUD_TASK_FILTERS.COMPLETED_TASKS',
|
||||||
key: 'completed-tasks',
|
key: 'completed-tasks',
|
||||||
|
Reference in New Issue
Block a user