Our pure JavaScript Scheduler component


Post by rytis.i »

I'm using the following code to change the event start date

        const currentStart = new Date(event.startDate);
        const start = new Date(currentStart.setDate(currentStart.getDate() + 1));
        event.setStartEndDate(start, event.endDate as Date);

I would expect the start date to change and the end day to stay the same, making the event shorter. This does not happen though. After the EventStore.commit the event end date is recalculated to keep the length the same.

Code attached

Attachments
package.zip
(27.54 KiB) Downloaded 16 times
setStartEndDate.gif
setStartEndDate.gif (905.01 KiB) Viewed 205 times

Post by ghulam.ghous »

Hi,

This is expected behaviour, because with the updated startDate, endDate is recalculated and as your duration is not changing, it is updating the endDate. Try updating the duration and startDate inside the eventEditor. You can see the endDate is gonna remain same after you commit with the updated startDate and duration.

Hope it helps!
Regards,
Ghous


Post by ghulam.ghous »

Try this:

async function startIncrease() {
    if (!eventStore.value) {
        return;
    }
    const event = eventStore.value.last as EventModel;
    if (event) {
        console.log(`current start/end ${moment(event.startDate).format("YYYY-MM-DD")} - ${moment(event.endDate).format("YYYY-MM-DD")} - ${event.duration}`);
        const currentStart = new Date(event.startDate);
        const start = new Date(currentStart.setDate(currentStart.getDate() + 1));
        console.log(`new start/end ${moment(start).format("YYYY-MM-DD")} - ${moment(event.endDate).format("YYYY-MM-DD")}  - ${event.duration}`);
        event.setStartEndDate(start, event.endDate as Date);
        event.set('duration', event.duration-1)
        await eventStore.value.commit();
        console.log(`after commit ${moment(event.startDate).format("YYYY-MM-DD")} - ${moment(event.endDate).format("YYYY-MM-DD")}  - ${event.duration}`);
    }
}

Post by rytis.i »

wow, this is super unexpected. What is the point of passing the endDate in setStartEndDate? If this is expected I feel like https://www.bryntum.com/products/scheduler/docs/api/Scheduler/model/EventModel#function-setStartEndDate doc needs some type of explanation of what it actually does. I assume I can achieve the desired behavior using EventModel.setStartDate with keepDuration set to true or no? And again, reading the API there are 3 methods: setStartDate, setEndDate and setStartEndDate one would think that setStartEndDate sets both start and end date and recalculates duration. I feel that if setStartEndDate doesn't do what the name implies it really needs to be documented.


Post by ghulam.ghous »

Hi there,

I checked with team, and this looks like a bug. I have opened a ticket to investigate and fix this issue here https://github.com/bryntum/support/issues/8881

Regards,
Ghous


Post by ghulam.ghous »

Hi @rytis.i,

Upon further investigating this issue, it came to light that setStartEndDate method is not yet not supported in SchedulerPro. The reason for this is, SchedulerPro uses a engine for scheduling and we need to implement the setStartEndDate method at the engine level. The bug was this method shouldn't be documented in the docs. We will fix the docs.

Regards,
Ghous


Post by rytis.i »

This is disappointing to hear. Please note that setStartEndDate is not only in the docs but also in the Typescript definitions of SchedulerPro

Attachments
setStartEnd.PNG
setStartEnd.PNG (30.09 KiB) Viewed 120 times

Post by ghulam.ghous »

Yes. That will be handled and removed from TS definition and docs. A pull request is already in progress for that.


Post Reply