mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-34656 Hide all counters in Workspace which do not provide value (#10896)
* Hide all counters in Workspace which do not provide value * Fixed a copy & paste issue
This commit is contained in:
committed by
GitHub
parent
1971980216
commit
8cb7a1719f
@@ -531,6 +531,19 @@ describe('ProcessFiltersCloudComponent', () => {
|
|||||||
expect(component.updatedFiltersSet.has(filterKeyTest)).toBeFalsy();
|
expect(component.updatedFiltersSet.has(filterKeyTest)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call fetchProcessFilterCounter only if filter.showCounter is true', () => {
|
||||||
|
const filterWithCounter = { ...mockProcessFilters[0], showCounter: true };
|
||||||
|
const filterWithoutCounter = { ...mockProcessFilters[1], showCounter: false };
|
||||||
|
const fetchSpy = spyOn<any>(component, 'fetchProcessFilterCounter').and.returnValue(of(42));
|
||||||
|
|
||||||
|
component.filters = [filterWithCounter, filterWithoutCounter];
|
||||||
|
component.updateFilterCounters();
|
||||||
|
|
||||||
|
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(fetchSpy).toHaveBeenCalledWith(filterWithCounter);
|
||||||
|
expect(fetchSpy).not.toHaveBeenCalledWith(filterWithoutCounter);
|
||||||
|
});
|
||||||
|
|
||||||
describe('Highlight Selected Filter', () => {
|
describe('Highlight Selected Filter', () => {
|
||||||
const allProcessesFilterKey = mockProcessFilters[0].key;
|
const allProcessesFilterKey = mockProcessFilters[0].key;
|
||||||
const runningProcessesFilterKey = mockProcessFilters[1].key;
|
const runningProcessesFilterKey = mockProcessFilters[1].key;
|
||||||
|
@@ -278,6 +278,10 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
|
|||||||
* @param filter filter
|
* @param filter filter
|
||||||
*/
|
*/
|
||||||
updateFilterCounter(filter: ProcessFilterCloudModel): void {
|
updateFilterCounter(filter: ProcessFilterCloudModel): void {
|
||||||
|
if (!filter?.showCounter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchProcessFilterCounter(filter)
|
this.fetchProcessFilterCounter(filter)
|
||||||
.pipe(
|
.pipe(
|
||||||
tap((filterCounter) => {
|
tap((filterCounter) => {
|
||||||
|
@@ -49,6 +49,7 @@ export class ProcessFilterCloudModel {
|
|||||||
suspendedDateType: DateCloudFilterType;
|
suspendedDateType: DateCloudFilterType;
|
||||||
completedDate: Date;
|
completedDate: Date;
|
||||||
environmentId?: string;
|
environmentId?: string;
|
||||||
|
showCounter: boolean;
|
||||||
|
|
||||||
processDefinitionNames: string[] | null;
|
processDefinitionNames: string[] | null;
|
||||||
processNames: string[] | null;
|
processNames: string[] | null;
|
||||||
@@ -74,6 +75,7 @@ export class ProcessFilterCloudModel {
|
|||||||
this.name = obj.name || null;
|
this.name = obj.name || null;
|
||||||
this.key = obj.key || null;
|
this.key = obj.key || null;
|
||||||
this.environmentId = obj.environmentId;
|
this.environmentId = obj.environmentId;
|
||||||
|
this.showCounter = obj.showCounter || false;
|
||||||
this.icon = obj.icon || null;
|
this.icon = obj.icon || null;
|
||||||
this.index = obj.index || null;
|
this.index = obj.index || null;
|
||||||
this.appName = obj.appName || obj.appName === '' ? obj.appName : null;
|
this.appName = obj.appName || obj.appName === '' ? obj.appName : null;
|
||||||
|
@@ -378,7 +378,8 @@ export class ProcessFilterCloudService {
|
|||||||
appName,
|
appName,
|
||||||
sort: 'startDate',
|
sort: 'startDate',
|
||||||
status: 'RUNNING',
|
status: 'RUNNING',
|
||||||
order: 'DESC'
|
order: 'DESC',
|
||||||
|
showCounter: true
|
||||||
}),
|
}),
|
||||||
new ProcessFilterCloudModel({
|
new ProcessFilterCloudModel({
|
||||||
name: 'ADF_CLOUD_PROCESS_FILTERS.COMPLETED_PROCESSES',
|
name: 'ADF_CLOUD_PROCESS_FILTERS.COMPLETED_PROCESSES',
|
||||||
@@ -387,7 +388,8 @@ export class ProcessFilterCloudService {
|
|||||||
appName,
|
appName,
|
||||||
sort: 'startDate',
|
sort: 'startDate',
|
||||||
status: 'COMPLETED',
|
status: 'COMPLETED',
|
||||||
order: 'DESC'
|
order: 'DESC',
|
||||||
|
showCounter: false
|
||||||
}),
|
}),
|
||||||
new ProcessFilterCloudModel({
|
new ProcessFilterCloudModel({
|
||||||
name: 'ADF_CLOUD_PROCESS_FILTERS.ALL_PROCESSES',
|
name: 'ADF_CLOUD_PROCESS_FILTERS.ALL_PROCESSES',
|
||||||
@@ -396,7 +398,8 @@ export class ProcessFilterCloudService {
|
|||||||
appName,
|
appName,
|
||||||
sort: 'startDate',
|
sort: 'startDate',
|
||||||
status: '',
|
status: '',
|
||||||
order: 'DESC'
|
order: 'DESC',
|
||||||
|
showCounter: false
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
|||||||
import { TaskFilterCloudAdapter } from '../../../../models/filter-cloud-model';
|
import { TaskFilterCloudAdapter } from '../../../../models/filter-cloud-model';
|
||||||
import { ApolloTestingModule } from 'apollo-angular/testing';
|
import { ApolloTestingModule } from 'apollo-angular/testing';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { TaskFilterCloudModel } from '../../models/filter-cloud.model';
|
||||||
|
|
||||||
describe('TaskFiltersCloudComponent', () => {
|
describe('TaskFiltersCloudComponent', () => {
|
||||||
let loader: HarnessLoader;
|
let loader: HarnessLoader;
|
||||||
@@ -562,6 +563,19 @@ describe('TaskFiltersCloudComponent', () => {
|
|||||||
expect(component.updatedCountersSet.has(fakeFilterKey)).toBe(true);
|
expect(component.updatedCountersSet.has(fakeFilterKey)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call fetchTaskFilterCounter only if filter.showCounter is true', () => {
|
||||||
|
const filterWithCounter = new TaskFilterCloudModel({ ...defaultTaskFiltersMock[0], showCounter: true });
|
||||||
|
const filterWithoutCounter = new TaskFilterCloudModel({ ...defaultTaskFiltersMock[1], showCounter: false });
|
||||||
|
const fetchSpy = spyOn<any>(component, 'fetchTaskFilterCounter').and.returnValue(of(42));
|
||||||
|
|
||||||
|
component.filters = [filterWithCounter, filterWithoutCounter];
|
||||||
|
component.updateFilterCounters();
|
||||||
|
|
||||||
|
expect(fetchSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(fetchSpy).toHaveBeenCalledWith(filterWithCounter);
|
||||||
|
expect(fetchSpy).not.toHaveBeenCalledWith(filterWithoutCounter);
|
||||||
|
});
|
||||||
|
|
||||||
describe('Highlight Selected Filter', () => {
|
describe('Highlight Selected Filter', () => {
|
||||||
const assignedTasksFilterKey = defaultTaskFiltersMock[1].key;
|
const assignedTasksFilterKey = defaultTaskFiltersMock[1].key;
|
||||||
const queuedTasksFilterKey = defaultTaskFiltersMock[0].key;
|
const queuedTasksFilterKey = defaultTaskFiltersMock[0].key;
|
||||||
|
Reference in New Issue
Block a user