Skip to content
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

FOUR-15854 on task completed - override behavior #6875

Merged
merged 5 commits into from
May 28, 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
118 changes: 111 additions & 7 deletions ProcessMaker/Models/ProcessRequestToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -135,6 +136,7 @@ class ProcessRequestToken extends ProcessMakerModel implements TokenInterface
*/
protected $appends = [
'advanceStatus',
'elementDestination'
];

/**
Expand Down Expand Up @@ -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)
devmiguelangel marked this conversation as resolved.
Show resolved Hide resolved
{
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.
Show resolved Hide resolved
{
$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.
*
Expand Down Expand Up @@ -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.
Show resolved Hide resolved
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.
Show resolved Hide resolved
$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);
}
}
4 changes: 4 additions & 0 deletions resources/js/processes-catalogue/components/ProcessTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<script>
import RequestTab from "./RequestTab.vue";
import TaskTab from "./TaskTab.vue";

export default {
components: {
RequestTab,
Expand All @@ -42,6 +43,9 @@ export default {
type: Object,
},
},
mounted() {
sessionStorage.setItem("elementDestinationURL", window.location.href);
},
};
</script>
<style>
Expand Down
6 changes: 6 additions & 0 deletions resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
"Destination Screen": "Zielbildschirm",
"Destination": "Ziel",
"Details": "Informationen",
"Determine the URL where the request will end": "Bestimmen Sie die URL, unter der die Anfrage endet",
"Direction": "Pfad",
"Disabled": "Deaktiviert",
"Dismiss Alert": "Warnung verwerfen",
Expand Down Expand Up @@ -305,6 +306,7 @@
"Element is missing label/name": "Dem Element fehlt eine Bezeichnung oder ein Name",
"Element is not connected": "Das Element ist nicht verbunden",
"Element": "Element",
"Element Destination": "„Elementziel",
"Email Address": "E-Mail-Adresse",
"Email": "E-Mail",
"Enable": "Aktivieren",
Expand Down Expand Up @@ -708,6 +710,7 @@
"Select allowed groups": "Zulässige Gruppen auswählen",
"Select allowed user": "Zulässigen Benutzer auswählen",
"Select allowed users": "Zulässige Benutzer auswählen",
"Select element destination": "Wählen Sie das Elementziel aus",
"Select Direction": "Pfad auswählen",
"Select Display-type Screen to show the summary of this Request when it completes": "Wählen Sie den Anzeigetyp Ansicht aus, um nach Abschluss dieser Anfrage eine Zusammenfassung derselben anzuzeigen",
"select file": "Datei wählen",
Expand All @@ -716,6 +719,7 @@
"Select group or type here to search groups": "Wählen Sie die Gruppe aus oder geben Sie hier einen Begriff ein, um nach Benutzern zu suchen",
"Select Screen to display this Task": "Wählen Sie Ansicht aus, um diese Aufgabe anzuzeigen",
"Select the Script this element runs": "Wählen Sie das Skript aus, das dieses Element ausführt",
"Select the dashboard to show the summary of this request when it completes": "Wählen Sie das Dashboard aus, um die Zusammenfassung dieser Anfrage anzuzeigen, wenn sie abgeschlossen ist",
"Select the date to trigger this element": "Wählen Sie das Datum aus, an dem dieses Element ausgelöst werden soll",
"Select the day(s) of the week in which to trigger this element": "Wählen Sie den Wochentag oder die Wochentage aus, an dem/denen dieses Element ausgelöst werden soll",
"Select the direction of workflow for this element": "Wählen Sie den Pfad des Arbeitsablaufes für dieses Element aus",
Expand Down Expand Up @@ -1670,6 +1674,7 @@
"Document Type": "Dokumenttyp",
"Intelligent Document Processing": "Intelligente Dokumentenverarbeitung",
"Variable containing the file to be sent": "Variable, die die zu sendende Datei enthält",
"Enter the destination...": "Geben Sie das Ziel ein...",
"Enter the document type": "Geben Sie den Dokumenttyp ein",
"Authorize Account": "Konto autorisieren",
"Search result": "Suchergebnis",
Expand Down Expand Up @@ -1966,6 +1971,7 @@
"AI Assistant": "KI-Assistent",
"Input Fields": "Eingabefelder",
"Content Fields": "Inhaltsfelder",
"Dashboard" : "Armaturenbrett",
"Dashboards": "Dashboards",
"Search faster.": "Schneller suchen.",
"Search Here": "Hier suchen",
Expand Down
6 changes: 6 additions & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@
"Destination Screen": "Destination Screen",
"Destination": "Destination",
"Details": "Details",
"Determine the URL where the request will end": "Determine the URL where the request will end",
"Direction": "Direction",
"Directs Task assignee to the next assigned Task": "Directs Task assignee to the next assigned Task",
"Disabled": "Disabled",
Expand Down Expand Up @@ -602,6 +603,7 @@
"Element is missing label/name": "Element is missing label/name",
"Element is not connected": "Element is not connected",
"Element": "Element",
"Element Destination": "Element Destination",
"Email Address": "Email Address",
"Email": "Email",
"Embed Media": "Embed Media",
Expand Down Expand Up @@ -630,6 +632,7 @@
"Enter the address of your ProcessMaker IDP server": "Enter the address of your ProcessMaker IDP server",
"Enter the alt text that should accompany the logos and icon.": "Enter the alt text that should accompany the logos and icon.",
"Enter the document type": "Enter the document type",
"Enter the destination...": "Enter the destination...",
"Enter the error name that is unique from all other elements in the diagram": "Enter the error name that is unique from all other elements in the diagram",
"Enter the expression that describes the workflow condition": "Enter the expression that describes the workflow condition",
"Enter the expression to evaluate Task assignment": "Enter the expression to evaluate Task assignment",
Expand Down Expand Up @@ -1233,6 +1236,7 @@
"AI Assistant": "AI Assistant",
"Input Fields": "Input Fields",
"Content Fields": "Content Fields",
"Dashboard" : "Dashboard",
"Dashboards": "Dashboards",
"Search faster.": "Search faster.",
"Search Here": "Search Here",
Expand Down Expand Up @@ -1499,6 +1503,7 @@
"Select Chart": "Select Chart",
"Select Chart Type": "Select Chart Type",
"Select default process status": "Select default process status",
"Select element destination": "Select element destination",
"Select Destination": "Select Destination",
"Select Direction": "Select Direction",
"Select Display-type Screen to show the summary of this Request when it completes": "Select Display-type Screen to show the summary of this Request when it completes",
Expand All @@ -1513,6 +1518,7 @@
"Select Project": "Select Project",
"Select Screen": "Select Screen",
"Select Screen to display this Task": "Select Screen to display this Task",
"Select the dashboard to show the summary of this request when it completes": "Select the dashboard to show the summary of this request when it completes",
"Select the date to initially trigger this element": "Select the date to initially trigger this element",
"Select the date to trigger this element": "Select the date to trigger this element",
"Select the day(s) of the week in which to trigger this Unable to send email. Please check your email server settings.element": "Select the day(s) of the week in which to trigger this element",
Expand Down
6 changes: 6 additions & 0 deletions resources/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
"Destination Screen": "Pantalla de destino",
"Destination": "Destino",
"Details": "Detalles",
"Determine the URL where the request will end": "Determinar la URL donde terminará la solicitud",
"Direction": "Dirección",
"Disabled": "Deshabilitado",
"Dismiss Alert": "Descartar alarma",
Expand Down Expand Up @@ -306,6 +307,7 @@
"Element is missing label/name": "Al elemento le falta etiqueta/nombre",
"Element is not connected": "El elemento no está conectado",
"Element": "Elemento",
"Element Destination": "Destino del elemento",
"Email Address": "Dirección de correo electrónico",
"Email": "Correo electrónico",
"Enable": "Habilitar",
Expand Down Expand Up @@ -710,6 +712,7 @@
"Select allowed groups": "Seleccionar grupos permitidos",
"Select allowed user": "Seleccionar el Usuario autorizado",
"Select allowed users": "Seleccionar usuarios permitidos",
"Select element destination": "Seleccionar destino del elemento",
"Select Direction": "Seleccionar dirección",
"Select Display-type Screen to show the summary of this Request when it completes": "Seleccionar la Pantalla de tipo de visualización para mostrar el resumen de esta solicitud cuando se complete",
"select file": "seleccionar archivo",
Expand All @@ -718,6 +721,7 @@
"Select group or type here to search groups": "Seleccionar un grupo o escribir aquí para buscar grupos",
"Select Screen to display this Task": "Seleccionar pantalla para mostrar esta tarea",
"Select the Script this element runs": "Seleccionar el script que ejecuta este elemento",
"Select the dashboard to show the summary of this request when it completes": "Seleccione el panel para mostrar el resumen de esta solicitud cuando se complete",
"Select the date to trigger this element": "Seleccionar la fecha para desencadenar este elemento",
"Select the day(s) of the week in which to trigger this element": "Seleccionar los días de la semana para desencadenar este elemento",
"Select the direction of workflow for this element": "Seleccionar la dirección del flujo de trabajo para este elemento",
Expand Down Expand Up @@ -1672,6 +1676,7 @@
"Intelligent Document Processing": "Procesamiento Inteligente de Documentos",
"Variable containing the file to be sent": "Variable que contiene el archivo a enviar",
"Enter the document type": "Ingrese el tipo de documento",
"Enter the destination...": "Introduce el destino...",
"Authorize Account": "Autorizar Cuenta",
"Search result": "Resultado de búsqueda",
"Nothing searched yet": "Nada buscado aún",
Expand Down Expand Up @@ -1968,6 +1973,7 @@
"AI Assistant": "Asistente de IA",
"Input Fields": "Campos de Entrada",
"Content Fields": "Campos de Contenido",
"Dashboard" : "Panel",
"Dashboards": "Tableros de control",
"Search faster.": "Busca más rápido.",
"Search Here": "Buscar Aquí",
Expand Down
6 changes: 6 additions & 0 deletions resources/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
"Destination Screen": "Écran de destination",
"Destination": "Destination",
"Details": "Détails",
"Determine the URL where the request will end": "Déterminer l'URL où se terminera la demande",
"Direction": "Chemin",
"Disabled": "Désactivé",
"Dismiss Alert": "Rejeter l'alerte",
Expand Down Expand Up @@ -305,6 +306,7 @@
"Element is missing label/name": "Étiquette/nom manquant(e) pour l'élément",
"Element is not connected": "L'élément n'est pas connecté",
"Element": "Élément",
"Element Destination": "Destination de l'élément",
"Email Address": "Adresse e-mail",
"Email": "E-mail",
"Enable": "Activer",
Expand Down Expand Up @@ -708,6 +710,7 @@
"Select allowed groups": "Sélectionnez les groupes autorisés",
"Select allowed user": "Sélectionner l'utilisateur autorisé",
"Select allowed users": "Sélectionnez les utilisateurs autorisés",
"Select element destination": "Sélectionner la destination de l'élément",
"Select Direction": "Sélectionnez un chemin",
"Select Display-type Screen to show the summary of this Request when it completes": "Sélectionner « Type d'affichage » pour afficher le résumé de cette demande une fois qu'elle sera terminée",
"select file": "Sélectionner le fichier",
Expand All @@ -717,6 +720,7 @@
"Select Screen to display this Task": "Sélectionner « Écran » pour afficher cette tâche",
"Select the Script this element runs": "Sélectionner le script exécuté par cet élément",
"Select the date to trigger this element": "Sélectionner la date de déclenchement de cet élément",
"Select the dashboard to show the summary of this request when it completes": "Sélectionnez le tableau de bord pour afficher le résumé de cette demande une fois celle-ci terminée",
"Select the day(s) of the week in which to trigger this element": "Sélectionner le ou les jours de la semaine au cours desquels cet élément doit être déclenché",
"Select the direction of workflow for this element": "Sélectionner le chemin du workflow de cet élément",
"Select the duration of the timer": "Sélectionner la durée du temporisateur",
Expand Down Expand Up @@ -1670,6 +1674,7 @@
"Document Type": "Type de document",
"Intelligent Document Processing": "Traitement Intelligent de Documents",
"Variable containing the file to be sent": "Variable contenant le fichier à envoyer",
"Enter the destination...": "Entrez la destination...",
"Enter the document type": "Saisissez le type de document",
"Authorize Account": "Autoriser le compte",
"Search result": "Résultat de recherche",
Expand Down Expand Up @@ -1966,6 +1971,7 @@
"AI Assistant": "Assistant IA",
"Input Fields": "Champs de saisie",
"Content Fields": "Champs de Contenu",
"Dashboard" : "Tableau de bord",
"Dashboards": "Tableaux de bord",
"Search faster.": "Recherchez plus rapidement.",
"Search Here": "Recherchez Ici",
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 @@ -535,11 +535,17 @@ class="multiselect__tag-icon"></i>
redirectToTask(task, force = false) {
this.redirect(`/tasks/${task}/edit`, force);
},
closed(taskId) {
closed(taskId, elementDestination = null) {
// avoid redirection if using a customized renderer
if (this.task.component && this.task.component === 'AdvancedScreenFrame') {
return;
}

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

this.redirect("/tasks");
},
claimTask() {
Expand Down Expand Up @@ -677,7 +683,7 @@ class="multiselect__tag-icon"></i>
screenFields.forEach((field) => {
_.set(draftData, field, _.get(this.formData, field));
});

return ProcessMaker.apiClient
.put("drafts/" + this.task.id, draftData)
.then((response) => {
Expand Down
Loading
Loading