You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an issue with the scrollTime. What I'd like to achieve is that, when all my data are fetched, compare all the hours and set the scrollTime to the one with the earliest one.
The issue is that, even if I can get the earliest value, I can't set the scrollTime with the setOption function or even when doing options.scrollTime = newScrollTime.
I did check the value of the scrollTime with some console.log and it does seem to change but not visually.
I haven't seen anyone with the same issue as me so I don't know if it's a known bug or if my code is just too horendous to work as is.
If you have any question or simply want a more simplified version let me know.
Here's a "simplified" version of my code :
Thank you for your time.
<scriptlang="ts">import'../../app.postcss';importCalendarfrom'@event-calendar/core';importTimeGridfrom'@event-calendar/time-grid';import{onMount}from'svelte';// Initialize variables and calendar optionsletplugins=[TimeGrid];letscrollTime: string='00:00:00';letcalendarRef: HTMLElement|null=null;letresaData: any;letuniqueRooms: any=[];letearliestTime: string;letearliestTimeSeconds: number;// Calendar options configurationletoptions={firstDay: 1,height: '100%',scrollTime: scrollTime,events: [],datesSet: function(info: any){constformattedStart=formatDateTime(info.startStr);constformattedEnd=formatDateTime(info.endStr);loadReservations(formattedStart,formattedEnd);},};// Function to format date-time stringfunctionformatDateTime(dateTimeStr: any){returndateTimeStr.replace('T',' ');}// Convert time string to secondsfunctiontoSeconds(time: any){const[hours,minutes,seconds]=time.split(':').map(Number);returnhours*3600+minutes*60+seconds;}// Find the earliest time in reservationsfunctionfindEarliestTime(reservations: any){returnreservations.reduce((earliest: any,reservation: any)=>{constcurrentSeconds=toSeconds(reservation.processedStart);constearliestSeconds=toSeconds(earliest);returncurrentSeconds<earliestSeconds ? reservation.processedStart : earliest;},'23:59:59');}// Function to load reservations using hardcoded dataasyncfunctionloadReservations(startDate: string|null=null,endDate: string|null=null){constdata={"data": [{"id": 383,"title": "test delete user","roomId": 2,"start": "2024-05-15 03:00:00","end": "2024-05-15 05:00:00",},{"id": 385,"title": "errgegrgreg","roomId": 6,"start": "2024-05-15 05:00:00","end": "2024-05-15 06:00:00",},]};letprocessedReservations=data.data.map((reservation: any)=>({
...reservation,processedStart: reservation.start.slice(11,19),processedEnd: reservation.end.slice(11,19),roomName: reservation.roomName,}));options.events=processedReservationsasnever[];resaData=data.data;uniqueRooms=resaData.reduce((acc: any,reservation: any)=>{constroomExists=acc.find((room: {roomName: any;})=>room.roomName===reservation.roomName);if(!roomExists){acc.push({roomName: reservation.roomName,backgroundColor: reservation.backgroundColor});}returnacc;},[]);earliestTime=findEarliestTime(processedReservations);earliestTimeSeconds=toSeconds(earliestTime);options.scrollTime=earliestTimeSeconds.toString();returndata.data;}</script><divclass="flex m-4 main-content"><divclass="flex-grow mr-2 overflow-auto calendar-container"><divclass="calendar-content"><Calendarbind:this={calendarRef}{plugins}{options}/></div></div></div>
The text was updated successfully, but these errors were encountered:
Hi,
I have an issue with the scrollTime. What I'd like to achieve is that, when all my data are fetched, compare all the hours and set the scrollTime to the one with the earliest one.
The issue is that, even if I can get the earliest value, I can't set the scrollTime with the setOption function or even when doing options.scrollTime = newScrollTime.
I did check the value of the scrollTime with some console.log and it does seem to change but not visually.
I haven't seen anyone with the same issue as me so I don't know if it's a known bug or if my code is just too horendous to work as is.
If you have any question or simply want a more simplified version let me know.
Here's a "simplified" version of my code :
Thank you for your time.
The text was updated successfully, but these errors were encountered: