diff --git a/client/src/components/cards/vacationCard.vue b/client/src/components/cards/vacationCard.vue index e844aadb..dbb8d6f4 100644 --- a/client/src/components/cards/vacationCard.vue +++ b/client/src/components/cards/vacationCard.vue @@ -45,12 +45,12 @@ + label="From" v-model="start_date" :readonly="!couldUpdate" type="date"> + label="To" v-model="end_date" :readonly="!couldUpdate" type="date" :rules="[validateEndDate]"> @@ -98,9 +98,13 @@ export default { setup(props, ctx) { const $api = useApi() + const startDate = ref(new Date(props.vacation.from_date)); + const start_date= ref(startDate.value.toISOString().split('T')[0]); + + + const endDate = ref(new Date(props.vacation.end_date)) + const end_date= ref(endDate.value.toISOString().split('T')[0]); - const startDate = ref(props.vacation.from_date) - const endDate = ref(props.vacation.end_date) const leaveReason = ref({ name: transformString(props.vacation.reason), reason: props.vacation.reason @@ -153,6 +157,20 @@ export default { return false }) + const from_date = computed(() => { + let val = new Date(startDate.value) + val.setHours(8, 0, 0, 0) + return val.toISOString() + }) + const to_date = computed(() => { + let val = new Date(endDate.value) + val.setHours(16, 0, 0, 0) + + return val.toISOString() + }) + + + const couldDelete = computed(() => { if (user.value) { @@ -242,8 +260,8 @@ export default { async function calculateActualDays() { return useAsyncState( $api.vacations.calculate.list({ - start_date: startDate.value, - end_date: endDate.value + start_date: start_date.value, + end_date: end_date.value }), [] ) @@ -261,8 +279,8 @@ export default { await useAsyncState( $api.vacations.edit.update(props.vacation.id, { reason: leaveReason.value.reason, - from_date: startDate.value, - end_date: endDate.value, + from_date: from_date.value, + end_date: to_date.value, actual_days: actualDays.state.value }), null, @@ -284,6 +302,8 @@ export default { couldApprove, couldUpdate, couldDelete, + start_date, + end_date, validateEndDate, updateVacation, handleApprove, diff --git a/client/src/components/requests/leaveRequest.vue b/client/src/components/requests/leaveRequest.vue index 3283547f..1e72d49e 100644 --- a/client/src/components/requests/leaveRequest.vue +++ b/client/src/components/requests/leaveRequest.vue @@ -48,13 +48,15 @@
+ label="Vacation Start Time" v-model="excuseStart" hide-details="auto" type="time" :rules="[validateTimes]" + :readonly="startDate !== endDate">
+ label="Vacation End Time" v-model="excuseEnd" hide-details="auto" type="time" :rules="[validateTimes]" + :readonly="startDate !== endDate">
@@ -176,6 +178,7 @@ export default { watch( () => [selectedOption.value], () => { + leaveReason.value = undefined if (selectedOption.value === Selection.ANOTHERUSER) { selectedUser.value = officeUsers.value[0] } else { @@ -274,8 +277,8 @@ export default { const startTimeInHours = timeStringToHours(excuseStart.value); const endTimeInHours = timeStringToHours(excuseEnd.value); const days = (endTimeInHours - startTimeInHours) / CORE_HOURS - if( days === 0.25 || days === 0.50 || days === 0.75){ - return days + if (days === 0.25 || days === 0.50 || days === 0.75) { + return days } return 1