Skip to content

FOUR-24420 Add support to back tasks in the process #8264

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

Open
wants to merge 1 commit into
base: pm-apps-2
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions ProcessMaker/Http/Controllers/Api/V1_1/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use ProcessMaker\Http\Resources\V1_1\TaskScreen;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ProcessRequestToken;
use ProcessMaker\Nayra\Contracts\Bpmn\ActivityInterface;
use ProcessMaker\ProcessTranslations\TranslationManager;

class TaskController extends Controller
Expand Down Expand Up @@ -151,4 +152,27 @@ public function showInterstitial($taskId)

return $response;
}

/**
* Move a token to a different task
* @param Request $request
* @param int $taskId
*
* @return \Illuminate\Http\JsonResponse
*/
public function moveToken(Request $request, $taskId)
{
$task = ProcessRequestToken::findOrFail($taskId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input validation was missed

    $request->validate([
        'target_task_id' => 'required|string|max:255'
    ]);

// find element id from process request
$targetTaskId = $request->input('target_task_id');
$defs = $task->processRequest->getVersionDefinitions();
$targetTask = $defs->getElementInstanceById($targetTaskId);
if (!($targetTask && $targetTask instanceof ActivityInterface)) {
return response()->json(['message' => 'Task not found'], 404);
}

$task->update(['element_id' => $targetTask->getId(), 'element_name' => $targetTask->getName()]);

return response()->json(['message' => 'Token moved successfully']);
}
}
4 changes: 4 additions & 0 deletions routes/v1_1/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
// Route to show the interstitial screen of a task
Route::get('/{taskId}/interstitial', [TaskController::class, 'showInterstitial'])
->name('show.interstitial');

// Route to move a token to a different task
Route::post('/{taskId}/move', [TaskController::class, 'moveToken'])
->name('move.token');
});

// Cases Endpoints
Expand Down