diff --git a/ProcessMaker/Http/Controllers/Api/TaskController.php b/ProcessMaker/Http/Controllers/Api/TaskController.php index f4164877e9..94e578e595 100644 --- a/ProcessMaker/Http/Controllers/Api/TaskController.php +++ b/ProcessMaker/Http/Controllers/Api/TaskController.php @@ -140,6 +140,10 @@ public function index(Request $request, $getTotal = false, User $user = null) // Apply filter overdue $query->overdue($request->input('overdue')); + if ($request->input('processesIManage') === 'true') { + $this->applyProcessManager($query, $user); + } + // If only the total is being requested (by a Saved Search), send it now if ($getTotal === true) { return $query->count(); diff --git a/ProcessMaker/Traits/TaskControllerIndexMethods.php b/ProcessMaker/Traits/TaskControllerIndexMethods.php index 4dc1004d42..8fa0d17d24 100644 --- a/ProcessMaker/Traits/TaskControllerIndexMethods.php +++ b/ProcessMaker/Traits/TaskControllerIndexMethods.php @@ -8,6 +8,7 @@ use Illuminate\Support\Str; use ProcessMaker\Filters\Filter; use ProcessMaker\Managers\DataManager; +use ProcessMaker\Models\Process; use ProcessMaker\Models\ProcessRequest; use ProcessMaker\Models\ProcessRequestToken; use ProcessMaker\Models\User; @@ -319,4 +320,18 @@ private function applyForCurrentUser($query, $user) ->orWhereIn('id', $user->availableSelfServiceTaskIds()); }); } + + public function applyProcessManager($query, $user) + { + $ids = Process::select(['id']) + ->where('properties->manager_id', $user->id) + ->where('status', 'ACTIVE') + ->get() + ->toArray(); + + $query->orWhere(function ($query) use ($ids) { + $query->whereIn('process_request_tokens.process_id', array_column($ids, 'id')) + ->where('process_request_tokens.status', 'ACTIVE'); + }); + } } diff --git a/resources/js/tasks/components/ListMixin.js b/resources/js/tasks/components/ListMixin.js index f8de85307e..a0a2827bf9 100644 --- a/resources/js/tasks/components/ListMixin.js +++ b/resources/js/tasks/components/ListMixin.js @@ -107,6 +107,7 @@ const ListMixin = { }${filterParams }${this.getSortParam() }&non_system=true` + + `&processesIManage=${(this.processesIManage ? 'true' : 'false')}` + advancedFilter + this.columnsQuery, { diff --git a/resources/js/tasks/components/TasksList.vue b/resources/js/tasks/components/TasksList.vue index b40f963c3e..468fba3cc6 100644 --- a/resources/js/tasks/components/TasksList.vue +++ b/resources/js/tasks/components/TasksList.vue @@ -339,7 +339,7 @@ export default { type: String, default: "tasks", }, - verifyUrlToFalse: { + processesIManage: { type: Boolean, default: false } @@ -866,7 +866,7 @@ export default { verifyURL(string) { const currentUrl = window.location.href; let isInUrl = currentUrl.includes(string); - if (this.verifyUrlToFalse) { + if (this.processesIManage) { isInUrl = false; } return isInUrl;