Skip to content

FOUR-15859: On Process End - Start a request for another selected process #6918

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 2 commits into from
Jun 10, 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
1 change: 1 addition & 0 deletions ProcessMaker/Http/Resources/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Task extends ApiResource
'interstitial',
'userRequestPermission',
'process',
'elementDestination',
];

private $process = null;
Expand Down
4 changes: 2 additions & 2 deletions ProcessMaker/Models/ProcessRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,9 @@ public function getProcessVersionAlternativeAttribute(): string | 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.
* @return ?array Returns a string value representing the element destination of the first closed end event.
*/
public function getElementDestination(): ?string
public function getElementDestination(): ?array
{
$endEvents = $this->tokens()
->where('element_type', 'end_event')
Expand Down
18 changes: 10 additions & 8 deletions ProcessMaker/Models/ProcessRequestToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class ProcessRequestToken extends ProcessMakerModel implements TokenInterface
*/
protected $appends = [
'advanceStatus',
'elementDestination'
];

/**
Expand Down Expand Up @@ -1196,13 +1195,14 @@ public function reassign($toUserId, User $requestingUser)
* @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.
* @return array|null Returns the destination URL.
*/
private function getElementDestination($elementDestinationType, $elementDestinationProp): ?string
private function getElementDestination($elementDestinationType, $elementDestinationProp): ?array
{
$elementDestination = null;

switch ($elementDestinationType) {
case 'anotherProcess':
case 'customDashboard':
case 'externalURL':
if (array_key_exists('value', $elementDestinationProp)) {
Expand All @@ -1227,7 +1227,7 @@ private function getElementDestination($elementDestinationType, $elementDestinat
case 'processLaunchpad':
$elementDestination = route('process.browser.index', [
'process' => $this->process_id,
'categorySelected' => -1
'categorySelected' => -1,
]);
break;
case 'taskSource':
Expand All @@ -1236,18 +1236,20 @@ private function getElementDestination($elementDestinationType, $elementDestinat
default:
$elementDestination = null;
break;

}

return $elementDestination;
return [
'type' => $elementDestinationType,
'value' => $elementDestination,
];
}

/**
* Determines the destination URL based on the element destination type specified in the definition.
*
* @return string|null
* @return array|null
*/
public function getElementDestinationAttribute(): ?string
public function getElementDestinationAttribute(): ?array
{
$definition = $this->getDefinition();
$elementDestinationProp = $definition['elementDestination'] ?? null;
Expand Down
13 changes: 13 additions & 0 deletions ProcessMaker/Traits/TaskResourceIncludes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use ProcessMaker\Http\Resources\ScreenVersion as ScreenVersionResource;
use ProcessMaker\Http\Resources\Users;
use ProcessMaker\Managers\DataManager;
use ProcessMaker\Models\ProcessRequestToken;
use ProcessMaker\Models\TaskDraft;
use ProcessMaker\ProcessTranslations\ProcessTranslation;
use StdClass;
Expand Down Expand Up @@ -137,4 +138,16 @@ private function includeUserRequestPermission()

return ['user_request_permission' => $userRequestPermission];
}

/**
* Include the element destination in the resource response.
*
* @return array
*/
private function includeElementDestination()
{
$elementDestination = $this->resource->getElementDestinationAttribute();

return ['elementDestination' => $elementDestination];
}
}
Loading