diff --git a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.html b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.html index dff061b4e4..8fc4281518 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.html +++ b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.html @@ -113,6 +113,9 @@ } @else if (hasScreen) { diff --git a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts index 6e96a196b4..289c98cd5c 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts @@ -310,6 +310,14 @@ describe('StartProcessCloudComponent', () => { expect(contentElement.textContent).toBe('Mock Screen Component'); }); + it('should inject screen input', () => { + formDefinitionSpy.and.returnValue(of(fakeStartForm)); + const processDefinition = fakeProcessDefinitions[2]; + component.processDefinitionCurrent = processDefinition; + fixture.detectChanges(); + expect(screenComponent.processDefinitionId()).toEqual(processDefinition.id); + }); + it('should toggle default process buttons', () => { screenComponent.defaultStartProcessButtonsConfigurationChange.emit({ show: false, disable: false }); fixture.detectChanges(); diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/base-screen/base-screen-cloud.component.ts b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/base-screen/base-screen-cloud.component.ts index a8ec356011..33c81b7a96 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/base-screen/base-screen-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/base-screen/base-screen-cloud.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, ComponentRef, inject, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; +import { Component, ComponentRef, inject, Input, OnInit, signal, ViewChild, ViewContainerRef } from '@angular/core'; import { ScreenRenderingService } from '../../../services/screen-rendering.service'; @Component({ @@ -29,6 +29,8 @@ export abstract class BaseScreenCloudComponent imple container: ViewContainerRef; protected componentRef: ComponentRef; + private readonly _componentRefChanged = signal | undefined>(undefined); + protected readonly componentRefChanged = this._componentRefChanged.asReadonly(); protected readonly screenRenderingService = inject(ScreenRenderingService); ngOnInit() { @@ -39,12 +41,13 @@ export abstract class BaseScreenCloudComponent imple if (this.screenId) { const componentType = this.screenRenderingService.resolveComponentType({ type: this.screenId }); this.componentRef = this.container.createComponent(componentType); + this._componentRefChanged.set(this.componentRef); this.setInputsForDynamicComponent(); this.subscribeToOutputs(); } } - protected abstract setInputsForDynamicComponent(): void; + protected setInputsForDynamicComponent(): void {} protected abstract subscribeToOutputs(): void; } diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.spec.ts index 595a7d4bef..77ac063799 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.spec.ts @@ -21,6 +21,7 @@ import { MockedTaskScreenCloudComponent } from '../../../../testing/start-proces import { provideScreen } from '../../../services/provide-screen'; import { By } from '@angular/platform-browser'; import { StartProcessScreenCloud, StartProcessScreenDefaultButtons } from './start-process-screen.model'; +import { TaskVariableCloud } from '../../../../form/models/task-variable-cloud.model'; describe('StartProcessScreenCloudComponent', () => { let component: StartProcessScreenCloudComponent; @@ -63,8 +64,30 @@ describe('StartProcessScreenCloudComponent', () => { expect(component.showStartProcessButtons()).toBe(startProcessScreenDefaultButtons.show); }); + it('should set appName', () => { + const screenInstance: StartProcessScreenCloud = fixture.debugElement.query(By.directive(MockedTaskScreenCloudComponent)).componentInstance; + expect(screenInstance.appName()).toEqual(''); + const newValue = 'new-app-name'; + fixture.componentRef.setInput('appName', newValue); + fixture.detectChanges(); + expect(screenInstance.appName()).toEqual(newValue); + }); + it('should set process definition id', () => { const screenInstance: StartProcessScreenCloud = fixture.debugElement.query(By.directive(MockedTaskScreenCloudComponent)).componentInstance; expect(screenInstance.processDefinitionId()).toBe(processDefinitionId); + const newId = 'new-id'; + fixture.componentRef.setInput('processDefinitionId', newId); + fixture.detectChanges(); + expect(screenInstance.processDefinitionId()).toEqual(newId); + }); + + it('should set resolvedValues', () => { + const screenInstance: StartProcessScreenCloud = fixture.debugElement.query(By.directive(MockedTaskScreenCloudComponent)).componentInstance; + expect(screenInstance.resolvedValues()).toBeUndefined(); + const newValues = [new TaskVariableCloud({ id: 'new-id', name: 'new-name' })]; + fixture.componentRef.setInput('resolvedValues', newValues); + fixture.detectChanges(); + expect(screenInstance.resolvedValues()).toEqual(newValues); }); }); diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.ts b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.ts index d066c2ee49..4cba3389f1 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen-cloud.component.ts @@ -15,11 +15,12 @@ * limitations under the License. */ -import { ChangeDetectionStrategy, Component, input, output, signal } from '@angular/core'; +import { ChangeDetectionStrategy, Component, effect, input, output, signal } from '@angular/core'; import { BaseScreenCloudComponent } from '../base-screen/base-screen-cloud.component'; import { MatCardModule } from '@angular/material/card'; import { CommonModule } from '@angular/common'; import { StartProcessScreenCloud } from './start-process-screen.model'; +import { TaskVariableCloud } from '../../../../form/models/task-variable-cloud.model'; @Component({ selector: 'adf-cloud-start-process-screen-cloud', @@ -30,16 +31,29 @@ import { StartProcessScreenCloud } from './start-process-screen.model'; changeDetection: ChangeDetectionStrategy.OnPush }) export class StartProcessScreenCloudComponent extends BaseScreenCloudComponent { + readonly appName = input(''); processDefinitionId = input(''); + readonly resolvedValues = input(); screenStartProcessPayloadChange = output(); disableStartProcessButton = output(); showStartProcessButtons = signal(false); - protected setInputsForDynamicComponent(): void { - if (this.processDefinitionId()) { - this.componentRef.setInput('processDefinitionId', this.processDefinitionId()); - } + constructor() { + super(); + effect(() => { + const componentRef = this.componentRefChanged(); + if (componentRef.instance && 'appName' in componentRef.instance) { + componentRef.setInput('appName', this.appName()); + } + }); + effect(() => this.componentRefChanged()?.setInput('processDefinitionId', this.processDefinitionId())); + effect(() => { + const componentRef = this.componentRefChanged(); + if (componentRef?.instance && 'resolvedValues' in componentRef.instance) { + componentRef.setInput('resolvedValues', this.resolvedValues()); + } + }); } protected subscribeToOutputs(): void { diff --git a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen.model.ts b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen.model.ts index 51a9964d04..e92ce60c16 100644 --- a/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen.model.ts +++ b/lib/process-services-cloud/src/lib/screen/components/screen-cloud/start-process-event-screen/start-process-screen.model.ts @@ -16,13 +16,16 @@ */ import { InputSignal, OutputEmitterRef } from '@angular/core'; +import { TaskVariableCloud } from '../../../../form/models/task-variable-cloud.model'; export interface StartProcessScreenDefaultButtons { show: boolean; disable: boolean; } export interface StartProcessScreenCloud { + readonly appName?: InputSignal; processDefinitionId: InputSignal; + readonly resolvedValues?: InputSignal; defaultStartProcessButtonsConfigurationChange: OutputEmitterRef; startProcessPayloadChanged: OutputEmitterRef; } diff --git a/lib/process-services-cloud/src/lib/testing/start-process-screen-mock.component.ts b/lib/process-services-cloud/src/lib/testing/start-process-screen-mock.component.ts index 92138774fa..3dfeb28e16 100644 --- a/lib/process-services-cloud/src/lib/testing/start-process-screen-mock.component.ts +++ b/lib/process-services-cloud/src/lib/testing/start-process-screen-mock.component.ts @@ -20,13 +20,16 @@ import { StartProcessScreenCloud, StartProcessScreenDefaultButtons } from '../screen/components/screen-cloud/start-process-event-screen/start-process-screen.model'; +import { TaskVariableCloud } from '../form/models/task-variable-cloud.model'; @Component({ selector: 'adf-cloud-mock-screen-component', template: `
Mock Screen Component
` }) export class MockedTaskScreenCloudComponent implements StartProcessScreenCloud { + readonly appName = input(''); processDefinitionId = input(''); + readonly resolvedValues = input(); defaultStartProcessButtonsConfigurationChange = output(); startProcessPayloadChanged = output(); }