Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add recent cases and active case count
  • Loading branch information
nolanpro committed May 28, 2024
commit aeb79b6440e95a924d6874a2759af0b416559a44
12 changes: 7 additions & 5 deletions ProcessMaker/Http/Controllers/Api/ProcessLaunchpadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function getProcesses(Request $request)
$processes = Process::nonSystem()->active();
// Filter by category
$category = $request->input('category', null);
if (!empty($category)) {
if ($category === 'recent') {
$processes->orderByRecentRequests();
} elseif (!empty($category)) {
$processes->processCategory($category);
}
// Filter pmql
Expand All @@ -44,6 +46,7 @@ public function getProcesses(Request $request)
// Get the processes
$processes = $processes
->select('processes.*')
->withRequestCount()
->orderBy('processes.name', 'asc')
->paginate($perPage);

Expand Down Expand Up @@ -120,9 +123,9 @@ public function destroy(ProcessLaunchpad $launch)
return response([], 204);
}

/**
* Store the elements related to the carousel [IMAGE, EMBED URL]
*/
/**
* Store the elements related to the carousel [IMAGE, EMBED URL]
*/
public function saveContentCarousel(Request $request, Process $process)
{
$contentCarousel = $request->input('imagesCarousel');
Expand All @@ -144,7 +147,6 @@ public function saveContentCarousel(Request $request, Process $process)
// Nothing
break;
}

}
}
}
Expand Down
39 changes: 32 additions & 7 deletions ProcessMaker/Models/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ public function manageCustomRoutes()
'params' => $webentryRouteConfig->parameters,
]
);
} catch (\Exception $e) {
} catch (Exception $e) {
\Log::info('*** Error: ' . $e->getMessage());
}
}
Expand Down Expand Up @@ -1250,7 +1250,7 @@ private function getStartEventPermissions(User $user)
/**
* Process events relationship.
*
* @return \ProcessMaker\Models\ProcessEvents
* @return ProcessEvents
*/
public function events()
{
Expand Down Expand Up @@ -1287,7 +1287,7 @@ public function launchpad()
/**
* Assignments of the process.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function assignments()
{
Expand Down Expand Up @@ -1616,7 +1616,7 @@ private function validateSchema(BpmnDocument $document)
private function deleteUnusedCustomRoutes($url, $processId, $nodeId)
{
// Delete unused custom routes
$customRoute = webentryRoute::where('process_id', $processId)->where('node_id', $nodeId)->first();
$customRoute = WebentryRoute::where('process_id', $processId)->where('node_id', $nodeId)->first();
if ($customRoute) {
$customRoute->delete();
}
Expand Down Expand Up @@ -1751,9 +1751,9 @@ public function scopeFilter($query, $filterStr)
->orWhere('processes.description', 'like', $filter)
->orWhere('processes.status', '=', $filterStr)
->orWhereHas('user', function ($query) use ($filter) {
$query->where('firstname', 'like', $filter)
->orWhere('lastname', 'like', $filter);
})
$query->where('firstname', 'like', $filter)
->orWhere('lastname', 'like', $filter);
})
->orWhereIn('processes.id', function ($qry) use ($filter) {
$qry->select('assignable_id')
->from('category_assignments')
Expand Down Expand Up @@ -1797,4 +1797,29 @@ public function hasAlternative()
{
return true;
}

public function scopeOrderByRecentRequests($query)
{
return $query->orderByDesc(
ProcessRequest::select('id')
// User has participated
->whereHas('tokens', function ($q) {
$q->where('user_id', Auth::user()->id);
})
->whereColumn('process_id', 'processes.id')
->orderByDesc('id') // using ID because created_at is not indexed
->limit(1)
);
}

public function scopeWithRequestCount($query)
{
return $query->withCount(['requests' => function ($query) {
return $query->where('status', 'ACTIVE')
// User has participated
->whereHas('tokens', function ($q) {
$q->where('user_id', Auth::user()->id);
});
}]);
}
}
43 changes: 36 additions & 7 deletions resources/js/processes-catalogue/components/ProcessesCatalogue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
</div>
</div>
</div>
<div class="slide-control">
<a href="#" @click="showMenu = !showMenu">M</a>
<div class="slide-control" :class="{ 'slide-control-open' : showMenu }">
<a href="#" @click="showMenu = !showMenu">
<i class="fa" :class="{ 'fa-caret-right' : !showMenu, 'fa-caret-left' : showMenu }"></i>
</a>
</div>
<div class="processes-info">
<div
Expand Down Expand Up @@ -108,15 +110,17 @@ export default {
isMobile: window.screen.width < 650,
listCategories: [],
defaultOptions: [
{
id: 'recent',
name: this.$t("Recent Cases"),
},
{
id: -1,
name: this.$t("All Processes"),
status: "ACTIVE",
},
{
id: 0,
name: this.$t("My Bookmarks"),
status: "ACTIVE",
},
],
fields: [],
Expand Down Expand Up @@ -369,7 +373,6 @@ export default {
display: flex;
.container-2 {
background-color: #F7F9FB;
border-right: 2px solid rgba(0, 0, 0, 0.1);
flex: 0 0 315px;
}

Expand All @@ -386,12 +389,38 @@ export default {
}
.slide-control {
flex: 0 0 10px;
border-right: 1px solid rgba(0, 0, 0, 0.1);
background-color: pink;
border-left: 0;
border-right: 1px solid #DEE0E1;

@media (max-width: $lp-breakpoint) {
display: none;
}

a {
position: relative;
left: 6px;
top: 40px;
z-index: 5;

display: flex;
align-items: center;
justify-content: center;
width: 12px;
height: 40px;
background-color: #ffffff;
border-radius: 6px;
border: 1px solid #DEE0E1;
}
}

.slide-control-open {
border-right: 0;
border-left: 1px solid #DEE0E1;

a {
left: -6px;
}

}

.mobile-menu-control {
Expand Down
23 changes: 22 additions & 1 deletion resources/js/processes-catalogue/components/utils/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
variant="custom"
/>
</div>
<div class="requests-count" v-if="process.requests_count">
{{ process.requests_count }}
</div>
<div class="card-bookmark">
<i
:ref="`bookmark-${process.id}`"
Expand Down Expand Up @@ -120,7 +123,7 @@ export default {
max-width: none;
min-width: none;
border-radius: 8px;
height: 150px;
height: 100px;
}
}
.card-process:hover {
Expand All @@ -138,6 +141,24 @@ export default {
.card-img {
border-radius: 16px;
}
.requests-count {
display: none;
float: right;
font-size: 14px;
font-weight: bold;
background-color: #F9E7C3;
margin-right: 8px;

border-radius: 50%;
width: 30px;
height: 30px;
justify-content: center;
align-items: center;

@media (max-width: $lp-breakpoint) {
display: flex;
}
}
.card-bookmark {
float: right;
font-size: 24px;
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2259,5 +2259,6 @@
"Your In-Progress tasks in the saved search {{title}}": "Your In-Progress tasks in the saved search {{title}}",
"Choose a saved search to see the tasks that you can use with an Inbox Rule.": "Choose a saved search to see the tasks that you can use with an Inbox Rule.",
"No tasks to show.": "No tasks to show.",
"But that's OK. You can still create this this Inbox Rule to apply to future tasks that match the above filters.": "But that's OK. You can still create this this Inbox Rule to apply to future tasks that match the above filters."
"But that's OK. You can still create this this Inbox Rule to apply to future tasks that match the above filters.": "But that's OK. You can still create this this Inbox Rule to apply to future tasks that match the above filters.",
"Recent Cases": "Recent Cases"
}