Skip to content

FOUR-15858 On Process End - Override Behavior #6888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ProcessMaker/Events/ProcessCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ProcessCompleted implements ShouldBroadcastNow

private $processRequest;

public $endEventDestination;

/**
* Create a new event instance.
*
Expand All @@ -26,6 +28,7 @@ public function __construct(ProcessRequest $processRequest)
{
$this->payloadUrl = route('api.requests.show', ['request' => $processRequest->getKey()]);
$this->processRequest = $processRequest;
$this->endEventDestination = $processRequest->getElementDestination();
}

/**
Expand Down
19 changes: 19 additions & 0 deletions ProcessMaker/Models/ProcessRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,4 +1053,23 @@ public function getProcessVersionAlternativeAttribute(): string | null

return null;
}

/**
* Retrieves the destination of the first closed end event.
*
* @return ?string Returns a string value representing the element destination of the first closed end event.
*/
public function getElementDestination(): ?string
{
$endEvents = $this->tokens()
->where('element_type', 'end_event')
->where('status', 'CLOSED')
->get();

if ($endEvents->count(0) === 0) {
return null;
}

return $endEvents->first()->elementDestination;
}
}
10 changes: 9 additions & 1 deletion ProcessMaker/Models/ProcessRequestToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,15 @@ public function reassign($toUserId, User $requestingUser)
event(new ActivityAssigned($this));
}

private function getElementDestination($elementDestinationType, $elementDestinationProp)
/**
* Determines the destination based on the type of element destination property
*
* @param elementDestinationType Used to determine the type of destination for an element.
* @param elementDestinationProp Used to determine the properties of the destination for an element.
*
* @return string|null Returns the destination URL.
*/
private function getElementDestination($elementDestinationType, $elementDestinationProp): ?string
{
$elementDestination = null;

Expand Down
10 changes: 8 additions & 2 deletions resources/views/tasks/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,17 @@ class="multiselect__tag-icon"></i>
`element_id=${this.task.element_id}&` +
`process_id=${this.task.process_id}`;
},
completed(processRequestId) {
completed(processRequestId, endEventDestination = null) {
// avoid redirection if using a customized renderer
if(this.task.component && this.task.component === 'AdvancedScreenFrame') {
if (this.task.component && this.task.component === 'AdvancedScreenFrame') {
return;
}

if (endEventDestination) {
this.redirect(endEventDestination);
return;
}

this.redirect(`/requests/${processRequestId}`);
},
error(processRequestId) {
Expand Down
Loading