From 2585e1eab90dceb4a79bb0d055f20e8b89a2ed19 Mon Sep 17 00:00:00 2001 From: "tomek.hanaj" Date: Tue, 17 Dec 2024 13:38:17 +0100 Subject: [PATCH] [AAE-29424] applied pr comments --- .../screen-cloud/screen-cloud.component.html | 4 +- .../screen-cloud.component.spec.ts | 10 +-- .../screen-cloud/screen-cloud.component.ts | 11 ++- .../lib/services/screen-rendering.service.ts | 2 +- .../task-form-cloud.component.html | 49 ++++++------- .../user-task-cloud-buttons.component.html | 19 +++--- .../user-task-cloud.component.html | 28 +++++--- .../user-task-cloud.component.ts | 68 +++++++++---------- .../lib/task/task-form/task-form.module.ts | 4 +- 9 files changed, 101 insertions(+), 94 deletions(-) diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.html b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.html index 3e609e3baa..94f8ea35f1 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.html +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.html @@ -1,3 +1 @@ -
-
-
+
diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.spec.ts index 5014b4a1ce..43fc628f48 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.spec.ts @@ -17,7 +17,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ScreenCloudComponent } from './screen-cloud.component'; +import { TaskScreenCloudComponent } from './screen-cloud.component'; import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { ScreenRenderingService } from '../../../services/public-api'; @@ -31,15 +31,15 @@ import { By } from '@angular/platform-browser'; }) class TestComponent {} -describe('ScreenCloudComponent', () => { - let fixture: ComponentFixture; +describe('TaskScreenCloudComponent', () => { + let fixture: ComponentFixture; let screenRenderingService: ScreenRenderingService; beforeEach(() => { TestBed.configureTestingModule({ - imports: [ScreenCloudComponent, TestComponent] + imports: [TaskScreenCloudComponent, TestComponent] }); - fixture = TestBed.createComponent(ScreenCloudComponent); + fixture = TestBed.createComponent(TaskScreenCloudComponent); screenRenderingService = TestBed.inject(ScreenRenderingService); screenRenderingService.register({ ['test']: () => TestComponent }); fixture.componentRef.setInput('screenId', 'test'); diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts index 968a4bc308..3ea9c1a4bb 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/screen-cloud.component.ts @@ -15,18 +15,17 @@ * limitations under the License. */ -import { DynamicComponentModel } from '@alfresco/adf-core'; -import { ScreenRenderingService } from '../../../services/public-api'; import { CommonModule } from '@angular/common'; import { Component, ComponentRef, inject, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; +import { ScreenRenderingService } from '../../../services/public-api'; @Component({ - selector: 'adf-cloud-screen-cloud', + selector: 'adf-cloud-task-screen', standalone: true, imports: [CommonModule], template: '
' }) -export class ScreenCloudComponent implements OnInit { +export class TaskScreenCloudComponent implements OnInit { /** Task id to fetch corresponding form and values. */ @Input() taskId: string; /** App id to fetch corresponding form and values. */ @@ -41,15 +40,13 @@ export class ScreenCloudComponent implements OnInit { @ViewChild('container', { read: ViewContainerRef, static: true }) container: ViewContainerRef; - screenComponent: DynamicComponentModel; componentRef: ComponentRef; private readonly screenRenderingService = inject(ScreenRenderingService); ngOnInit() { if (this.screenId) { - this.screenComponent = { type: this.screenId }; - const componentType = this.screenRenderingService.resolveComponentType(this.screenComponent); + const componentType = this.screenRenderingService.resolveComponentType({ type: this.screenId }); this.componentRef = this.container.createComponent(componentType); if (this.taskId) { this.componentRef.setInput('taskId', this.taskId); diff --git a/lib/process-services-cloud/src/lib/services/screen-rendering.service.ts b/lib/process-services-cloud/src/lib/services/screen-rendering.service.ts index 7cc13efe0e..156f727a45 100644 --- a/lib/process-services-cloud/src/lib/services/screen-rendering.service.ts +++ b/lib/process-services-cloud/src/lib/services/screen-rendering.service.ts @@ -15,8 +15,8 @@ * limitations under the License. */ +import { DynamicComponentMapper } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; -import { DynamicComponentMapper } from '../../../../core/src/lib/common/services/dynamic-component-mapper.service'; @Injectable({ providedIn: 'root' diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud/task-form-cloud.component.html b/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud/task-form-cloud.component.html index 25d27e255f..0b85839fe4 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud/task-form-cloud.component.html +++ b/lib/process-services-cloud/src/lib/task/task-form/components/task-form-cloud/task-form-cloud.component.html @@ -1,25 +1,27 @@ -
- +
+ + (error)="onError($event)" + > diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud-buttons/user-task-cloud-buttons.component.html b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud-buttons/user-task-cloud-buttons.component.html index 73144426e0..7b06233dee 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud-buttons/user-task-cloud-buttons.component.html +++ b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud-buttons/user-task-cloud-buttons.component.html @@ -1,29 +1,32 @@ diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html index af825db1e1..e07985f75c 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html +++ b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.html @@ -7,24 +7,31 @@ [appName]="appName" [candidateUsers]="candidateUsers" [candidateGroups]="candidateGroups" - [taskId]="taskId" - [taskDetails]="taskDetails" - [showValidationIcon]="showValidationIcon" - [showTitle]="showTitle" [displayModeConfigurations]="displayModeConfigurations" [fieldValidators]="fieldValidators" + [showValidationIcon]="showValidationIcon" + [showTitle]="showTitle" + [taskId]="taskId" + [taskDetails]="taskDetails" (cancelClick)="onCancelForm()" + (executeOutcome)="onExecuteOutcome($event)" + (error)="onError($event)" (formSaved)="onFormSaved()" + (formContentClicked)="onFormContentClicked($event)" (taskCompleted)="onCompleteTaskForm()" + (taskClaimed)="onClaimTask()" (taskUnclaimed)="onTaskUnclaimed()" - (formContentClicked)="onFormContentClicked($event)" - (executeOutcome)="onExecuteOutcome($event)" - (error)="onError($event)"> + > - + + @@ -48,8 +55,8 @@

@@ -68,7 +75,6 @@

- diff --git a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts index 37ef552d0f..acc0a6a95b 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-form/components/user-task-cloud/user-task-cloud.component.ts @@ -128,6 +128,26 @@ export class UserTaskCloudComponent implements OnInit, OnChanges { private taskCloudService: TaskCloudService = inject(TaskCloudService); private readonly destroyRef = inject(DestroyRef); + ngOnChanges(changes: SimpleChanges) { + const appName = changes['appName']; + if (appName && appName.currentValue !== appName.previousValue && this.taskId) { + this.loadTask(); + return; + } + + const taskId = changes['taskId']; + if (taskId?.currentValue && this.appName) { + this.loadTask(); + return; + } + } + + ngOnInit() { + if (this.appName === '' && this.taskId) { + this.loadTask(); + } + } + canClaimTask(): boolean { return !this.readOnly && this.taskCloudService.canClaimTask(this.taskDetails) && this.hasCandidateUsersOrGroups(); } @@ -140,7 +160,7 @@ export class UserTaskCloudComponent implements OnInit, OnChanges { return !this.readOnly && this.taskCloudService.canUnclaimTask(this.taskDetails) && this.hasCandidateUsersOrGroups(); } - getTaskType() { + getTaskType(): void { if (this.taskDetails && !!this.taskDetails.formKey && this.taskDetails.formKey.includes(this.taskTypeEnum.Form)) { this.taskType = this.taskTypeEnum.Form; } else if (this.taskDetails && !!this.taskDetails.formKey && this.taskDetails.formKey.includes(this.taskTypeEnum.Screen)) { @@ -164,52 +184,52 @@ export class UserTaskCloudComponent implements OnInit, OnChanges { return this.hasCandidateUsers() || this.hasCandidateGroups(); } - onCancelForm() { + onCancelForm(): void { this.cancelClick.emit(); } - onCancelClick() { + onCancelClick(): void { this.cancelClick.emit(this.taskId); } - onClaimTask() { + onClaimTask(): void { this.loadTask(); this.taskClaimed.emit(this.taskId); } - onCompleteTask() { + onCompleteTask(): void { this.loadTask(); this.taskCompleted.emit(this.taskId); } - onCompleteTaskForm() { + onCompleteTaskForm(): void { this.taskCompleted.emit(); } - onError(data: any) { + onError(data: any): void { this.error.emit(data); } - onExecuteOutcome(outcome: FormOutcomeEvent) { + onExecuteOutcome(outcome: FormOutcomeEvent): void { this.executeOutcome.emit(outcome); } - onFormContentClicked(content: ContentLinkModel) { + onFormContentClicked(content: ContentLinkModel): void { this.formContentClicked.emit(content); } - onFormSaved() { + onFormSaved(): void { this.formSaved.emit(); } - onTaskUnclaimed() { + onTaskUnclaimed(): void { this.taskUnclaimed.emit(); } - onUnclaimTask() { + onUnclaimTask(): void { this.loadTask(); this.taskUnclaimed.emit(this.taskId); } - private loadTask() { + private loadTask(): void { this.loading = true; this.taskCloudService .getTaskById(this.appName, this.taskId) @@ -225,29 +245,9 @@ export class UserTaskCloudComponent implements OnInit, OnChanges { this.taskCloudService.getCandidateGroups(this.appName, this.taskId).subscribe((groups) => (this.candidateGroups = groups || [])); } - public switchToDisplayMode(newDisplayMode?: string) { + public switchToDisplayMode(newDisplayMode?: string): void { if (this.adfCloudTaskForm) { this.adfCloudTaskForm.switchToDisplayMode(newDisplayMode); } } - - ngOnChanges(changes: SimpleChanges) { - const appName = changes['appName']; - if (appName && appName.currentValue !== appName.previousValue && this.taskId) { - this.loadTask(); - return; - } - - const taskId = changes['taskId']; - if (taskId?.currentValue && this.appName) { - this.loadTask(); - return; - } - } - - ngOnInit() { - if (this.appName === '' && this.taskId) { - this.loadTask(); - } - } } diff --git a/lib/process-services-cloud/src/lib/task/task-form/task-form.module.ts b/lib/process-services-cloud/src/lib/task/task-form/task-form.module.ts index 75d5b8ad04..cb3fca0743 100644 --- a/lib/process-services-cloud/src/lib/task/task-form/task-form.module.ts +++ b/lib/process-services-cloud/src/lib/task/task-form/task-form.module.ts @@ -22,12 +22,12 @@ import { FormCloudModule } from '../../form/form-cloud.module'; import { TaskDirectiveModule } from '../directives/task-directive.module'; import { TaskFormCloudComponent } from './components/task-form-cloud/task-form-cloud.component'; import { CoreModule } from '@alfresco/adf-core'; -import { ScreenCloudComponent } from '../../screen/components/screen-cloud/screen-cloud.component'; +import { TaskScreenCloudComponent } from '../../screen/components/screen-cloud/screen-cloud.component'; import { UserTaskCloudComponent } from './components/user-task-cloud/user-task-cloud.component'; import { UserTaskCloudButtonsComponent } from './components/user-task-cloud-buttons/user-task-cloud-buttons.component'; @NgModule({ - imports: [CoreModule, CommonModule, MaterialModule, FormCloudModule, TaskDirectiveModule, ScreenCloudComponent], + imports: [CoreModule, CommonModule, MaterialModule, FormCloudModule, TaskDirectiveModule, TaskScreenCloudComponent], declarations: [TaskFormCloudComponent, UserTaskCloudComponent, UserTaskCloudButtonsComponent], exports: [TaskFormCloudComponent, UserTaskCloudComponent] })