From 63859951962d68fdae90d063bac79139246c3bbf Mon Sep 17 00:00:00 2001 From: Miguel Angel Date: Thu, 23 May 2024 20:19:15 -0400 Subject: [PATCH 1/5] feat: add element destination attribute to process request token model, set elementDestinationURL in session storage --- ProcessMaker/Models/ProcessRequestToken.php | 46 +++++++++++++++++++ .../components/ProcessTab.vue | 4 ++ resources/views/tasks/edit.blade.php | 10 +++- resources/views/tasks/index.blade.php | 2 + 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/ProcessMaker/Models/ProcessRequestToken.php b/ProcessMaker/Models/ProcessRequestToken.php index 85ce41d136..97c54d1797 100644 --- a/ProcessMaker/Models/ProcessRequestToken.php +++ b/ProcessMaker/Models/ProcessRequestToken.php @@ -135,6 +135,7 @@ class ProcessRequestToken extends ProcessMakerModel implements TokenInterface */ protected $appends = [ 'advanceStatus', + 'elementDestination' ]; /** @@ -299,6 +300,11 @@ public function getDefinition($asObject = false, $par = null) return $asObject ? $element : $element->getProperties(); } $request = $this->processRequest ?: $this->getInstance(); + + if (!$request) { + return []; + } + $process = $request->processVersion ?: $request->process; $definitions = $process->getDefinitions(); $element = $definitions->findElementById($this->element_id); @@ -1152,4 +1158,44 @@ public function reassign($toUserId, User $requestingUser) $this->user->notify($notification); event(new ActivityAssigned($this)); } + + /** + * Determines the destination URL based on the element destination type specified in the definition. + * + * @return string|null + */ + public function getElementDestinationAttribute(): ?string + { + $definition = $this->getDefinition(); + $elementDestinationType = $definition['elementDestinationType'] ?? null; + $elementDestination = null; + + if ($elementDestinationType) { + switch ($elementDestinationType) { + case 'customDashboard': + case 'externalURL': + $elementDestination = $definition['elementDestinationURL'] ?? null; + break; + case 'taskList': + $elementDestination = route('tasks.index'); + break; + case 'homepageDashboard': + if (hasPackage('package-dynamic-ui')) { + $user = auth()->user(); + $elementDestination = \ProcessMaker\Package\PackageDynamicUI\Models\DynamicUI::getHomePage($user); + } else { + $elementDestination = route('home'); + } + break; + case 'processLaunchpad': + $elementDestination = route('process.browser.index', ['process' => $this->process_id, 'categorySelected' => -1]); + break; + case 'taskSource': + $elementDestination = $elementDestinationType; + break; + } + } + + return $elementDestination; + } } diff --git a/resources/js/processes-catalogue/components/ProcessTab.vue b/resources/js/processes-catalogue/components/ProcessTab.vue index c327460d78..d5b451733a 100644 --- a/resources/js/processes-catalogue/components/ProcessTab.vue +++ b/resources/js/processes-catalogue/components/ProcessTab.vue @@ -29,6 +29,7 @@