refactor(task-modal): fixed calendar position in timeblocks

This commit is contained in:
Matej Glasnák committed 2025-10-14 19:33:48 +02:00
1 parent 0035251080
commit 2a2ba6db51
2 files changed
+41 -5

No files matched your search

@@ -6,11 +6,11 @@
<div <div
@click="handleDatepickerClick" @click="handleDatepickerClick"
class="datepicker-wrapper" class="datepicker-wrapper"
ref="datepicker-wrapper" :ref="`timeblock-datepicker-wrapper-${index}`"
> >
<Datepicker <Datepicker
:model-value="timeblock.date" :model-value="timeblock.date"
ref="datepicker" :ref="`timeblock-datepicker-${index}`"
@update:model-value="updateDate" @update:model-value="updateDate"
format="dd.MM.yyyy" format="dd.MM.yyyy"
locale="sk" locale="sk"
@@ -85,6 +85,10 @@ export default {
type: Function, type: Function,
default: () => ({}), default: () => ({}),
}, },
index: {
type: Number,
},
}, },
data() { data() {
@@ -105,10 +109,42 @@ export default {
methods: { methods: {
handleDatepickerClick() { handleDatepickerClick() {
// Pass the datepicker wrapper element reference to the mixin // Pass the datepicker wrapper element reference to the mixin
const scrollTarget = this.$refs['datepicker-wrapper']; const scrollTarget =
this.$refs[`timeblock-datepicker-wrapper-${this.index}`];
this.onDateOpen(scrollTarget); this.onDateOpen(scrollTarget);
// Open the datepicker // Open the datepicker
this.openDatepicker('datepicker'); this.openDatepicker(`timeblock-datepicker-${this.index}`);
setTimeout(() => {
const calendar = document.querySelector(
'.dp__menu.dp__menu_index.dp__theme_light',
);
if (!calendar) return;
// Get the datepicker wrapper element
const datepickerWrapper =
this.$refs[`timeblock-datepicker-wrapper-${this.index}`];
// Get the modal container
const modalContainer = document.querySelector('.v-overlay__content');
if (!datepickerWrapper || !modalContainer) return;
// Get bounding rectangles
const wrapperRect = datepickerWrapper.getBoundingClientRect();
const modalRect = modalContainer.getBoundingClientRect();
// Calculate position relative to modal
const topPosition =
wrapperRect.top - modalRect.top + wrapperRect.height;
const leftPosition = wrapperRect.left - modalRect.left;
// Apply positioning
// calendar.style.position = 'absolute';
calendar.style.top = `${topPosition + 210}px`;
// calendar.style.left = `${leftPosition}px`;
}, 100);
}, },
async openDatepicker(ref) { async openDatepicker(ref) {
@@ -247,6 +247,7 @@
:prevent-input-focus="preventInputFocus" :prevent-input-focus="preventInputFocus"
:on-input-focus="onInputFocus" :on-input-focus="onInputFocus"
:on-date-open="onDateOpen" :on-date-open="onDateOpen"
:index="index"
/> />
<div class="end-button w-100" v-if="!subtask.id"> <div class="end-button w-100" v-if="!subtask.id">
<button @click="addTimeblock">Pridať časový blok</button> <button @click="addTimeblock">Pridať časový blok</button>
@@ -349,7 +350,6 @@
<script> <script>
import Datepicker from '@vuepic/vue-datepicker'; import Datepicker from '@vuepic/vue-datepicker';
import ZFilesUpload from '@/plugins/tm@_components/z-files-upload.vue'; import ZFilesUpload from '@/plugins/tm@_components/z-files-upload.vue';
import ATaskTimeblocks from '@/plugins/tm@modal/task/_components/_components/a-task-timeblocks.vue';
import useVuelidate from '@vuelidate/core'; import useVuelidate from '@vuelidate/core';
import { required, requiredIf, optional } from '@vuelidate/validators'; import { required, requiredIf, optional } from '@vuelidate/validators';
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'; import errorUtils from '@/plugins/lib@auth/_utils/error.utils';