#157 - added support for the user id parameter
This commit is contained in:
parent
48ef40e8ff
commit
5f02e23f51
@ -173,6 +173,11 @@ class VacationRequestController extends Controller
|
||||
->orderByProfileField("first_name")
|
||||
->get();
|
||||
|
||||
if(($selectedUserId = $request->get("user")) && is_numeric($selectedUserId)) {
|
||||
$userId = User::query()
|
||||
->find($selectedUserId)?->id;
|
||||
}
|
||||
|
||||
return inertia("VacationRequest/Create", [
|
||||
"vacationTypes" => VacationType::casesToSelect(),
|
||||
"users" => SimpleUserResource::collection($users),
|
||||
@ -180,6 +185,7 @@ class VacationRequestController extends Controller
|
||||
"createOnBehalfOfEmployee" => $request->user()->can("createOnBehalfOfEmployee", VacationRequest::class),
|
||||
"skipFlow" => $request->user()->can("skipFlow", VacationRequest::class),
|
||||
],
|
||||
"userId" => $userId ?? null,
|
||||
"vacationStartDate" => $request->get("start_date"),
|
||||
]);
|
||||
}
|
||||
|
@ -110,18 +110,32 @@
|
||||
>
|
||||
<VacationTypeCalendarIcon :type="day.vacationTypes[user.id]" />
|
||||
</div>
|
||||
<InertiaLink
|
||||
<template
|
||||
v-else-if="isActiveBtn(user.id + '+' + day.date) && !day.isWeekend && !day.isHoliday && day.isFuture && (auth.user.id === user.id || can.createOnBehalfOfEmployee)"
|
||||
>
|
||||
<InertiaLink
|
||||
v-if="can.createOnBehalfOfEmployee"
|
||||
href="/vacation/requests/create"
|
||||
:data="{ 'user': user.id, 'start_date': day.date }"
|
||||
>
|
||||
<div class="flex justify-center items-center">
|
||||
<VacationTypeCalendarIcon
|
||||
type="create"
|
||||
/>
|
||||
</div>
|
||||
</InertiaLink>
|
||||
<InertiaLink
|
||||
v-else
|
||||
href="/vacation/requests/create"
|
||||
:data="{ 'start_date': day.date }"
|
||||
>
|
||||
<div class="flex justify-center items-center">
|
||||
<VacationTypeCalendarIcon
|
||||
type="create"
|
||||
class="text-blumilk-700"
|
||||
/>
|
||||
</div>
|
||||
</InertiaLink>
|
||||
</template>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -343,12 +343,13 @@ const props = defineProps({
|
||||
users: Object,
|
||||
holidays: Object,
|
||||
can: Object,
|
||||
userId: [Number, null],
|
||||
vacationStartDate: [String, null],
|
||||
})
|
||||
|
||||
const form = useForm({
|
||||
user: props.can.createOnBehalfOfEmployee
|
||||
? props.users.data.find(user => user.id === props.auth.user.id) ?? props.users.data[0]
|
||||
? props.users.data.find(user => user.id === (props.userId ?? props.auth.user.id)) ?? props.users.data[0]
|
||||
: props.auth.user,
|
||||
from: props.vacationStartDate,
|
||||
to: null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user