Skip to content

Commit d47a60f

Browse files
authored
Merge pull request #305 from netgrif/NAE-2232
[NAE-2232] Frontend Actions Task events resolver
2 parents 2c98977 + 705f89e commit d47a60f

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {ChangedFieldsService} from '../../changed-fields/services/changed-fields
2424
import {EventService} from '../../event/services/event.service';
2525
import {ChangedFieldsMap} from '../../event/services/interfaces/changed-fields-map';
2626
import {TaskEventOutcome} from '../../event/model/event-outcomes/task-outcomes/task-event-outcome';
27+
import {FrontActionService} from '../../actions/services/front-action.service';
28+
import {FrontAction} from '../../data-fields/models/changed-fields';
2729

2830

2931
/**
@@ -42,6 +44,7 @@ export class AssignTaskService extends TaskHandlingService {
4244
protected _eventQueue: EventQueueService,
4345
protected _eventService: EventService,
4446
protected _changedFieldsService: ChangedFieldsService,
47+
protected _frontActionService: FrontActionService,
4548
@Inject(NAE_TASK_OPERATIONS) protected _taskOperations: TaskOperations,
4649
@Optional() _selectedCaseService: SelectedCaseService,
4750
@Optional() protected _taskViewService: TaskViewService,
@@ -121,9 +124,15 @@ export class AssignTaskService extends TaskHandlingService {
121124
this._taskContentService.updateStateData(outcomeResource.outcome as AssignTaskEventOutcome);
122125
const changedFieldsMap: ChangedFieldsMap = this._eventService
123126
.parseChangedFieldsFromOutcomeTree(outcomeResource.outcome);
127+
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
128+
124129
if (!!changedFieldsMap) {
125130
this._changedFieldsService.emitChangedFields(changedFieldsMap);
126131
}
132+
if (frontActions?.length > 0) {
133+
this._frontActionService.runAll(frontActions);
134+
}
135+
127136
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
128137
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as AssignTaskEventOutcome);
129138
this._snackBar.openSuccessSnackBar(!!outcomeResource.outcome.message

projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ import {QueuedEvent} from '../../event-queue/model/queued-event';
2323
import {AfterAction} from '../../utility/call-chain/after-action';
2424
import {PermissionService} from '../../authorization/permission/permission.service';
2525
import {ChangedFieldsService} from '../../changed-fields/services/changed-fields.service';
26-
import { EventService} from '../../event/services/event.service';
26+
import {EventService} from '../../event/services/event.service';
2727
import {ChangedFieldsMap} from '../../event/services/interfaces/changed-fields-map';
2828
import {TaskEventOutcome} from '../../event/model/event-outcomes/task-outcomes/task-event-outcome';
29-
29+
import {FrontActionService} from '../../actions/services/front-action.service';
30+
import {FrontAction} from '../../data-fields/models/changed-fields';
3031
/**
3132
* Service that handles the logic of canceling a task.
3233
*/
@@ -49,7 +50,9 @@ export class CancelTaskService extends TaskHandlingService {
4950
@Optional() _selectedCaseService: SelectedCaseService,
5051
@Optional() protected _taskViewService: TaskViewService,
5152
_taskContentService: TaskContentService,
52-
protected permissionService: PermissionService) {
53+
protected permissionService: PermissionService,
54+
protected _frontActionService: FrontActionService
55+
) {
5356
super(_taskContentService, _selectedCaseService);
5457
}
5558

@@ -123,9 +126,15 @@ export class CancelTaskService extends TaskHandlingService {
123126
this._taskContentService.updateStateData(outcomeResource.outcome as CancelTaskEventOutcome);
124127
const changedFieldsMap: ChangedFieldsMap = this._eventService
125128
.parseChangedFieldsFromOutcomeTree(outcomeResource.outcome);
129+
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
130+
126131
if (!!changedFieldsMap) {
127132
this._changedFieldsService.emitChangedFields(changedFieldsMap);
128133
}
134+
if (frontActions?.length > 0) {
135+
this._frontActionService.runAll(frontActions);
136+
}
137+
129138
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
130139
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as CancelTaskEventOutcome);
131140
} else if (outcomeResource.error !== undefined) {

projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import {ChangedFieldsService} from '../../changed-fields/services/changed-fields
2424
import {EventService} from '../../event/services/event.service';
2525
import {ChangedFieldsMap} from '../../event/services/interfaces/changed-fields-map';
2626
import {TaskEventOutcome} from '../../event/model/event-outcomes/task-outcomes/task-event-outcome';
27-
27+
import {FrontActionService} from '../../actions/services/front-action.service';
28+
import {FrontAction} from '../../data-fields/models/changed-fields';
2829

2930
/**
3031
* Service that handles the logic of finishing a task.
@@ -45,7 +46,8 @@ export class FinishTaskService extends TaskHandlingService {
4546
protected _changedFieldsService: ChangedFieldsService,
4647
@Inject(NAE_TASK_OPERATIONS) protected _taskOperations: TaskOperations,
4748
@Optional() _selectedCaseService: SelectedCaseService,
48-
_taskContentService: TaskContentService) {
49+
_taskContentService: TaskContentService,
50+
protected _frontActionService: FrontActionService) {
4951
super(_taskContentService, _selectedCaseService);
5052
}
5153

@@ -136,9 +138,15 @@ export class FinishTaskService extends TaskHandlingService {
136138
this._taskContentService.updateStateData(outcomeResource.outcome as FinishTaskEventOutcome);
137139
const changedFieldsMap: ChangedFieldsMap = this._eventService
138140
.parseChangedFieldsFromOutcomeTree(outcomeResource.outcome);
141+
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
142+
139143
if (!!changedFieldsMap) {
140144
this._changedFieldsService.emitChangedFields(changedFieldsMap);
141145
}
146+
if (frontActions?.length > 0) {
147+
this._frontActionService.runAll(frontActions);
148+
}
149+
142150
this._taskOperations.reload();
143151
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as FinishTaskEventOutcome);
144152
this._taskOperations.close();

projects/netgrif-components-core/src/lib/task/services/task-data.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
489489
if (Object.keys(changedFieldsMap).length > 0) {
490490
this._changedFieldsService.emitChangedFields(changedFieldsMap);
491491
}
492-
if (!!frontActions && frontActions.length > 0) {
492+
if (frontActions?.length > 0) {
493493
this._frontActionService.runAll(frontActions);
494494
}
495495
this.clearWaitingForResponseFlag(context.body);

0 commit comments

Comments
 (0)