Compare commits
28 Commits
style-upda
...
9bd3cca970
Author | SHA1 | Date | |
---|---|---|---|
9bd3cca970
|
|||
48bd4ab644
|
|||
043217e9d4
|
|||
31f771b8e4
|
|||
9e47c7cb28
|
|||
e6f4d0e78c
|
|||
8dc487a133
|
|||
5f0d6b5af3
|
|||
f755e1e0db
|
|||
bf03289797
|
|||
1d7b4da903
|
|||
13aa2c7a86
|
|||
94f433de6e
|
|||
a9c476cb8e
|
|||
5c3833d4cb
|
|||
6e627d11c8
|
|||
eb644fa494
|
|||
4392b666e1
|
|||
e7c1028da1
|
|||
c16eb9aff5 | |||
a7bc4695a7 | |||
4e16f363ac | |||
7893282385 | |||
db874d4395 | |||
dcc3808428 | |||
2a3e65ed5f | |||
643f546142 | |||
995c0b6696 |
@@ -31,6 +31,7 @@ class Resume extends Model
|
|||||||
"technologies" => AsCollection::class,
|
"technologies" => AsCollection::class,
|
||||||
"projects" => AsCollection::class,
|
"projects" => AsCollection::class,
|
||||||
];
|
];
|
||||||
|
protected $perPage = 50;
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
|
@@ -46,6 +46,7 @@ class User extends Authenticatable implements NotifiableInterface
|
|||||||
protected $with = [
|
protected $with = [
|
||||||
"profile",
|
"profile",
|
||||||
];
|
];
|
||||||
|
protected $perPage = 50;
|
||||||
|
|
||||||
public function profile(): HasOne
|
public function profile(): HasOne
|
||||||
{
|
{
|
||||||
|
@@ -49,6 +49,7 @@ class VacationRequest extends Model
|
|||||||
"to" => "date",
|
"to" => "date",
|
||||||
"event_ids" => AsCollection::class,
|
"event_ids" => AsCollection::class,
|
||||||
];
|
];
|
||||||
|
protected $perPage = 50;
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
|
@@ -12,8 +12,11 @@ use Toby\Domain\UserVacationStatsRetriever;
|
|||||||
use Toby\Domain\VacationRequestStatesRetriever;
|
use Toby\Domain\VacationRequestStatesRetriever;
|
||||||
use Toby\Domain\VacationTypeConfigRetriever;
|
use Toby\Domain\VacationTypeConfigRetriever;
|
||||||
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||||
|
use Toby\Eloquent\Models\Holiday;
|
||||||
|
use Toby\Eloquent\Models\Vacation;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
use Toby\Infrastructure\Http\Resources\HolidayResource;
|
use Toby\Infrastructure\Http\Resources\HolidayResource;
|
||||||
|
use Toby\Infrastructure\Http\Resources\SimpleVacationRequestResource;
|
||||||
use Toby\Infrastructure\Http\Resources\VacationRequestResource;
|
use Toby\Infrastructure\Http\Resources\VacationRequestResource;
|
||||||
use Toby\Infrastructure\Http\Resources\VacationResource;
|
use Toby\Infrastructure\Http\Resources\VacationResource;
|
||||||
|
|
||||||
@@ -54,6 +57,22 @@ class DashboardController extends Controller
|
|||||||
->limit(3)
|
->limit(3)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
$allHolidays = $yearPeriod->holidays;
|
||||||
|
|
||||||
|
$approvedVacations = $request->user()
|
||||||
|
->vacations()
|
||||||
|
->with("vacationRequest.vacations")
|
||||||
|
->whereBelongsTo($yearPeriod)
|
||||||
|
->approved()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$pendingVacations = $request->user()
|
||||||
|
->vacations()
|
||||||
|
->with("vacationRequest.vacations")
|
||||||
|
->whereBelongsTo($yearPeriod)
|
||||||
|
->pending()
|
||||||
|
->get();
|
||||||
|
|
||||||
$limit = $vacationStatsRetriever->getVacationDaysLimit($user, $yearPeriod);
|
$limit = $vacationStatsRetriever->getVacationDaysLimit($user, $yearPeriod);
|
||||||
$used = $vacationStatsRetriever->getUsedVacationDays($user, $yearPeriod);
|
$used = $vacationStatsRetriever->getUsedVacationDays($user, $yearPeriod);
|
||||||
$pending = $vacationStatsRetriever->getPendingVacationDays($user, $yearPeriod);
|
$pending = $vacationStatsRetriever->getPendingVacationDays($user, $yearPeriod);
|
||||||
@@ -66,6 +85,19 @@ class DashboardController extends Controller
|
|||||||
"remoteDays" => VacationResource::collection($remoteDays),
|
"remoteDays" => VacationResource::collection($remoteDays),
|
||||||
"vacationRequests" => VacationRequestResource::collection($vacationRequests),
|
"vacationRequests" => VacationRequestResource::collection($vacationRequests),
|
||||||
"holidays" => HolidayResource::collection($holidays),
|
"holidays" => HolidayResource::collection($holidays),
|
||||||
|
"allHolidays" => $allHolidays->mapWithKeys(
|
||||||
|
fn(Holiday $holiday): array => [$holiday->date->toDateString() => $holiday->name],
|
||||||
|
),
|
||||||
|
"approvedVacations" => $approvedVacations->mapWithKeys(
|
||||||
|
fn(Vacation $vacation): array => [
|
||||||
|
$vacation->date->toDateString() => new SimpleVacationRequestResource($vacation->vacationRequest),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
"pendingVacations" => $pendingVacations->mapWithKeys(
|
||||||
|
fn(Vacation $vacation): array => [
|
||||||
|
$vacation->date->toDateString() => new SimpleVacationRequestResource($vacation->vacationRequest),
|
||||||
|
],
|
||||||
|
),
|
||||||
"stats" => [
|
"stats" => [
|
||||||
"limit" => $limit,
|
"limit" => $limit,
|
||||||
"remaining" => $remaining,
|
"remaining" => $remaining,
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
<div class="grid grid-cols-1 gap-4 items-start xl:grid-cols-3 xl:gap-8">
|
<div class="grid grid-cols-1 gap-4 items-start xl:grid-cols-3 xl:gap-8">
|
||||||
<div class="grid grid-cols-1 gap-4 xl:col-span-2">
|
<div class="grid grid-cols-1 gap-4 xl:col-span-2">
|
||||||
<Welcome :user="auth.user" />
|
<Welcome :user="auth.user" />
|
||||||
<VacationCalendar />
|
<VacationCalendar
|
||||||
<VacationStats :stats="stats" />
|
:holidays="allHolidays"
|
||||||
</div>
|
:approved-vacations="approvedVacations"
|
||||||
<div class="grid grid-cols-1 gap-4">
|
:pending-vacations="pendingVacations"
|
||||||
<VacationCalendar />
|
/>
|
||||||
<PendingVacationRequests
|
<PendingVacationRequests
|
||||||
v-if="can.listAllVacationRequests"
|
v-if="can.listAllVacationRequests"
|
||||||
:requests="vacationRequests.data"
|
:requests="vacationRequests.data"
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
v-else
|
v-else
|
||||||
:requests="vacationRequests.data"
|
:requests="vacationRequests.data"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-1 gap-4">
|
||||||
|
<VacationStats :stats="stats" />
|
||||||
<AbsenceList
|
<AbsenceList
|
||||||
v-if="years.current.year === years.selected.year && absences.data.length"
|
v-if="years.current.year === years.selected.year && absences.data.length"
|
||||||
:absences="absences.data"
|
:absences="absences.data"
|
||||||
@@ -51,5 +54,8 @@ defineProps({
|
|||||||
can: Object,
|
can: Object,
|
||||||
stats: Object,
|
stats: Object,
|
||||||
years: Object,
|
years: Object,
|
||||||
|
allHolidays: Object,
|
||||||
|
approvedVacations: Object,
|
||||||
|
pendingVacations: Object,
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="overflow-x-auto xl:overflow-x-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -10,13 +10,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<form @submit.prevent="submitVacationDays">
|
<form @submit.prevent="submitVacationDays">
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full border-b divide-y divide-gray-200">
|
<table class="min-w-full border-b divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th
|
<th
|
||||||
scope="col"
|
scope="col"
|
||||||
class="py-3 px-4 text-xs font-semibold tracking-wider text-left text-gray-500 uppercase whitespace-nowrap"
|
class="py-3 px-4 text-xs font-semibold tracking-wider text-left text-gray-500 uppercase whitespace-nowrap bg-gray-50 sticky -left-1"
|
||||||
>
|
>
|
||||||
Imię i nazwisko
|
Imię i nazwisko
|
||||||
</th>
|
</th>
|
||||||
@@ -52,8 +52,8 @@
|
|||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="hover:bg-blumilk-25"
|
class="hover:bg-blumilk-25"
|
||||||
>
|
>
|
||||||
<td class="p-4 text-sm text-gray-500 whitespace-nowrap">
|
<td class="p-4 text-sm text-gray-500 whitespace-nowrap bg-white sticky -left-1 z-10">
|
||||||
<div class="flex">
|
<div class="flex justify-start items-center">
|
||||||
<span class="inline-flex justify-center items-center w-10 h-10 rounded-full">
|
<span class="inline-flex justify-center items-center w-10 h-10 rounded-full">
|
||||||
<img
|
<img
|
||||||
class="w-10 h-10 rounded-full"
|
class="w-10 h-10 rounded-full"
|
||||||
@@ -61,10 +61,16 @@
|
|||||||
>
|
>
|
||||||
</span>
|
</span>
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<p class="text-sm font-medium text-gray-900 break-all">
|
<p class="flex items-start flex-col-reverse md:flex-row">
|
||||||
{{ item.user.name }}
|
<span
|
||||||
|
v-for="split in item.user.name.split(' ', 2)"
|
||||||
|
:key="split"
|
||||||
|
class="first:text-xs md:first:text-sm font-medium text-gray-900 truncate first:mr-1"
|
||||||
|
>
|
||||||
|
{{ split }}
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-gray-500 break-all">
|
<p class="hidden md:block text-sm text-gray-500 break-all">
|
||||||
{{ item.user.email }}
|
{{ item.user.email }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -297,8 +297,8 @@
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="inline-flex justify-center py-2 px-4 text-sm font-medium text-white bg-blumilk-600 rounded-md border border-transparent focus:outline-none focus:ring-2 focus:ring-blumilk-500 focus:ring-offset-2 shadow-sm"
|
class="inline-flex justify-center py-2 px-4 text-sm font-medium text-white bg-blumilk-600 rounded-md border border-transparent focus:outline-none focus:ring-2 focus:ring-blumilk-500 focus:ring-offset-2 shadow-sm"
|
||||||
:class="[form.processing || !form.isDirty ? 'disabled:opacity-60' : 'hover:bg-blumilk-700']"
|
:class="[form.processing || !isDirty ? 'disabled:opacity-60' : 'hover:bg-blumilk-700']"
|
||||||
:disabled="form.processing || !form.isDirty"
|
:disabled="form.processing || !isDirty"
|
||||||
>
|
>
|
||||||
Zapisz
|
Zapisz
|
||||||
</button>
|
</button>
|
||||||
@@ -359,6 +359,13 @@ const form = useForm({
|
|||||||
flowSkipped: false,
|
flowSkipped: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let isDirty = ref(false)
|
||||||
|
|
||||||
|
watch(form, formData => {
|
||||||
|
const { from, to } = formData.data()
|
||||||
|
isDirty.value = formData.isDirty || from !== null || to !== null
|
||||||
|
}, { immediate: true, deep: true })
|
||||||
|
|
||||||
refreshEstimatedDays(form.from, form.to)
|
refreshEstimatedDays(form.from, form.to)
|
||||||
|
|
||||||
const estimatedDays = ref([])
|
const estimatedDays = ref([])
|
||||||
|
@@ -88,7 +88,7 @@
|
|||||||
</Listbox>
|
</Listbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
leave-to-class="opacity-0"
|
leave-to-class="opacity-0"
|
||||||
>
|
>
|
||||||
<ListboxOptions
|
<ListboxOptions
|
||||||
class="overflow-auto absolute z-10 py-1 mt-1 w-full max-w-lg max-h-60 text-base bg-white rounded-md focus:outline-none ring-1 ring-black ring-opacity-5 shadow-lg sm:text-sm"
|
class="overflow-x-auto absolute z-10 py-1 mt-1 w-full max-w-lg max-h-60 text-base bg-white rounded-md focus:outline-none ring-1 ring-black ring-opacity-5 shadow-lg sm:text-sm"
|
||||||
>
|
>
|
||||||
<ListboxOption
|
<ListboxOption
|
||||||
v-slot="{ active }"
|
v-slot="{ active }"
|
||||||
@@ -237,7 +237,7 @@
|
|||||||
</Listbox>
|
</Listbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-auto xl:overflow-visible">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
|
104
resources/js/Shared/Widgets/Calendar/DayComponent.vue
Normal file
104
resources/js/Shared/Widgets/Calendar/DayComponent.vue
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
:class="[ (day.isVacation || day.isPendingVacation) && `border-b-2 border-dashed ${getVacationBorder(day)}` ]"
|
||||||
|
>
|
||||||
|
<Popper
|
||||||
|
v-if="day.isHoliday"
|
||||||
|
as="div"
|
||||||
|
open-delay="200"
|
||||||
|
hover
|
||||||
|
offset-distance="0"
|
||||||
|
@mouseover.passive="onMouseover"
|
||||||
|
@mouseleave="onMouseleave"
|
||||||
|
>
|
||||||
|
<time
|
||||||
|
:datetime="day.date"
|
||||||
|
:class="[ day.isToday && 'flex h-6 w-6 items-center justify-center rounded-full bg-blumilk-500 font-semibold text-white', 'text-red-600' ]"
|
||||||
|
>
|
||||||
|
{{ day.dayNumber }}
|
||||||
|
</time>
|
||||||
|
<template #content>
|
||||||
|
<div class="py-2 px-6 text-sm font-semibold text-left text-gray-700 bg-white rounded-lg border border-gray-400">
|
||||||
|
{{ getHolidayDescription(day) }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Popper>
|
||||||
|
<Popper
|
||||||
|
v-else-if="day.isPendingVacation"
|
||||||
|
as="div"
|
||||||
|
open-delay="200"
|
||||||
|
hover
|
||||||
|
offset-distance="0"
|
||||||
|
@mouseover.passive="onMouseover"
|
||||||
|
@mouseleave="onMouseleave"
|
||||||
|
>
|
||||||
|
<time
|
||||||
|
:datetime="day.date"
|
||||||
|
:class="[ day.isToday && 'flex h-6 w-6 items-center justify-center rounded-full bg-blumilk-500 font-semibold text-white' ]"
|
||||||
|
>
|
||||||
|
{{ day.dayNumber }}
|
||||||
|
</time>
|
||||||
|
<template #content>
|
||||||
|
<VacationPopup :vacation="getVacationInfo(day)" />
|
||||||
|
</template>
|
||||||
|
</Popper>
|
||||||
|
<div
|
||||||
|
v-else-if="day.isWeekend"
|
||||||
|
>
|
||||||
|
<time
|
||||||
|
:datetime="day.date"
|
||||||
|
:class="{ 'flex h-6 w-6 items-center justify-center rounded-full bg-blumilk-500 font-semibold text-white': day.isToday }"
|
||||||
|
>
|
||||||
|
{{ day.dayNumber }}
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
<InertiaLink
|
||||||
|
v-else
|
||||||
|
href="/vacation/requests/create"
|
||||||
|
:data="{ 'from_date': day.date }"
|
||||||
|
@mouseover.passive="onMouseover"
|
||||||
|
@mouseleave="onMouseleave"
|
||||||
|
>
|
||||||
|
<time
|
||||||
|
:datetime="day.date"
|
||||||
|
:class="{ 'flex h-6 w-6 items-center justify-center rounded-full bg-blumilk-500 font-semibold text-white': day.isToday }"
|
||||||
|
>
|
||||||
|
{{ day.dayNumber }}
|
||||||
|
</time>
|
||||||
|
</InertiaLink>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import Popper from 'vue3-popper'
|
||||||
|
import { defineProps, ref } from 'vue'
|
||||||
|
import VacationPopup from '@/Shared/VacationPopup'
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
day: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
getHolidayDescription: {
|
||||||
|
type: Function,
|
||||||
|
},
|
||||||
|
getVacationBorder: {
|
||||||
|
type: Function,
|
||||||
|
},
|
||||||
|
getVacationInfo: {
|
||||||
|
type: Function,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const isActive = ref(false)
|
||||||
|
|
||||||
|
function onMouseover() {
|
||||||
|
if (!isActive.value)
|
||||||
|
isActive.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseleave() {
|
||||||
|
if (isActive.value)
|
||||||
|
isActive.value = false
|
||||||
|
}
|
||||||
|
</script>
|
@@ -120,19 +120,16 @@
|
|||||||
class="w-full grid grid-cols-7 gap-px"
|
class="w-full grid grid-cols-7 gap-px"
|
||||||
:class="{ 'grid-rows-1': calendarState.viewMode.isWeek }"
|
:class="{ 'grid-rows-1': calendarState.viewMode.isWeek }"
|
||||||
>
|
>
|
||||||
<div
|
<DayComponent
|
||||||
v-for="(day, index) in days"
|
v-for="(day, index) in days"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="flex flex-col"
|
:day="day"
|
||||||
:class="[day.isCurrentMonth ? 'bg-white' : 'bg-gray-50 text-gray-500', calendarState.viewMode.isWeek && index !== 0 && (index % 5 === 0 || index % 6 === 0) ? 'bg-red-100' : undefined, calendarState.viewMode.isWeek ? 'day' : 'month-day', 'relative py-2 px-3']"
|
class="flex flex-col relative py-2 px-3"
|
||||||
>
|
:class="[day.isCurrentMonth ? 'bg-white' : 'bg-gray-50 text-gray-500', { 'hover:bg-blumilk-25': day.isCurrentMonth && !day.isWeekend }, { 'day': calendarState.viewMode.isWeek }, { 'bg-red-100': day.isCurrentMonth && day.isWeekend }, { 'bg-red-50': !day.isCurrentMonth && day.isWeekend }, { 'text-red-800': day.isWeekend }]"
|
||||||
<time
|
:get-holiday-description="getHolidayDescription"
|
||||||
:datetime="day.date"
|
:get-vacation-border="getVacationBorder"
|
||||||
:class="day.isToday ? 'flex h-6 w-6 items-center justify-center rounded-full bg-indigo-600 font-semibold text-white' : undefined"
|
:get-vacation-info="getVacationInfo"
|
||||||
>
|
/>
|
||||||
{{ day.date.split('-').pop().replace(/^0/, '') }}
|
|
||||||
</time>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -144,19 +141,30 @@ import { CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from '@
|
|||||||
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
||||||
import { ref, watch, computed, reactive } from 'vue'
|
import { ref, watch, computed, reactive } from 'vue'
|
||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
|
import useVacationTypeInfo from '@/Composables/vacationTypeInfo'
|
||||||
import useCurrentYearPeriodInfo from '@/Composables/yearPeriodInfo'
|
import useCurrentYearPeriodInfo from '@/Composables/yearPeriodInfo'
|
||||||
import { useMonthInfo } from '@/Composables/monthInfo'
|
import { useMonthInfo } from '@/Composables/monthInfo'
|
||||||
import { viewModes, find as findViewMode } from '@/Shared/Widgets/Calendar/ViewModeOptions'
|
import { viewModes, find as findViewMode } from '@/Shared/Widgets/Calendar/ViewModeOptions'
|
||||||
|
import DayComponent from '@/Shared/Widgets/Calendar/DayComponent'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
holidays: Object,
|
||||||
|
approvedVacations: Object,
|
||||||
|
pendingVacations: Object,
|
||||||
|
})
|
||||||
|
|
||||||
let days = ref([])
|
let days = ref([])
|
||||||
const months = useMonthInfo().getMonths()
|
|
||||||
function getCurrentDate() {
|
function getCurrentDate() {
|
||||||
const { year, month, weekNumber } = DateTime.now()
|
const { year, month, weekNumber } = DateTime.now()
|
||||||
return { year, month, week: weekNumber }
|
return { year, month, week: weekNumber }
|
||||||
}
|
}
|
||||||
const selectedYear = useCurrentYearPeriodInfo().year.value
|
|
||||||
const currentDate = getCurrentDate()
|
const currentDate = getCurrentDate()
|
||||||
|
|
||||||
|
const months = useMonthInfo().getMonths()
|
||||||
|
const { findType } = useVacationTypeInfo()
|
||||||
|
const selectedYear = useCurrentYearPeriodInfo().year.value
|
||||||
|
|
||||||
const calendar = {
|
const calendar = {
|
||||||
viewMode: ref('week'),
|
viewMode: ref('week'),
|
||||||
currents: reactive({
|
currents: reactive({
|
||||||
@@ -179,7 +187,7 @@ const calendarState = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const customCalendar = {
|
const customCalendar = {
|
||||||
generateCalendar() {
|
loadCalendar() {
|
||||||
const date = DateTime.fromObject({
|
const date = DateTime.fromObject({
|
||||||
year: calendar.currents.year,
|
year: calendar.currents.year,
|
||||||
month: calendarState.viewMode.isMonth ? calendar.currents.month : 1,
|
month: calendarState.viewMode.isMonth ? calendar.currents.month : 1,
|
||||||
@@ -221,33 +229,38 @@ const customCalendar = {
|
|||||||
return days
|
return days
|
||||||
},
|
},
|
||||||
prepareDay(day) {
|
prepareDay(day) {
|
||||||
|
const isCurrentMonth = isInCurrentMonth(day)
|
||||||
return {
|
return {
|
||||||
date: day.toISODate(),
|
date: day.toISODate(),
|
||||||
dayNumber: day.day,
|
dayNumber: day.day,
|
||||||
isCurrentMonth: isInCurrentMonth(day),
|
isCurrentMonth: isCurrentMonth,
|
||||||
isToday: isToday(day),
|
isToday: isToday(day),
|
||||||
|
isWeekend: isWeekend(day),
|
||||||
|
isHoliday: isHoliday(day),
|
||||||
|
isVacation: isCurrentMonth && isVacation(day),
|
||||||
|
isPendingVacation: isCurrentMonth && isPendingVacation(day),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([calendar.viewMode, calendar.currents], () => {
|
watch([calendar.viewMode, calendar.currents], () => {
|
||||||
customCalendar.generateCalendar()
|
customCalendar.loadCalendar()
|
||||||
})
|
})
|
||||||
|
|
||||||
customCalendar.generateCalendar()
|
customCalendar.loadCalendar()
|
||||||
|
|
||||||
function toLast() {
|
function toLast() {
|
||||||
if (calendar.viewMode.value === 'week')
|
if (calendar.viewMode.value === 'week')
|
||||||
minusWeek()
|
minusWeek()
|
||||||
else
|
else
|
||||||
addMonths(-1)
|
minusMonth()
|
||||||
}
|
}
|
||||||
|
|
||||||
function toNext() {
|
function toNext() {
|
||||||
if (calendar.viewMode.value === 'week') {
|
if (calendar.viewMode.value === 'week')
|
||||||
addWeek()
|
addWeek()
|
||||||
} else
|
else
|
||||||
addMonths()
|
addMonth()
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCalendar(config = {}) {
|
function resetCalendar(config = {}) {
|
||||||
@@ -256,7 +269,7 @@ function resetCalendar(config = {}) {
|
|||||||
|
|
||||||
calendar.currents.year = isUndefined(config.year) ? selectedYear : config.month
|
calendar.currents.year = isUndefined(config.year) ? selectedYear : config.month
|
||||||
calendar.currents.month = calendarState.isActualYear || !isUndefined(config.year) ? currentMonth : 1
|
calendar.currents.month = calendarState.isActualYear || !isUndefined(config.year) ? currentMonth : 1
|
||||||
calendar.currents.week = calendarState.isActualYear || !isUndefined(config.year) ? currentWeek : 1
|
calendar.currents.week = calendarState.isActualYear || !isUndefined(config.week) ? currentWeek : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUndefined(value) {
|
function isUndefined(value) {
|
||||||
@@ -275,15 +288,10 @@ function addWeek(minus = false) {
|
|||||||
|
|
||||||
const startWeekDay = date.startOf('week'), endWeekDay = date.endOf('week')
|
const startWeekDay = date.startOf('week'), endWeekDay = date.endOf('week')
|
||||||
nextMonth = howMany > 0 ? startWeekDay.month : endWeekDay.month
|
nextMonth = howMany > 0 ? startWeekDay.month : endWeekDay.month
|
||||||
if (howMany < 0 && endWeekDay.day === endWeekDay.daysInMonth) {
|
if (howMany < 0 && endWeekDay.day === endWeekDay.daysInMonth)
|
||||||
console.log('pre', endWeekDay.day, endWeekDay.daysInMonth)
|
|
||||||
calendar.currents.week--
|
calendar.currents.week--
|
||||||
} else if (howMany > 0 && startWeekDay.day === 1) {
|
else if (howMany > 0 && startWeekDay.day === 1)
|
||||||
console.log('next', endWeekDay.day, endWeekDay.daysInMonth)
|
|
||||||
calendar.currents.week++
|
calendar.currents.week++
|
||||||
} else {
|
|
||||||
console.log('else', endWeekDay.day, endWeekDay.daysInMonth)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextMonth !== calendar.currents.month) {
|
if (nextMonth !== calendar.currents.month) {
|
||||||
calendar.currents.month = calendar.currents.week > 1 ? nextMonth : 1
|
calendar.currents.month = calendar.currents.week > 1 ? nextMonth : 1
|
||||||
@@ -298,8 +306,12 @@ function minusWeek() {
|
|||||||
addWeek(true)
|
addWeek(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMonths(howMany = 1) {
|
function addMonth(minus = false) {
|
||||||
calendar.currents.month += howMany
|
calendar.currents.month += minus ? -1 : 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function minusMonth() {
|
||||||
|
addMonth(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToToday() {
|
function goToToday() {
|
||||||
@@ -308,7 +320,7 @@ function goToToday() {
|
|||||||
|
|
||||||
function updateViewMode(type) {
|
function updateViewMode(type) {
|
||||||
if (type === 'month')
|
if (type === 'month')
|
||||||
resetCalendar({ week: 1 })
|
resetCalendar({ week: 0 })
|
||||||
else
|
else
|
||||||
resetCalendar()
|
resetCalendar()
|
||||||
calendar.viewMode.value = type
|
calendar.viewMode.value = type
|
||||||
@@ -318,9 +330,37 @@ function isInCurrentMonth(date) {
|
|||||||
return calendar.currents.month === date.month
|
return calendar.currents.month === date.month
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWeekend(date) {
|
||||||
|
return date.weekday === 6 || date.weekday === 7
|
||||||
|
}
|
||||||
|
|
||||||
function isToday(date) {
|
function isToday(date) {
|
||||||
return date.toISODate() === DateTime.local().toISODate()
|
return date.toISODate() === DateTime.local().toISODate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isHoliday(date) {
|
||||||
|
return props.holidays[date.toISODate()] !== undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHolidayDescription(day) {
|
||||||
|
return props.holidays[day.date]
|
||||||
|
}
|
||||||
|
|
||||||
|
function isVacation(date) {
|
||||||
|
return props.approvedVacations[date.toISODate()] !== undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPendingVacation(date) {
|
||||||
|
return props.pendingVacations[date.toISODate()] !== undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVacationBorder(day) {
|
||||||
|
return findType(getVacationInfo(day).type)?.border
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVacationInfo(day) {
|
||||||
|
return day.isVacation ? props.approvedVacations[day.date] : props.pendingVacations[day.date]
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css">
|
<style lang="css">
|
||||||
@@ -344,11 +384,6 @@ function isToday(date) {
|
|||||||
content: "Pt";
|
content: "Pt";
|
||||||
}
|
}
|
||||||
|
|
||||||
.day:nth-of-type(7n - 1):before,
|
|
||||||
.day:nth-of-type(7n):before {
|
|
||||||
color: #991b1b;
|
|
||||||
}
|
|
||||||
|
|
||||||
.day:nth-of-type(7n - 1):before {
|
.day:nth-of-type(7n - 1):before {
|
||||||
content: "Sb";
|
content: "Sb";
|
||||||
}
|
}
|
||||||
@@ -356,8 +391,4 @@ function isToday(date) {
|
|||||||
.day:nth-of-type(7n):before {
|
.day:nth-of-type(7n):before {
|
||||||
content: "Nd";
|
content: "Nd";
|
||||||
}
|
}
|
||||||
|
|
||||||
.month-day:nth-of-type(7n - 1), .month-day:nth-of-type(7n) {
|
|
||||||
background-color: #fee2e2;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
<section class="grid grid-cols-1 gap-4 md:grid-cols-1">
|
||||||
<div class="hidden p-4 bg-white shadow-md md:block">
|
|
||||||
<VacationChart :stats="stats" />
|
|
||||||
</div>
|
|
||||||
<div class="h-full">
|
<div class="h-full">
|
||||||
<div class="grid grid-cols-2 gap-4 h-full">
|
<div class="grid grid-cols-2 gap-4 h-full">
|
||||||
<div class="py-5 px-4 bg-white shadow-md sm:p-6">
|
<div class="py-5 px-4 bg-white shadow-md sm:p-6">
|
||||||
@@ -77,8 +74,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import VacationChart from '@/Shared/VacationChart'
|
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
stats: Object,
|
stats: Object,
|
||||||
})
|
})
|
||||||
|
@@ -73,10 +73,10 @@ class UserTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserListIsPaginated(): void
|
public function testUserListIsPaginated(): void
|
||||||
{
|
{
|
||||||
User::factory()->count(15)->create();
|
User::factory()->count(50)->create();
|
||||||
$admin = User::factory()->admin()->create();
|
$admin = User::factory()->admin()->create();
|
||||||
|
|
||||||
$this->assertDatabaseCount("users", 16);
|
$this->assertDatabaseCount("users", 51);
|
||||||
|
|
||||||
$this->actingAs($admin)
|
$this->actingAs($admin)
|
||||||
->get("/users?page=2")
|
->get("/users?page=2")
|
||||||
|
Reference in New Issue
Block a user