This commit is contained in:
Adrian Hopek 2022-03-16 13:56:16 +01:00
parent 286b4175b7
commit 02677af2de
2 changed files with 39 additions and 0 deletions

View File

@ -43,8 +43,32 @@ class VacationRequestController extends Controller
->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user())) ->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user()))
->paginate(); ->paginate();
$pending = $request->user()
->vacationRequests()
->where("year_period_id", $yearPeriodRetriever->selected()->id)
->states(VacationRequestStatesRetriever::pendingStates())
->count();
$success = $request->user()
->vacationRequests()
->where("year_period_id", $yearPeriodRetriever->selected()->id)
->states(VacationRequestStatesRetriever::successStates())
->count();
$failed = $request->user()
->vacationRequests()
->where("year_period_id", $yearPeriodRetriever->selected()->id)
->states(VacationRequestStatesRetriever::failedStates())
->count();
return inertia("VacationRequest/Index", [ return inertia("VacationRequest/Index", [
"requests" => VacationRequestResource::collection($vacationRequests), "requests" => VacationRequestResource::collection($vacationRequests),
"stats" => [
"all" => $pending + $success + $failed,
"pending" => $pending,
"success" => $success,
"failed" => $failed,
],
"filters" => [ "filters" => [
"status" => $status, "status" => $status,
], ],

View File

@ -25,6 +25,12 @@
:class="[status.value === filters.status ? 'text-blumilk-600 font-semibold' : 'hover:bg-blumilk-25 text-gray-700 focus:z-10', 'group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-sm font-medium text-center']" :class="[status.value === filters.status ? 'text-blumilk-600 font-semibold' : 'hover:bg-blumilk-25 text-gray-700 focus:z-10', 'group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-sm font-medium text-center']"
> >
<span>{{ status.name }}</span> <span>{{ status.name }}</span>
<span
v-if="stats[status.value]"
:class="[status.value === filters.status ? 'bg-blumilk-50 text-blumilk-600' : 'bg-gray-100 text-gray-600', 'hidden ml-3 py-0.5 px-2.5 rounded-full text-xs font-semibold md:inline-block']"
>
{{ stats[status.value] }}
</span>
<span :class="[status.value === filters.status ? 'bg-blumilk-500' : 'bg-transparent', 'absolute inset-x-0 bottom-0 h-0.5']" /> <span :class="[status.value === filters.status ? 'bg-blumilk-500' : 'bg-transparent', 'absolute inset-x-0 bottom-0 h-0.5']" />
</InertiaLink> </InertiaLink>
</nav> </nav>
@ -210,6 +216,15 @@ export default {
type: Object, type: Object,
default: () => null, default: () => null,
}, },
stats: {
type: Object,
default: () => ({
all: 0,
pending: 0,
success: 0,
failed: 0,
}),
},
filters: { filters: {
type: Object, type: Object,
default: () => null, default: () => null,