Skip to content

Commit a4617ed

Browse files
author
dante
committed
Endpoint that lists start processes for an user
1 parent 8aabd18 commit a4617ed

3 files changed

Lines changed: 63 additions & 2 deletions

File tree

‎ProcessMaker/Http/Controllers/Api/ProcessController.php‎

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class ProcessController extends Controller
2222
{
23-
public $skipPermissionCheckFor = ['triggerStartEvent'];
23+
public $skipPermissionCheckFor = ['triggerStartEvent', 'startProcesses'];
2424

2525
/**
2626
* Get list Process
@@ -246,6 +246,65 @@ public function update(Request $request, Process $process)
246246
return new Resource($process->refresh());
247247
}
248248

249+
/**
250+
* Returns the list of processes that the user can start.
251+
*
252+
* @param Request $request
253+
*
254+
* @return ApiCollection
255+
*
256+
* * @OA\Get(
257+
* path="/start_processes",
258+
* summary="Returns the list of processes that the user can start",
259+
* operationId="startProcesses",
260+
* tags={"Process"},
261+
* @OA\Parameter(ref="#/components/parameters/order_by"),
262+
* @OA\Parameter(ref="#/components/parameters/order_direction"),
263+
* @OA\Parameter(ref="#/components/parameters/per_page"),
264+
* @OA\Parameter(ref="#/components/parameters/include"),
265+
*
266+
* @OA\Response(
267+
* response=200,
268+
* description="list of processes that the user can start",
269+
* @OA\JsonContent(
270+
* type="object",
271+
* @OA\Property(
272+
* property="data",
273+
* type="array",
274+
* @OA\Items(ref="#/components/schemas/Process"),
275+
* ),
276+
* @OA\Property(
277+
* property="meta",
278+
* type="object",
279+
* allOf={@OA\Schema(ref="#/components/schemas/metadata")},
280+
* ),
281+
* ),
282+
* ),
283+
* )
284+
*/
285+
public function startProcesses(Request $request)
286+
{
287+
$orderBy = $this->getRequestSortBy($request, 'name');
288+
$perPage = $this->getPerPage($request);
289+
$include = $this->getRequestInclude($request);
290+
291+
$processes = Process::with($include)
292+
->select('processes.*')
293+
->leftJoin('process_categories as category', 'processes.process_category_id', '=', 'category.id')
294+
->leftJoin('users as user', 'processes.user_id', '=', 'user.id')
295+
->where('processes.status', 'ACTIVE')
296+
->where('category.status', 'ACTIVE');
297+
298+
//Verify what processes the current user can initiate, user Administrator can start everything.
299+
if (!Auth::user()->is_administrator) {
300+
$processId = Auth::user()->startProcesses();
301+
$processes->whereIn('processes.id', $processId);
302+
}
303+
$processes->orderBy(...$orderBy);
304+
305+
return new ApiCollection($processes->paginate($perPage));
306+
}
307+
249308
private function savePermission($process, $assignableType, $assignableId, $permissionId)
250309
{
251310
$processPerm = new ProcessPermission();

‎ProcessMaker/Http/Controllers/NotificationController.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
class NotificationController extends Controller
1010
{
11+
public $skipPermissionCheckFor = ['index', 'show'];
12+
1113
private static $dueLabels = [
1214
'open' => 'Due ',
1315
'completed' => 'Completed ',

‎resources/js/components/requests/modal.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default {
6868
// Maximum number of requests returned is 200 but should be enough
6969
// @todo Determine if we need to paginate or lazy scroll if someone has more than 200 requests
7070
window.ProcessMaker.apiClient
71-
.get("processes?include=events,category")
71+
.get("start_processes?include=events,category")
7272
.then(response => {
7373
let data = response.data;
7474
// Empty processes

0 commit comments

Comments
 (0)