From e7a34adb23fcb03db27dff1310930d457e849c78 Mon Sep 17 00:00:00 2001 From: Ehsan Rezaei Date: Fri, 14 Apr 2023 20:47:32 +0200 Subject: [PATCH 1/2] AAE-13282: Fixing save preferences on service tasks --- .../base-task-list-cloud.component.ts | 18 ++++++++++++++--- .../service-task-list-cloud.component.spec.ts | 20 ++++++------------- .../service-task-list-cloud.component.ts | 2 -- .../task-list-cloud.component.spec.ts | 12 ++++------- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts index bd006c4bbe0..f2df0797153 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts @@ -157,6 +157,9 @@ export abstract class BaseTaskListCloudComponent extends DataTableS if (changes['sorting']) { this.formatSorting(changes['sorting'].currentValue); } + if (changes['appName']) { + this.retrieveTasksPreferences(); + } this.reload(); } @@ -165,7 +168,8 @@ export abstract class BaseTaskListCloudComponent extends DataTableS this.onDestroy$.complete(); } - ngAfterContentInit() { + private retrieveTasksPreferences(): void { + this.isLoading = true; this.cloudPreferenceService.getPreferences(this.appName).pipe( take(1), map((preferences => { @@ -194,8 +198,16 @@ export abstract class BaseTaskListCloudComponent extends DataTableS } this.createDatatableSchema(); - } - ); + this.createColumns(); + this.isLoading = false; + }, (error) => { + this.error.emit(error); + this.isLoading = false; + }); + } + + ngAfterContentInit(): void { + this.retrieveTasksPreferences(); } isListEmpty(): boolean { diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts index 2c41b2bbfb4..cc65932a6c3 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts @@ -130,15 +130,9 @@ describe('ServiceTaskListCloudComponent', () => { spyOn(serviceTaskListCloudService, 'getServiceTaskByRequest').and.returnValue(of(emptyList)); fixture.detectChanges(); - expect(component.isLoading).toBe(true); - let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); - expect(loadingContent.nativeElement).toBeDefined(); - - const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); - component.ngOnChanges({ appName }); - fixture.detectChanges(); + expect(component.isLoading).toBe(false); - loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(loadingContent).toBeFalsy(); const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); @@ -150,15 +144,13 @@ describe('ServiceTaskListCloudComponent', () => { const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); fixture.detectChanges(); - expect(component.isLoading).toBe(true); - let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); - expect(loadingContent.nativeElement).toBeDefined(); + expect(component.isLoading).toBe(false); component.ngOnChanges({ appName }); fixture.detectChanges(); expect(component.isLoading).toBe(false); - loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(loadingContent).toBeFalsy(); const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); @@ -169,7 +161,7 @@ describe('ServiceTaskListCloudComponent', () => { it('should use the custom schemaColumn from app.config.json', () => { component.presetColumn = 'fakeCustomSchema'; - component.ngAfterContentInit(); + // component.ngAfterContentInit(); fixture.detectChanges(); expect(component.columns).toEqual(fakeCustomSchema); }); @@ -182,7 +174,7 @@ describe('ServiceTaskListCloudComponent', () => { }); it('should return an empty task list when no input parameters are passed', () => { - component.ngAfterContentInit(); + // component.ngAfterContentInit(); expect(component.rows).toBeDefined(); expect(component.isListEmpty()).toBeTruthy(); }); diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts index b862bb0b280..5a59567fcbc 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts @@ -52,7 +52,6 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent { this.requestNode = this.createRequestNode(); if (this.requestNode.appName || this.requestNode.appName === '') { - this.isLoading = true; combineLatest([ this.serviceTaskListCloudService.getServiceTaskByRequest(this.requestNode), @@ -63,7 +62,6 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent { ([tasks]) => { this.rows = tasks.list.entries; this.success.emit(tasks); - this.isLoading = false; this.pagination.next(tasks.list.pagination); }, (error) => { this.error.emit(error); diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts index bee6a286f08..ac658233038 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts @@ -160,15 +160,13 @@ describe('TaskListCloudComponent', () => { spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(emptyList)); fixture.detectChanges(); - expect(component.isLoading).toBe(true); - let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); - expect(loadingContent.nativeElement).toBeDefined(); + expect(component.isLoading).toBe(false); const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); component.ngOnChanges({ appName }); fixture.detectChanges(); - loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(loadingContent).toBeFalsy(); const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); @@ -180,15 +178,13 @@ describe('TaskListCloudComponent', () => { const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); fixture.detectChanges(); - expect(component.isLoading).toBe(true); - let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); - expect(loadingContent.nativeElement).toBeDefined(); + expect(component.isLoading).toBe(false); component.ngOnChanges({ appName }); fixture.detectChanges(); expect(component.isLoading).toBe(false); - loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); + const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(loadingContent).toBeFalsy(); const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content')); From a5dea5b6ac81fd253c2d243a7a8687b9b18fccea Mon Sep 17 00:00:00 2001 From: Ehsan Rezaei Date: Fri, 14 Apr 2023 20:50:37 +0200 Subject: [PATCH 2/2] AAE-13282: Removing comments --- .../components/service-task-list-cloud.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts index cc65932a6c3..33a427218a6 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts @@ -161,7 +161,7 @@ describe('ServiceTaskListCloudComponent', () => { it('should use the custom schemaColumn from app.config.json', () => { component.presetColumn = 'fakeCustomSchema'; - // component.ngAfterContentInit(); + component.ngAfterContentInit(); fixture.detectChanges(); expect(component.columns).toEqual(fakeCustomSchema); }); @@ -174,7 +174,7 @@ describe('ServiceTaskListCloudComponent', () => { }); it('should return an empty task list when no input parameters are passed', () => { - // component.ngAfterContentInit(); + component.ngAfterContentInit(); expect(component.rows).toBeDefined(); expect(component.isListEmpty()).toBeTruthy(); });