[AAE-33096] added rootProcessInstanceId to dynamic component (#10762)

This commit is contained in:
tomasz hanaj 2025-04-03 12:13:16 +02:00 committed by GitHub
parent 500d4be4a3
commit 2d21340947
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 31 additions and 3 deletions

View File

@ -37,6 +37,7 @@ export class YourService extends ScreenRenderingService {
[canClaimTask]="canClaimTask()" [canClaimTask]="canClaimTask()"
[canUnclaimTask]="canUnclaimTask()" [canUnclaimTask]="canUnclaimTask()"
[processInstanceId]="taskDetails.processInstanceId" [processInstanceId]="taskDetails.processInstanceId"
[rootProcessInstanceId]="taskDetails.rootProcessInstanceId"
[screenId]="screenId" [screenId]="screenId"
[showCancelButton]="showCancelButton" [showCancelButton]="showCancelButton"
[taskName]="taskDetails.name" [taskName]="taskDetails.name"
@ -60,6 +61,7 @@ export class YourService extends ScreenRenderingService {
| canClaimTask | `boolean` | | Boolean informing if a task can be claimed. | | canClaimTask | `boolean` | | Boolean informing if a task can be claimed. |
| canUnclaimTask | `boolean` | | Boolean informing if a task can be unclaimed. | | canUnclaimTask | `boolean` | | Boolean informing if a task can be unclaimed. |
| processInstanceId | `string` | | Process Instance Id to fetch corresponding data. | | processInstanceId | `string` | | Process Instance Id to fetch corresponding data. |
| rootProcessInstanceId | `string` | | Root Process Instance Id to fetch corresponding data. |
| readOnly | `boolean` | false | Toggle readonly state of the task. | | readOnly | `boolean` | false | Toggle readonly state of the task. |
| showCancelButton | `boolean` | true | Toggle rendering of the `Cancel` button. | | showCancelButton | `boolean` | true | Toggle rendering of the `Cancel` button. |
| screenId | `string` | | Screen id to create dynamic component | | screenId | `string` | | Screen id to create dynamic component |
@ -94,6 +96,7 @@ Dynamic component must implement logic for method switchToDisplayMode.
[canClaimTask]="canClaimTask()" [canClaimTask]="canClaimTask()"
[canUnclaimTask]="canUnclaimTask()" [canUnclaimTask]="canUnclaimTask()"
[processInstanceId]="taskDetails.processInstanceId" [processInstanceId]="taskDetails.processInstanceId"
[rootProcessInstanceId]="taskDetails.rootProcessInstanceId"
[screenId]="screenId" [screenId]="screenId"
[showCancelButton]="showCancelButton" [showCancelButton]="showCancelButton"
[taskName]="taskDetails.name" [taskName]="taskDetails.name"

View File

@ -28,6 +28,7 @@ import { TaskScreenCloudComponent } from './screen-cloud.component';
<div class="adf-cloud-test-container"> <div class="adf-cloud-test-container">
test component test component
<div class="adf-cloud-test-container-taskId">{{ taskId }}</div> <div class="adf-cloud-test-container-taskId">{{ taskId }}</div>
<div class="adf-cloud-test-container-rootProcessInstanceId">{{ rootProcessInstanceId }}</div>
<button class="adf-cloud-test-container-complete-btn" (click)="onComplete()">complete</button> <button class="adf-cloud-test-container-complete-btn" (click)="onComplete()">complete</button>
</div> </div>
`, `,
@ -37,6 +38,7 @@ import { TaskScreenCloudComponent } from './screen-cloud.component';
class TestComponent { class TestComponent {
@Input() taskId = ''; @Input() taskId = '';
@Input() screenId = ''; @Input() screenId = '';
@Input() rootProcessInstanceId = '';
@Output() taskCompleted = new EventEmitter(); @Output() taskCompleted = new EventEmitter();
displayMode: string; displayMode: string;
onComplete() { onComplete() {
@ -49,7 +51,15 @@ class TestComponent {
@Component({ @Component({
selector: 'adf-cloud-test-actions-component', selector: 'adf-cloud-test-actions-component',
template: ` <adf-cloud-task-screen [taskId]="'1'" [appName]="'app-name-test'" [screenId]="'test'" (taskCompleted)="onTaskCompleted()" /> `, template: `
<adf-cloud-task-screen
[taskId]="'1'"
[appName]="'app-name-test'"
[screenId]="'test'"
[rootProcessInstanceId]="'abcd-1234'"
(taskCompleted)="onTaskCompleted()"
/>
`,
imports: [CommonModule, TaskScreenCloudComponent], imports: [CommonModule, TaskScreenCloudComponent],
standalone: true standalone: true
}) })
@ -91,6 +101,11 @@ describe('TaskScreenCloudComponent', () => {
expect((inputValueFromDynamicComponent.nativeElement as HTMLElement).textContent).toBe('1'); expect((inputValueFromDynamicComponent.nativeElement as HTMLElement).textContent).toBe('1');
}); });
it('should set input property rootProcessInstanceId for dynamic component', () => {
const inputValueFromDynamicComponent = fixture.debugElement.query(By.css('.adf-cloud-test-container-rootProcessInstanceId'));
expect((inputValueFromDynamicComponent.nativeElement as HTMLElement).textContent).toBe('abcd-1234');
});
it('should subscribe to the output of dynamic component', () => { it('should subscribe to the output of dynamic component', () => {
const onTaskCompletedSpy = spyOn(fixture.componentInstance, 'onTaskCompleted'); const onTaskCompletedSpy = spyOn(fixture.componentInstance, 'onTaskCompleted');
const btnComplete = fixture.debugElement.query(By.css('.adf-cloud-test-container-complete-btn')); const btnComplete = fixture.debugElement.query(By.css('.adf-cloud-test-container-complete-btn'));

View File

@ -64,6 +64,10 @@ export class TaskScreenCloudComponent implements OnInit {
@Input() @Input()
readOnly = false; readOnly = false;
/** Toggle readonly state of the task. */
@Input()
rootProcessInstanceId: string = '';
/** Emitted when the task is saved. */ /** Emitted when the task is saved. */
@Output() @Output()
taskSaved = new EventEmitter(); taskSaved = new EventEmitter();
@ -133,6 +137,9 @@ export class TaskScreenCloudComponent implements OnInit {
if (this.showCancelButton && Object.prototype.hasOwnProperty.call(this.componentRef.instance, 'showCancelButton')) { if (this.showCancelButton && Object.prototype.hasOwnProperty.call(this.componentRef.instance, 'showCancelButton')) {
this.componentRef.setInput('showCancelButton', this.showCancelButton); this.componentRef.setInput('showCancelButton', this.showCancelButton);
} }
if (this.rootProcessInstanceId && Object.prototype.hasOwnProperty.call(this.componentRef.instance, 'rootProcessInstanceId')) {
this.componentRef.setInput('rootProcessInstanceId', this.rootProcessInstanceId);
}
} }
subscribeToOutputs() { subscribeToOutputs() {

View File

@ -22,10 +22,11 @@ export interface UserTaskCustomUi {
canClaimTask: boolean; canClaimTask: boolean;
canUnclaimTask: boolean; canUnclaimTask: boolean;
processInstanceId: string; processInstanceId: string;
taskName: string; rootProcessInstanceId: string;
taskId: string;
screenId: string; screenId: string;
showCancelButton: boolean; showCancelButton: boolean;
taskName: string;
taskId: string;
cancelTask: EventEmitter<any>; cancelTask: EventEmitter<any>;
claimTask: EventEmitter<any>; claimTask: EventEmitter<any>;
error: EventEmitter<any>; error: EventEmitter<any>;

View File

@ -37,6 +37,7 @@ export interface TaskDetailsCloudModel {
priority?: number; priority?: number;
processDefinitionId?: string; processDefinitionId?: string;
processInstanceId?: string; processInstanceId?: string;
rootProcessInstanceId?: string;
status?: TaskStatus; status?: TaskStatus;
standalone?: boolean; standalone?: boolean;
candidateUsers?: string[]; candidateUsers?: string[];

View File

@ -30,6 +30,7 @@
[canClaimTask]="canClaimTask()" [canClaimTask]="canClaimTask()"
[canUnclaimTask]="canUnclaimTask()" [canUnclaimTask]="canUnclaimTask()"
[processInstanceId]="taskDetails.processInstanceId" [processInstanceId]="taskDetails.processInstanceId"
[rootProcessInstanceId]="taskDetails.rootProcessInstanceId"
[screenId]="screenId" [screenId]="screenId"
[showCancelButton]="showCancelButton" [showCancelButton]="showCancelButton"
[taskName]="taskDetails.name" [taskName]="taskDetails.name"