diff --git a/ProcessMaker/Http/Resources/Task.php b/ProcessMaker/Http/Resources/Task.php index 186c6ab89f..893af985ad 100644 --- a/ProcessMaker/Http/Resources/Task.php +++ b/ProcessMaker/Http/Resources/Task.php @@ -38,6 +38,7 @@ class Task extends ApiResource 'interstitial', 'userRequestPermission', 'process', + 'elementDestination', ]; private $process = null; diff --git a/ProcessMaker/Models/ProcessRequest.php b/ProcessMaker/Models/ProcessRequest.php index c03ba2aa81..05e0578b14 100644 --- a/ProcessMaker/Models/ProcessRequest.php +++ b/ProcessMaker/Models/ProcessRequest.php @@ -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') diff --git a/ProcessMaker/Models/ProcessRequestToken.php b/ProcessMaker/Models/ProcessRequestToken.php index 2236e7a91d..ab3d2214b1 100644 --- a/ProcessMaker/Models/ProcessRequestToken.php +++ b/ProcessMaker/Models/ProcessRequestToken.php @@ -136,7 +136,6 @@ class ProcessRequestToken extends ProcessMakerModel implements TokenInterface */ protected $appends = [ 'advanceStatus', - 'elementDestination' ]; /** @@ -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)) { @@ -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': @@ -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; diff --git a/ProcessMaker/Traits/TaskResourceIncludes.php b/ProcessMaker/Traits/TaskResourceIncludes.php index 8b8db4a0f7..04aeff63a5 100644 --- a/ProcessMaker/Traits/TaskResourceIncludes.php +++ b/ProcessMaker/Traits/TaskResourceIncludes.php @@ -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; @@ -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]; + } }