From 2fb2415203dcc3a3d75f0b2806de79981677cbc4 Mon Sep 17 00:00:00 2001 From: Kamil Niemczycki Date: Wed, 8 Jun 2022 11:02:37 +0200 Subject: [PATCH] #157 - more interactive calendar (#162) * #157 - added support for the date parameter * #157 - prepared clikable days * removed line with consol log * lint * #157 - prepared clikable days for calendar of holidays * #157 - added a privilege check * #157 - added support for the user id parameter * improved loading of selected date * updated calendar * #157 - added the request class and improved the request parameters * csf * Apply suggestions from code review Co-authored-by: Krzysztof Rewak * Apply suggestion Co-authored-by: Krzysztof Rewak * icon has been renamed Co-authored-by: EwelinaLasowy * selection of previous days restored Co-authored-by: EwelinaLasowy Co-authored-by: Adrian Hopek * changes for the controller have been withdrawn Co-authored-by: Adrian Hopek * wip * Update resources/js/Composables/vacationTypeInfo.js Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * #157 - updated cursor type for weekened Co-authored-by: EwelinaLasowy Co-authored-by: Krzysztof Rewak Co-authored-by: EwelinaLasowy Co-authored-by: Adrian Hopek Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> --- .../VacationCalendarController.php | 1 + .../Controllers/VacationRequestController.php | 2 + resources/js/Composables/vacationTypeInfo.js | 8 ++++ resources/js/Pages/AnnualSummary.vue | 24 +++++++++--- resources/js/Pages/Calendar.vue | 39 ++++++++++++++++++- resources/js/Pages/VacationRequest/Create.vue | 14 +++++-- 6 files changed, 78 insertions(+), 10 deletions(-) diff --git a/app/Infrastructure/Http/Controllers/VacationCalendarController.php b/app/Infrastructure/Http/Controllers/VacationCalendarController.php index 20d1678..2673f6f 100644 --- a/app/Infrastructure/Http/Controllers/VacationCalendarController.php +++ b/app/Infrastructure/Http/Controllers/VacationCalendarController.php @@ -44,6 +44,7 @@ class VacationCalendarController extends Controller "users" => SimpleUserResource::collection($users), "can" => [ "generateTimesheet" => $request->user()->can("generateTimesheet"), + "createOnBehalfOfEmployee" => $request->user()->can("createOnBehalfOfEmployee"), ], ]); } diff --git a/app/Infrastructure/Http/Controllers/VacationRequestController.php b/app/Infrastructure/Http/Controllers/VacationRequestController.php index 7d8b543..fffc401 100644 --- a/app/Infrastructure/Http/Controllers/VacationRequestController.php +++ b/app/Infrastructure/Http/Controllers/VacationRequestController.php @@ -180,6 +180,8 @@ class VacationRequestController extends Controller "createOnBehalfOfEmployee" => $request->user()->can("createOnBehalfOfEmployee", VacationRequest::class), "skipFlow" => $request->user()->can("skipFlow", VacationRequest::class), ], + "vacationUserId" => (int)$request->get("user"), + "vacationFromDate" => $request->get("from_date"), ]); } diff --git a/resources/js/Composables/vacationTypeInfo.js b/resources/js/Composables/vacationTypeInfo.js index 3bd73b9..b112d69 100644 --- a/resources/js/Composables/vacationTypeInfo.js +++ b/resources/js/Composables/vacationTypeInfo.js @@ -9,6 +9,7 @@ import CalendarCheckIcon from 'vue-material-design-icons/CalendarCheck.vue' import MedicalBagIcon from 'vue-material-design-icons/MedicalBag.vue' import CalendarRemoveIcon from 'vue-material-design-icons/CalendarRemove.vue' import HomeCityIcon from 'vue-material-design-icons/HomeCity.vue' +import PlusIcon from 'vue-material-design-icons/Plus.vue' const types = [ { @@ -88,6 +89,13 @@ const types = [ color: 'text-lime-500', border: 'border-lime-500', }, + { + text: 'Złóż wniosek', + value: 'create', + icon: PlusIcon, + color: 'text-blumilk-700', + border: 'border-lime-500', + }, ] export default function useVacationTypeInfo() { diff --git a/resources/js/Pages/AnnualSummary.vue b/resources/js/Pages/AnnualSummary.vue index 46f434b..5c2f3d1 100644 --- a/resources/js/Pages/AnnualSummary.vue +++ b/resources/js/Pages/AnnualSummary.vue @@ -39,7 +39,7 @@ offset-distance="0" >
- + + +
+ @@ -118,7 +134,7 @@ diff --git a/resources/js/Pages/VacationRequest/Create.vue b/resources/js/Pages/VacationRequest/Create.vue index 3118556..b990620 100644 --- a/resources/js/Pages/VacationRequest/Create.vue +++ b/resources/js/Pages/VacationRequest/Create.vue @@ -343,19 +343,23 @@ const props = defineProps({ users: Object, holidays: Object, can: Object, + vacationUserId: [Number, null], + vacationFromDate: [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 === (checkUserId(props.vacationUserId) ?? props.auth.user.id)) ?? props.users.data[0] : props.auth.user, - from: null, - to: null, + from: props.vacationFromDate, + to: props.vacationFromDate, vacationType: null, comment: null, flowSkipped: false, }) +refreshEstimatedDays(form.from, form.to) + const estimatedDays = ref([]) const vacationTypes = ref([]) @@ -423,6 +427,10 @@ function resetForm() { estimatedDays.value = [] } +function checkUserId(userId) { + return userId > 0 ? userId: null +} + async function refreshEstimatedDays(from, to) { if (from && to) { const res = await axios.post('/api/vacation/calculate-days', { from, to })