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