Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 249
FOUR-15854 on task completed - override behavior#6875
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6385995b438c67478ca10105c797996ae52File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,6 +4,7 @@ | ||
| use Carbon\Carbon; | ||
| use DB; | ||
| use Exception; | ||
| use Illuminate\Auth\Access\AuthorizationException; | ||
| use Illuminate\Support\Arr; | ||
| use Illuminate\Support\Facades\Notification; | ||
| @@ -135,6 +136,7 @@ class ProcessRequestToken extends ProcessMakerModel implements TokenInterface | ||
| */ | ||
| protected $appends = [ | ||
| 'advanceStatus', | ||
| 'elementDestination' | ||
| ]; | ||
| /** | ||
| @@ -287,28 +289,63 @@ public function assignableUsers() | ||
| } | ||
| /** | ||
| * Get the BPMN definition of the element where the token is. | ||
| * Returns either the owner element or its properties | ||
| * | ||
| * @return array|\ProcessMaker\Nayra\Contracts\Bpmn\EntityInterface | ||
| * @param asObject Boolean flag that determines whether the function should return the element directly or its | ||
| * properties as an object. | ||
| * | ||
| * @return If the parameter is true, the function will return the object. If is false, the | ||
| * function will return the properties of the object. | ||
| */ | ||
| public function getDefinition($asObject = false, $par = null) | ||
| private function getDefinitionFromOwner($asObject) | ||
| { | ||
| if ($this->getOwner() && $this->getOwnerElement()) { | ||
| $element = $this->getOwnerElement(); | ||
| $element = $this->getOwnerElement(); | ||
| return $asObject ? $element : $element->getProperties(); | ||
| } | ||
| return $asObject ? $element : $element->getProperties(); | ||
| } | ||
| /** | ||
| * Retrieves a specific element's BPMN definition from a request object and returns either the element | ||
| * itself or its properties. | ||
| * | ||
| * @param asObject Boolean flag that determines whether the function should return the BPMN element instance | ||
| * as an object or just its properties. | ||
| * | ||
| * @return If `asObject` is false, the properties of the BPMN element instance are returned. | ||
| */ | ||
| private function getDefinitionFromRequest($asObject) | ||
devmiguelangel marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| { | ||
| $request = $this->processRequest ?: $this->getInstance(); | ||
| if (!$request) { | ||
| return []; | ||
| } | ||
| $process = $request->processVersion ?: $request->process; | ||
| $definitions = $process->getDefinitions(); | ||
| $element = $definitions->findElementById($this->element_id); | ||
| if (!$element) { | ||
| return []; | ||
| } | ||
| return $asObject ? $element->getBpmnElementInstance() : $element->getBpmnElementInstance()->getProperties(); | ||
| } | ||
| /** | ||
| * Get the BPMN definition of the element where the token is. | ||
| * | ||
| * @return array|\ProcessMaker\Nayra\Contracts\Bpmn\EntityInterface | ||
| */ | ||
| public function getDefinition($asObject = false, $par = null) | ||
| { | ||
| if ($this->getOwner() && $this->getOwnerElement()) { | ||
| return $this->getDefinitionFromOwner($asObject); | ||
| } | ||
| return $this->getDefinitionFromRequest($asObject); | ||
| } | ||
| /** | ||
| * Get the BPMN element node where the token is currently located. | ||
| * | ||
| @@ -1152,4 +1189,71 @@ public function reassign($toUserId, User $requestingUser) | ||
| $this->user->notify($notification); | ||
| event(new ActivityAssigned($this)); | ||
| } | ||
| private function getElementDestination($elementDestinationType, $elementDestinationProp) | ||
| { | ||
| $elementDestination = null; | ||
| switch ($elementDestinationType) { | ||
devmiguelangel marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| case 'customDashboard': | ||
| case 'externalURL': | ||
| if (array_key_exists('value', $elementDestinationProp)) { | ||
| if (is_string($elementDestinationProp['value'])) { | ||
| $elementDestination = $elementDestinationProp['value']; | ||
| } else { | ||
| $elementDestination = $elementDestinationProp['value']['url'] ?? null; | ||
| } | ||
| } | ||
| break; | ||
| case 'taskList': | ||
| $elementDestination = route('tasks.index'); | ||
| break; | ||
| case 'homepageDashboard': | ||
| if (hasPackage('package-dynamic-ui')) { | ||
devmiguelangel marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| $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; | ||
| default: | ||
| $elementDestination = null; | ||
| break; | ||
| } | ||
| return $elementDestination; | ||
| } | ||
| /** | ||
| * Determines the destination URL based on the element destination type specified in the definition. | ||
| * | ||
| * @return string|null | ||
| */ | ||
| public function getElementDestinationAttribute(): ?string | ||
| { | ||
| $definition = $this->getDefinition(); | ||
| $elementDestinationProp = $definition['elementDestination'] ?? null; | ||
| $elementDestinationType = null; | ||
| try { | ||
| $elementDestinationProp = json_decode($elementDestinationProp, true); | ||
| if (is_array($elementDestinationProp) && array_key_exists('type', $elementDestinationProp)) { | ||
| $elementDestinationType = $elementDestinationProp['type']; | ||
| } | ||
| } catch (Exception $e) { | ||
| return null; | ||
| } | ||
| return $this->getElementDestination($elementDestinationType, $elementDestinationProp); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.