This commit is contained in:
Adrian Hopek 2022-03-29 13:40:56 +02:00
parent 720d2c4e7b
commit 93f0151b14
14 changed files with 126 additions and 121 deletions

View File

@ -30,13 +30,15 @@ class YearPeriodRetriever
public function links(): array
{
$current = $this->selected();
$selected = $this->selected();
$current = $this->current();
$years = YearPeriod::query()->whereIn("year", $this->offset($current->year))->get();
$years = YearPeriod::query()->whereIn("year", $this->offset($selected->year))->get();
$navigation = $years->map(fn(YearPeriod $yearPeriod) => $this->toNavigation($yearPeriod));
return [
"current" => $current->year,
"current" => $this->toNavigation($current),
"selected" => $this->toNavigation($selected),
"navigation" => $navigation->toArray(),
];
}

View File

@ -36,6 +36,6 @@ class GoogleController extends Controller
$auth->guard()->login($user, true);
return redirect()->route("dashboard");
return redirect()->intended();
}
}

View File

@ -2,8 +2,8 @@ import { computed } from 'vue'
import { usePage } from '@inertiajs/inertia-vue3'
export default function useCurrentYearPeriodInfo() {
const minDate = computed(() => new Date(usePage().props.value.years.current, 0, 1))
const maxDate = computed(() => new Date(usePage().props.value.years.current, 11, 31))
const minDate = computed(() => new Date(usePage().props.value.years.selected.year, 0, 1))
const maxDate = computed(() => new Date(usePage().props.value.years.selected.year, 11, 31))
return {
minDate,

View File

@ -10,7 +10,7 @@
<InertiaLink
v-if="previousMonth"
as="button"
:href="`/vacation-calendar/${previousMonth.value}`"
:href="`/vacation/calendar/${previousMonth.value}`"
class="flex items-center justify-center rounded-l-md border border-r-0 border-gray-300 bg-white py-2 pl-3 pr-4 text-gray-400 hover:text-gray-500 focus:relative md:w-9 md:px-2 md:hover:bg-gray-50"
>
<ChevronLeftIcon class="h-5 w-5" />
@ -23,7 +23,7 @@
</span>
<InertiaLink
as="button"
:href="`/vacation-calendar/${currentMonth.value}`"
:href="`/vacation/calendar/${currentMonth.value}`"
class="hidden border-t border-b border-gray-300 bg-white px-3.5 text-sm font-medium flex items-center text-gray-700 hover:bg-gray-50 hover:text-gray-900 focus:relative md:block"
>
Dzisiaj
@ -31,7 +31,7 @@
<InertiaLink
v-if="nextMonth"
as="button"
:href="`/vacation-calendar/${nextMonth.value}`"
:href="`/vacation/calendar/${nextMonth.value}`"
class="flex items-center justify-center rounded-r-md border border-l-0 border-gray-300 bg-white py-2 pl-4 pr-3 text-gray-400 hover:text-gray-500 focus:relative md:w-9 md:px-2 md:hover:bg-gray-50"
>
<ChevronRightIcon class="h-5 w-5" />
@ -59,13 +59,13 @@
<tr>
<th class="w-64 py-2 border text-lg font-semibold text-gray-800 border-gray-300">
<div class="flex justify-center items-center">
{{ selectedMonth.name }} {{ years.current }}
{{ selectedMonth.name }} {{ years.selected.year }}
</div>
</th>
<th
v-for="day in calendar"
:key="day.dayOfMonth"
class="border border-gray-300 text-lg font-semibold text-gray-900 py-4 px-2"
class="border border-gray-300 text-lg font-semibold text-gray-900 py-2 px-2"
style="min-width: 46px;"
:class="{ 'bg-red-100 text-red-800': day.isWeekend || day.isHoliday, 'text-blumilk-600 bg-blumilk-25': day.isToday }"
>
@ -83,16 +83,13 @@
v-for="user in users.data"
:key="user.id"
>
<th class="border border-gray-300 py-2 px-4">
<th class="border border-gray-300 py-2 px-2">
<div class="flex justify-start items-center">
<span class="inline-flex items-center justify-center h-10 w-10 rounded-full">
<img
class="h-10 w-10 rounded-full"
:src="user.avatar"
>
<span class="inline-flex items-center justify-center h-8 w-8 rounded-full">
<img :src="user.avatar">
</span>
<div class="ml-3">
<div class="text-sm font-medium text-gray-900 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900 truncate">
{{ user.name }}
</div>
</div>

View File

@ -155,7 +155,7 @@ function submitVacationDays() {
days: item.hasVacation ? item.days : null,
})),
}))
.put('/vacation-limits', {
.put('/vacation/limits', {
preserveState: (page) => Object.keys(page.props.errors).length,
preserveScroll: true,
})

View File

@ -287,7 +287,7 @@
<div class="flex justify-end py-3">
<div class="space-x-3">
<InertiaLink
href="/vacation-requests"
href="/vacation/requests"
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
>
Anuluj
@ -388,7 +388,7 @@ function createForm() {
type: data.type.value,
user: data.user.id,
}))
.post('/vacation-requests')
.post('/vacation/requests')
}
function onFromChange(selectedDates, dateStr) {
@ -418,14 +418,14 @@ function resetForm() {
async function refreshEstimatedDays(from, to) {
if (from && to) {
const res = await axios.post('/api/calculate-vacation-days', { from, to })
const res = await axios.post('/api/calculate-vacation/days', { from, to })
estimatedDays.value = res.data
}
}
async function refreshVacationStats(user) {
const res = await axios.post('/api/calculate-vacation-stats', { user: user.id })
const res = await axios.post('/api/calculate-vacation/stats', { user: user.id })
stats.value = res.data
}

View File

@ -9,7 +9,7 @@
</div>
<div>
<InertiaLink
href="/vacation-requests/create"
href="/vacation/requests/create"
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
>
Dodaj wniosek
@ -84,7 +84,7 @@
>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="font-semibold text-blumilk-600 hover:text-blumilk-500 hover:underline"
>
{{ request.name }}
@ -107,13 +107,13 @@
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="flex justify-around"
>
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
</InertiaLink>
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="absolute inset-0"
/>
</td>

View File

@ -9,7 +9,7 @@
</div>
<div>
<InertiaLink
href="/vacation-requests/create"
href="/vacation/requests/create"
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
>
Dodaj wniosek
@ -224,7 +224,7 @@
>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="font-semibold text-blumilk-600 hover:text-blumilk-500 hover:underline"
>
{{ request.name }}
@ -263,13 +263,13 @@
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="flex justify-around"
>
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
</InertiaLink>
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="absolute inset-0"
/>
</td>
@ -334,7 +334,7 @@ const form = reactive({
})
watch(form, debounce(() => {
Inertia.get('/vacation-requests', { user: form.user?.id, status: form.status.value }, {
Inertia.get('/vacation/requests', { user: form.user?.id, status: form.status.value }, {
preserveState: true,
replace: true,
})

View File

@ -60,13 +60,14 @@
Data
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<template v-if="request.days.length > 1">
{{ request.from }} - {{ request.to }}
</template>
<template v-else>
{{ request.from }}
</template>
<span class="font-semibold">
<template v-if="request.days.length > 1">
{{ request.from }} - {{ request.to }} [Liczba dni: {{ request.days.length }}]
</template>
<template v-else>
{{ request.from }} [Liczba dni: {{ request.days.length }}]
</template>
[Liczba dni: {{ request.days.length }}]
</span>
</dd>
</div>
@ -100,7 +101,7 @@
</div>
<div class="ml-4 flex-shrink-0">
<a
:href="`/vacation-requests/${request.id}/download`"
:href="`/vacation/requests/${request.id}/download`"
target="_blank"
class="font-medium text-blumilk-600 hover:text-blumilk-500"
>
@ -130,7 +131,7 @@
</div>
<div class="mt-5">
<InertiaLink
:href="`/vacation-requests/${request.id}/accept-as-technical`"
:href="`/vacation/requests/${request.id}/accept-as-technical`"
method="post"
as="button"
preserve-scroll
@ -156,7 +157,7 @@
</div>
<div class="mt-5">
<InertiaLink
:href="`/vacation-requests/${request.id}/accept-as-administrative`"
:href="`/vacation/requests/${request.id}/accept-as-administrative`"
method="post"
as="button"
preserve-scroll
@ -182,7 +183,7 @@
</div>
<div class="mt-5">
<InertiaLink
:href="`/vacation-requests/${request.id}/reject`"
:href="`/vacation/requests/${request.id}/reject`"
method="post"
as="button"
preserve-scroll
@ -208,7 +209,7 @@
</div>
<div class="mt-5">
<InertiaLink
:href="`/vacation-requests/${request.id}/cancel`"
:href="`/vacation/requests/${request.id}/cancel`"
method="post"
as="button"
preserve-scroll

View File

@ -44,7 +44,6 @@
class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
@click="sidebarOpen = false"
>
<span class="sr-only">Close sidebar</span>
<XIcon class="h-6 w-6 text-white" />
</button>
</div>
@ -102,32 +101,28 @@
>
</InertiaLink>
</div>
<nav class="mt-5 flex-1 flex flex-col divide-y divide-blumilk-800 overflow-y-auto">
<div class="px-2 space-y-1">
<nav class="mt-5 px-2 flex-1 flex flex-col divide-y divide-blumilk-800 overflow-y-auto">
<InertiaLink
href="/"
:class="[$page.component === 'Dashboard' ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
>
<HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
Strona główna
</InertiaLink>
<div class="mt-1 pt-1">
<InertiaLink
href="/"
:class="[$page.component === 'Dashboard' ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
v-for="item in navigation"
:key="item.name"
:href="item.href"
:class="[$page.component === item.component ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
>
<HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
Strona główna
<component
:is="item.icon"
class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200"
/>
{{ item.name }}
</InertiaLink>
</div>
<div class="mt-4 pt-4">
<div class="px-2 space-y-1">
<InertiaLink
v-for="item in navigation"
:key="item.name"
:href="item.href"
:class="[$page.component === item.component ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
>
<component
:is="item.icon"
class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200"
/>
{{ item.name }}
</InertiaLink>
</div>
</div>
</nav>
</div>
</div>
@ -139,7 +134,6 @@
class="px-4 border-r border-gray-200 text-gray-400 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blumilk-500 lg:hidden"
@click="sidebarOpen = true"
>
<span class="sr-only">Open sidebar</span>
<MenuAlt1Icon class="h-6 w-6" />
</button>
<div class="flex-1 px-4 flex justify-between sm:px-6 lg:px-8">
@ -150,14 +144,14 @@
class="relative inline-block text-left"
>
<div class="flex justify-center items-center">
<div class="mr-4">
<div class="mr-4 text-sm">
Wybrany rok:
</div>
<div>
<MenuButton
class="inline-flex justify-center w-full rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
>
{{ years.current }}
{{ years.selected.year }}
<ChevronDownIcon class="-mr-1 ml-2 h-5 w-5" />
</MenuButton>
</div>
@ -189,7 +183,7 @@
>
{{ item.year }}
<CheckIcon
v-if="item.year === years.current"
v-if="item.year === years.selected"
class="h-5 w-5 text-blumilk-500 ml-2"
/>
</InertiaLink>
@ -199,6 +193,20 @@
</transition>
</Menu>
</div>
<div
v-if="years.current.year !== years.selected.year"
class="ml-3 text-sm hidden sm:block"
>
<InertiaLink
:href="years.current.link"
as="button"
method="post"
:preserve-state="false"
class="font-medium text-blumilk-600 hover:text-blumilk-500"
>
Kliknij, aby wrócić do obecnego roku
</inertialink>
</div>
</div>
<div class="ml-4 flex items-center md:ml-6">
<Menu
@ -213,7 +221,6 @@
:src="auth.user.avatar"
>
<span class="hidden ml-3 text-gray-700 text-sm font-medium lg:block">
<span class="sr-only">Open user menu for </span>
{{ auth.user.name }}
</span>
<ChevronDownIcon class="hidden flex-shrink-0 ml-1 h-5 w-5 text-gray-400 lg:block" />
@ -285,28 +292,28 @@ const navigation = computed(() =>
[
{
name: 'Moje wnioski',
href: '/vacation-requests/me',
href: '/vacation/requests/me',
component: 'VacationRequest/Index',
icon: DocumentTextIcon,
can: true,
},
{
name: 'Wnioski urlopowe',
href: '/vacation-requests',
href: '/vacation/requests',
component: 'VacationRequest/IndexForApprovers',
icon: CollectionIcon,
can: props.auth.can.listAllVacationRequests,
},
{
name: 'Kalendarz urlopów',
href: '/vacation-calendar',
href: '/vacation/calendar',
component: 'Calendar',
icon: CalendarIcon,
can: true,
},
{
name: 'Wykorzystanie urlopu',
href: '/monthly-usage',
href: '/vacation/monthly-usage',
component: 'MonthlyUsage',
icon: AdjustmentsIcon,
can: props.auth.can.listMonthlyUsage,
@ -320,7 +327,7 @@ const navigation = computed(() =>
},
{
name: 'Limity urlopów',
href: '/vacation-limits',
href: '/vacation/limits',
component: 'VacationLimits',
icon: SunIcon,
can: props.auth.can.manageVacationLimits,

View File

@ -16,7 +16,7 @@
<div class="relative focus-within:ring-2 focus-within:ring-blumilk-500">
<h3 class="text-sm font-semibold text-blumilk-600 hover:text-blumilk-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="hover:underline focus:outline-none"
>
<span class="absolute inset-0" />
@ -54,7 +54,7 @@
</div>
<div class="mt-6">
<InertiaLink
href="/vacation-requests"
href="/vacation/requests"
:data="{status: 'waiting_for_action'}"
class="w-full flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blumilk-500"
>

View File

@ -16,7 +16,7 @@
<div class="relative focus-within:ring-2 focus-within:ring-blumilk-500">
<h3 class="text-sm font-semibold text-blumilk-600 hover:text-blumilk-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
:href="`/vacation/requests/${request.id}`"
class="hover:underline focus:outline-none"
>
<span class="absolute inset-0" />
@ -41,7 +41,7 @@
</div>
<div class="mt-6">
<InertiaLink
href="/vacation-requests/me"
href="/vacation/requests/me"
class="w-full flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blumilk-500"
>
Zobacz wszystkie

View File

@ -32,7 +32,7 @@ createInertiaApp({
InertiaProgress.init({
delay: 0,
color: 'red',
color: '#527ABA',
})
Flatpickr.localize(Polish)

View File

@ -21,51 +21,49 @@ Route::middleware("auth")->group(function (): void {
Route::post("/logout", LogoutController::class);
Route::resource("users", UserController::class);
Route::post("/users/{user}/restore", [UserController::class, "restore"])->withTrashed();
Route::post("/users/{user}/restore", [UserController::class, "restore"])
->withTrashed();
Route::resource("holidays", HolidayController::class);
Route::get("/vacation-limits", [VacationLimitController::class, "edit"])
->name("vacation.limits");
Route::get("/vacation-calendar/{month?}", [VacationCalendarController::class, "index"])
->name("vacation.calendar");
Route::get("/timesheet/{month}", TimesheetController::class)
->name("timesheet");
Route::get("/vacation-limits", [VacationLimitController::class, "edit"])->name("vacation.limits");
Route::put("/vacation-limits", [VacationLimitController::class, "update"]);
Route::get("/vacation-requests/me", [VacationRequestController::class, "index"])
->name("vacation.requests.index");
Route::get("/vacation-requests", [VacationRequestController::class, "indexForApprovers"])
->name("vacation.requests.indexForApprovers");
Route::get("/vacation-requests/create", [VacationRequestController::class, "create"])
->name("vacation.requests.create");
Route::post("/vacation-requests", [VacationRequestController::class, "store"])
->name("vacation.requests.store");
Route::get("/vacation-requests/{vacationRequest}", [VacationRequestController::class, "show"])
->name("vacation.requests.show");
Route::get("/vacation-requests/{vacationRequest}/download", [VacationRequestController::class, "download"])
->name("vacation.requests.download");
Route::post("/vacation-requests/{vacationRequest}/reject", [VacationRequestController::class, "reject"])
->name("vacation.requests.reject");
Route::post("/vacation-requests/{vacationRequest}/cancel", [VacationRequestController::class, "cancel"])
->name("vacation.requests.cancel");
Route::post(
"/vacation-requests/{vacationRequest}/accept-as-technical",
[VacationRequestController::class, "acceptAsTechnical"],
)
->name("vacation.requests.accept-as-technical");
Route::post(
"/vacation-requests/{vacationRequest}/accept-as-administrative",
[VacationRequestController::class, "acceptAsAdministrative"],
)
->name("vacation.requests.accept-as-administrative");
Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class)
->name("year-periods.select");
Route::get("/monthly-usage", MonthlyUsageController::class)->name("monthly-usage");
Route::prefix("/vacation")->group(function () {
Route::get("/limits", [VacationLimitController::class, "edit"])
->name("vacation.limits");
Route::get("/calendar/{month?}", [VacationCalendarController::class, "index"])
->name("vacation.calendar");
Route::get("/timesheet/{month}", TimesheetController::class)
->name("timesheet");
Route::get("/limits", [VacationLimitController::class, "edit"])
->name("vacation.limits");
Route::put("/limits", [VacationLimitController::class, "update"]);
Route::get("/requests", [VacationRequestController::class, "indexForApprovers"])
->name("vacation.requests.indexForApprovers");
Route::get("/requests/me", [VacationRequestController::class, "index"])
->name("vacation.requests.index");
Route::get("/requests/create", [VacationRequestController::class, "create"])
->name("vacation.requests.create");
Route::post("/requests", [VacationRequestController::class, "store"])
->name("vacation.requests.store");
Route::get("/requests/{vacationRequest}", [VacationRequestController::class, "show"])
->name("vacation.requests.show");
Route::get("/requests/{vacationRequest}/download", [VacationRequestController::class, "download"])
->name("vacation.requests.download");
Route::post("/requests/{vacationRequest}/reject", [VacationRequestController::class, "reject"])
->name("vacation.requests.reject");
Route::post("/requests/{vacationRequest}/cancel", [VacationRequestController::class, "cancel"])
->name("vacation.requests.cancel");
Route::post("/requests/{vacationRequest}/accept-as-technical", [VacationRequestController::class, "acceptAsTechnical"],)
->name("vacation.requests.accept-as-technical");
Route::post("/requests/{vacationRequest}/accept-as-administrative", [VacationRequestController::class, "acceptAsAdministrative"],)
->name("vacation.requests.accept-as-administrative");
Route::get("/monthly-usage", MonthlyUsageController::class)
->name("vacation.monthly-usage");
});
});
Route::middleware("guest")->group(function (): void {