Timeline snapping changes dates


I’ve been implementing the scheduler timeline in order to create a shift planner for employees.
However, I’ve come across what seems to be a bug in the timeline view.
I’ve done some customization to make events fill out the line, display line-by-line and show the start/end times for the event as seen below.

When I drag the event to another employee, I want the event times to stay the same.
However, due to the snapping it changes the start/end times relative to the start of the cell.
An event that goes from 9am to 10am will change to 0-1am and one that goes from 9am to 3pm will go from 0-6am.

I’ve looked in the sample files and it seems all the timeline views have this behaviour.

I’ve created a workaround where I save the start_date and end_date in a temporary var onEventDrag and then use those in my onEventChanged that saves the event.
It saves the correct data, but I have to reload the events every time to show the correct dates. It’s a bit ugly.

Any ideas as to how I can fix this?

Thanks (sorry for the longwindedness).

In addition, I just found that this same bug also affects the collision plugin.
It checks the wrong time when comparing for collisions :frowning:

It works fine in the regular week view, but as soon as I use the timeline week view it gets the times confused.

At least it’s only the sexy fluff in my calendar that’s is not working :unamused:


It doesn’t get confused, it works as instructed :slight_smile: Indeed we are changing event start date to the start date of the cell (in your example - 19 Mar. 00:00).

Do you save events yourself, without our dataprocessor? If so simply assign correct start and end dates to event and refresh it (scheduler.updateEvent(id)) or even whole view (scheduler.setCurrentView()).

Kind regards,

Hm. Okay then. Is there a way around it, while keeping the snap?
As I said, it also breaks the collision plugin :frowning:

Yeah. My framework has it’s own dataprocessor. This helps.
I was loading a whole months worth of events every time. Just updating the specific event would be so much faster :slight_smile:

Collision extension offers event you can use to check if that’s a real problem or not.

If you say that event properties are correct but it is only displayed incorrectly - then all you need to do is to refresh current view, correct.

In the upcoming version we will add something for such case (not changing minutes if that’s not necessary).

Kind regards,

All right, I’ll snoop around the collision plugin. See if I can find a solution.

Thanks :slight_smile:

Hi again Ilya,

I’ve been looking at the timeline.js file trying to figure out where it sets the event’s start_date to midnight so I can work around it, but I can’t figure it out (not being a javascript shark may have something to do with that).

Can you help me get on the right track to where this happens?

Okay, found the cause and created this superhack to work arround it.
Added two new temporary parameters in my event map and grab the start/end hour/minutes from them, while using the date from the dragged event.
That solves my general issue of it changing the date when dragging.

[code]scheduler.render_data=function(evs, mode){
if (this._mode == obj.name){
if (mode) //repaint single event, precision is not necessary
for (var i=0; i < evs.length; i++) {
/* SEB Changes */
if (scheduler.getState().mode == “timeline_week”){
if (evs[i].workEffortId){
var startDate = evs[i].start_date;
var endDate = evs[i].end_date;

						var evStartYear = startDate.getFullYear();
						var evStartMonth = startDate.getMonth();
						var evStartDay = startDate.getDate();
						var tempStartHour = evs[i].tempStartDate.substring(11,13);
						var tempStartMinute = evs[i].tempStartDate.substring(14,16);
						var evEndYear = endDate.getFullYear();
						var evEndMonth = endDate.getMonth();
						var evEndDay = endDate.getDate();
						var tempEndHour = evs[i].tempEndDate.substring(11,13);
						var tempEndMinute = evs[i].tempEndDate.substring(14,16);
						var evStartDate = new Date(evStartYear,evStartMonth,evStartDay, tempStartHour, tempStartMinute);
						var evEndDate = new Date(evEndYear,evEndMonth,evEndDay, tempEndHour, tempEndMinute);
						evs[i].start_date = evStartDate;
						evs[i].end_date = evEndDate;
				/* End SEB Changes */
				this.render_timeline_event.call(this.matrix[this._mode], evs[i], 0, true);
	} else
		return old.apply(this,arguments);[/code]

Also added the following code to ensure that new events added in the week timeline don’t use the whole day to look for overlaps (prevented me from adding any new events at all through week view).

scheduler.attachEvent("onBeforeEventChanged",function(ev,e,is_new){ /* SEB Changes */ if (scheduler.getState().mode == "timeline_week"){ if (!ev.workEffortId) ev.end_date = ev.start_date; } /* End SEB Changes */ return collision_check(ev); });