diff --git a/demo-shell/src/app/components/cloud/cloud-filters-demo.component.ts b/demo-shell/src/app/components/cloud/cloud-filters-demo.component.ts index 2a193bfdbe..8a34e75151 100644 --- a/demo-shell/src/app/components/cloud/cloud-filters-demo.component.ts +++ b/demo-shell/src/app/components/cloud/cloud-filters-demo.component.ts @@ -63,15 +63,11 @@ export class CloudFiltersDemoComponent implements OnInit { } onTaskFilterSelected(filter) { - this.cloudLayoutService.setCurrentTaskFilterParam({id: filter && filter.id ? filter.id : ''}); - const currentFilter = Object.assign({}, filter); - this.router.navigate([`/cloud/${this.appName}/tasks/`], { queryParams: currentFilter }); + this.router.navigate([`/cloud/${this.appName}/tasks/`], { queryParams: filter }); } onProcessFilterSelected(filter) { - this.cloudLayoutService.setCurrentProcessFilterParam({id: filter && filter.id ? filter.id : ''}); - const currentFilter = Object.assign({}, filter); - this.router.navigate([`/cloud/${this.appName}/processes/`], { queryParams: currentFilter }); + this.router.navigate([`/cloud/${this.appName}/processes/`], { queryParams: filter }); } onTaskFilterOpen(): boolean { diff --git a/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts b/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts index 87f77c13bc..6c86edbe66 100644 --- a/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts +++ b/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts @@ -37,6 +37,7 @@ import { Pagination } from '@alfresco/js-api'; export class ProcessesCloudDemoComponent implements OnInit, OnDestroy { public static ACTION_SAVE_AS = 'saveAs'; + public static ACTION_DELETE = 'delete'; static PROCESS_FILTER_PROPERTY_KEYS = 'adf-edit-process-filter'; @ViewChild('processCloud') @@ -140,7 +141,12 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy { } onProcessFilterAction(filterAction: any) { - this.cloudLayoutService.setCurrentProcessFilterParam({ id: filterAction.filter.id }); + if (filterAction.actionType === ProcessesCloudDemoComponent.ACTION_DELETE) { + this.cloudLayoutService.setCurrentProcessFilterParam({ index: 0 }); + } else { + this.cloudLayoutService.setCurrentProcessFilterParam({ id: filterAction.filter.id }); + } + if (filterAction.actionType === ProcessesCloudDemoComponent.ACTION_SAVE_AS) { this.router.navigate([`/cloud/${this.appName}/processes/`], { queryParams: filterAction.filter }); } diff --git a/demo-shell/src/app/components/cloud/tasks-cloud-demo.component.ts b/demo-shell/src/app/components/cloud/tasks-cloud-demo.component.ts index c264bae8c8..57817e4373 100644 --- a/demo-shell/src/app/components/cloud/tasks-cloud-demo.component.ts +++ b/demo-shell/src/app/components/cloud/tasks-cloud-demo.component.ts @@ -30,6 +30,7 @@ import { takeUntil } from 'rxjs/operators'; export class TasksCloudDemoComponent implements OnInit, OnDestroy { public static ACTION_SAVE_AS = 'saveAs'; + public static ACTION_DELETE = 'delete'; static TASK_FILTER_PROPERTY_KEYS = 'adf-edit-task-filter'; @ViewChild('taskCloud') @@ -133,7 +134,13 @@ export class TasksCloudDemoComponent implements OnInit, OnDestroy { } onTaskFilterAction(filterAction: any) { - this.cloudLayoutService.setCurrentTaskFilterParam({ id: filterAction.filter.id }); + + if (filterAction.actionType === TasksCloudDemoComponent.ACTION_DELETE) { + this.cloudLayoutService.setCurrentTaskFilterParam({ index: 0 }); + } else { + this.cloudLayoutService.setCurrentTaskFilterParam({ id: filterAction.filter.id }); + } + if (filterAction.actionType === TasksCloudDemoComponent.ACTION_SAVE_AS) { this.router.navigate([`/cloud/${this.appName}/tasks/`], { queryParams: filterAction.filter }); } diff --git a/docs/process-services-cloud/components/process-filters-cloud.component.md b/docs/process-services-cloud/components/process-filters-cloud.component.md index 4c32e6e13b..8f79d4c6c6 100644 --- a/docs/process-services-cloud/components/process-filters-cloud.component.md +++ b/docs/process-services-cloud/components/process-filters-cloud.component.md @@ -25,7 +25,7 @@ Lists all available process filters and allows to select a filter. | Name | Type | Default value | Description | | ---- | ---- | ------------- | ----------- | | appName | `string` | "" | (required) The application name | -| filterParam | [`FilterParamsModel`](../../../lib/process-services/src/lib/task-list/models/filter.model.ts) | | (optional) The filter to be selected by default | +| filterParam | [`FilterParamsModel`](../../../lib/process-services/src/lib/task-list/models/filter.model.ts) | | (optional) The filter to be selected by default. If there is no match no filter is selected by default. | | showIcons | `boolean` | false | (optional) Toggles showing an icon by the side of each filter | ### Events diff --git a/docs/process-services-cloud/components/task-filters-cloud.component.md b/docs/process-services-cloud/components/task-filters-cloud.component.md index 99bcefb9a4..5460b7fbd3 100644 --- a/docs/process-services-cloud/components/task-filters-cloud.component.md +++ b/docs/process-services-cloud/components/task-filters-cloud.component.md @@ -22,7 +22,7 @@ Shows all available filters. | Name | Type | Default value | Description | | ---- | ---- | ------------- | ----------- | | appName | `string` | "" | Display filters available to the current user for the application with the specified name. | -| filterParam | [`FilterParamsModel`](../../../lib/process-services/src/lib/task-list/models/filter.model.ts) | | Parameters to use for the task filter cloud. If there is no match then the default filter (the first one in the list) is selected. | +| filterParam | [`FilterParamsModel`](../../../lib/process-services/src/lib/task-list/models/filter.model.ts) | | Parameters to use for the task filter cloud. If there is no match no filter is selected by default. | | showIcons | `boolean` | false | Toggles display of the filter's icons. | ### Events diff --git a/docs/process-services/components/process-filters.component.md b/docs/process-services/components/process-filters.component.md index 47f740d932..5ccb2aaa13 100644 --- a/docs/process-services/components/process-filters.component.md +++ b/docs/process-services/components/process-filters.component.md @@ -36,7 +36,7 @@ Collection of criteria used to filter process instances, which may be customized | ---- | ---- | ------------- | ----------- | | appId | `number` | | Display filters available to the current user for the application with the specified ID. | | appName | `string` | | Display filters available to the current user for the application with the specified name. | -| filterParam | [`FilterProcessRepresentationModel`](../../../lib/process-services/src/lib/process-list/models/filter-process.model.ts) | | The parameters to filter the task filter. If there is no match then the default one (ie, the first filter in the list) is selected. | +| filterParam | [`FilterProcessRepresentationModel`](../../../lib/process-services/src/lib/process-list/models/filter-process.model.ts) | | The parameters to filter the task filter. If there is no match no filter is selected by default. | | showIcon | `boolean` | true | Toggle to show or hide the filter's icon. | ### Events diff --git a/docs/process-services/components/task-filters.component.md b/docs/process-services/components/task-filters.component.md index cbd04e7998..ad5cabed20 100644 --- a/docs/process-services/components/task-filters.component.md +++ b/docs/process-services/components/task-filters.component.md @@ -23,7 +23,7 @@ Shows all available filters. | ---- | ---- | ------------- | ----------- | | appId | `number` | | Display filters available to the current user for the application with the specified ID. | | appName | `string` | | Display filters available to the current user for the application with the specified name. | -| filterParam | [`FilterParamsModel`](../../../lib/process-services/src/lib/task-list/models/filter.model.ts) | | Parameters to use for the task filter. If there is no match then the default filter (the first one the list) is selected. | +| filterParam | [`FilterParamsModel`](../../../lib/process-services/src/lib/task-list/models/filter.model.ts) | | Parameters to use for the task filter. If there is no match no filter is selected by default. | | showIcon | `boolean` | | Toggles display of the filter's icon. | ### Events diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts index 0cf57fbcfa..49f6064fd4 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts @@ -223,26 +223,6 @@ describe('ProcessFiltersCloudComponent', () => { component.ngOnChanges({ 'appName': change }); }); - it('should select the default filter if filter input does not exist', (done) => { - spyOn(processFilterService, 'getProcessFilters').and.returnValue(fakeGlobalFilterObservable); - - component.filterParam = new FilterParamsModel({ name: 'UnexistableFilter' }); - - const appName = 'my-app-1'; - const change = new SimpleChange(null, appName, true); - - fixture.detectChanges(); - - component.filterClick.subscribe((res) => { - expect(res).toBeDefined(); - expect(component.currentFilter).toBeDefined(); - expect(component.currentFilter.name).toEqual('FakeAllProcesses'); - done(); - }); - - component.ngOnChanges({ 'appName': change }); - }); - it('should select the filter based on the input by index param', (done) => { spyOn(processFilterService, 'getProcessFilters').and.returnValue(fakeGlobalFilterObservable); diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts index ab4f3d9f4d..3bb5580716 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts @@ -78,7 +78,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro if (appName && appName.currentValue) { this.getFilters(appName.currentValue); } else if (filter && filter.currentValue !== filter.previousValue) { - this.selectFilter(filter.currentValue); + this.selectFilterAndEmit(filter.currentValue); } } @@ -113,9 +113,6 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro paramFilter.index === index; }); } - if (!this.currentFilter) { - this.selectDefaultProcessFilter(); - } } /** diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts index 2c035ebebe..e045940df3 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts @@ -67,21 +67,6 @@ describe('TaskFiltersCloudComponent', () => { taskFilterService = TestBed.get(TaskFilterCloudService); }); - it('should the first element active', async(() => { - spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); - const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({'appName': change}); - fixture.detectChanges(); - component.showIcons = true; - - fixture.whenStable().then(() => { - fixture.detectChanges(); - const activeElement = fixture.debugElement.nativeElement.querySelector('.adf-active span'); - expect(activeElement).toBeDefined(); - expect(activeElement.innerText).toEqual(fakeGlobalFilter[0].name); - }); - })); - it('should attach specific icon for each filter if hasIcon is true', async(() => { spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); const change = new SimpleChange(undefined, 'my-app-1', true); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts index 16cf441648..d0a17b324b 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.ts @@ -76,7 +76,7 @@ export class TaskFiltersCloudComponent implements OnInit, OnChanges, OnDestroy { if (appName && appName.currentValue !== appName.previousValue) { this.getFilters(appName.currentValue); } else if (filter && filter.currentValue !== filter.previousValue) { - this.selectFilter(filter.currentValue); + this.selectFilterAndEmit(filter.currentValue); } } @@ -114,9 +114,6 @@ export class TaskFiltersCloudComponent implements OnInit, OnChanges, OnDestroy { (paramFilter.name.toLocaleLowerCase() === this.translationService.instant(filter.name).toLocaleLowerCase()) )); } - if (!this.currentFilter) { - this.selectDefaultTaskFilter(); - } } public selectFilterAndEmit(newParamFilter: FilterParamsModel) { diff --git a/lib/process-services/src/lib/process-list/components/process-filters.component.spec.ts b/lib/process-services/src/lib/process-list/components/process-filters.component.spec.ts index e06676509a..a9aaafd799 100644 --- a/lib/process-services/src/lib/process-list/components/process-filters.component.spec.ts +++ b/lib/process-services/src/lib/process-list/components/process-filters.component.spec.ts @@ -119,6 +119,7 @@ describe('ProcessFiltersComponent', () => { it('should emit an event when a filter is selected', (done) => { spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise)); + filterList.filterParam = new FilterProcessRepresentationModel({ id: 10 }); const appId = '1'; const change = new SimpleChange(null, appId, true); filterList.ngOnChanges({ 'appId': change }); @@ -278,26 +279,6 @@ describe('ProcessFiltersComponent', () => { }); }); - it('should select first filter if filterParam is empty', (done) => { - spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise)); - - filterList.filterParam = new FilterProcessRepresentationModel({}); - - const appId = 1; - const change = new SimpleChange(null, appId, true); - - filterList.ngOnChanges({ 'appId': change }); - - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(filterList.filters).toBeDefined(); - expect(filterList.filters.length).toEqual(3); - expect(filterList.currentFilter).toBeDefined(); - expect(filterList.currentFilter.name).toEqual('FakeInvolvedTasks'); - done(); - }); - }); - it('should attach specific icon for each filter if hasIcon is true', (done) => { spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise)); filterList.showIcon = true; diff --git a/lib/process-services/src/lib/process-list/components/process-filters.component.ts b/lib/process-services/src/lib/process-list/components/process-filters.component.ts index b2976a4aed..2d134635d8 100644 --- a/lib/process-services/src/lib/process-list/components/process-filters.component.ts +++ b/lib/process-services/src/lib/process-list/components/process-filters.component.ts @@ -164,9 +164,6 @@ export class ProcessFiltersComponent implements OnInit, OnChanges { } }); } - if (this.isCurrentFilterEmpty()) { - this.selectDefaultTaskFilter(); - } } /** @@ -208,10 +205,6 @@ export class ProcessFiltersComponent implements OnInit, OnChanges { this.currentFilter = undefined; } - private isCurrentFilterEmpty(): boolean { - return this.currentFilter === undefined || null; - } - /** * Return current filter icon */ diff --git a/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts index 5864d8fb90..7e3d7a6080 100644 --- a/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts @@ -144,23 +144,6 @@ describe('TaskFiltersComponent', () => { component.ngOnInit(); }); - it('should select the first filter as default', (done) => { - spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise)); - - const appId = '1'; - const change = new SimpleChange(null, appId, true); - - fixture.detectChanges(); - component.ngOnChanges({ 'appId': change }); - - component.success.subscribe((res) => { - expect(res).toBeDefined(); - expect(component.currentFilter).toBeDefined(); - expect(component.currentFilter.name).toEqual('FakeInvolvedTasks'); - done(); - }); - }); - it('should be able to fetch and select the default if the input filter is not valid', (done) => { spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalEmptyFilterPromise)); spyOn(component, 'createFiltersByAppId').and.stub(); @@ -194,25 +177,6 @@ describe('TaskFiltersComponent', () => { }); }); - it('should select the default task filter if filter input does not exist', (done) => { - spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise)); - - component.filterParam = new FilterParamsModel({ name: 'UnexistableFilter' }); - - const appId = '1'; - const change = new SimpleChange(null, appId, true); - - fixture.detectChanges(); - component.ngOnChanges({ 'appId': change }); - - component.success.subscribe((res) => { - expect(res).toBeDefined(); - expect(component.currentFilter).toBeDefined(); - expect(component.currentFilter.name).toEqual('FakeInvolvedTasks'); - done(); - }); - }); - it('should select the task filter based on the input by index param', (done) => { spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise)); diff --git a/lib/process-services/src/lib/task-list/components/task-filters.component.ts b/lib/process-services/src/lib/task-list/components/task-filters.component.ts index 1e73a97cac..4af32a0256 100644 --- a/lib/process-services/src/lib/task-list/components/task-filters.component.ts +++ b/lib/process-services/src/lib/task-list/components/task-filters.component.ts @@ -166,9 +166,6 @@ export class TaskFiltersComponent implements OnInit, OnChanges { (newFilter.name.toLocaleLowerCase() === filter.name.toLocaleLowerCase()) )); } - if (!this.currentFilter) { - this.selectDefaultTaskFilter(); - } } public selectFilterAndEmit(newFilter: FilterParamsModel) {