FullCalendar displaying last weeks events below this weeks events

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2010-12-08T19:41:22Z Indexed on 2010/12/31 19:54 UTC
Read the original article Hit count: 314

Filed under:
|

I am developing an application to manage an On-Call calendar, using FullCalendar to render it. Most events are 1 week long, starting at 8:00 AM Tuesday and ending the following Tuesday at 8:00 AM. Another event, presumably with a different person on-call, will follow that event.

During a hallway usability test, someone commented that the month calendar view was difficult to read because the previous weeks event is not at the top of the stack, instead rendering below the event that starts during that week. When being viewed, the eye perceives that it should go down 1 line to view the remaining timeline because the event from last week is there, instead of moving down to the following week.

I investigated what I believe to be the problem:

function segCmp(a, b) {  
    return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);  
}

sorts the events for a row, but uses the length of the event in the calculation. Since the current week's event will have a longer duration, it always get sorted to the top. To test, I changed the start dates to Wednesday so the durations are closer. This cause the events to render how I would expect, with last weeks events at the top and this weeks at the bottom.

I thought that if one of the events in the compare doesn't start that week, then it should only be compared based on the start times. I modified the function to be:

function segCmp(a, b) {
    if (a.isStart == false || b.isStart == false) {
        return (a.event.start - b.event.start);
    }
    return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
}

This solved my problem, and the rendering now looks good - and passes the hallway test. What I don't know is if this would have an impact in other areas. I have taken a look at the other views (month, week, day) and they all seem to be rendering properly as well. I am just not familiar with FullCalendar enough to file a bug or feature request on this, or if this would even be considered a bug.

I am wondering if what I modified is correct, or if it is not what a better modification would be to fix this issue.

Thanks!

Below I have the json results for what should be displayed:


[{"title":"Person 1 - OnCall (OSS On Call)","id":12,"allDay":false,"start":"2010-11-30T15:00:00.0000000Z","end":"2010-12-07T15:00:00.0000000Z","editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/12"},  
{"title":"Person 2 - OnCall (OSS On Call)","id":13,"allDay":false,"start":"2010-12-07T15:00:00.0000000Z","end":"2010-12-14T15:00:00.0000000Z","editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/13"},  
{"title":"Person 3 - OnCall (OSS On Call)","id":14,"allDay":false,"start":"2010-12-14T15:00:00.0000000Z","end":"2010-12-21T15:00:00.0000000Z","editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/14"},  
{"title":"Person 4 - OnCall (OSS On Call)","id":15,"allDay":false,"start":"2010-12-21T15:00:00.0000000Z","end":"2010-12-28T15:00:00.0000000Z","editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/15"},  
{"title":"Person 5 - OnCall (OSS On Call)","id":16,"allDay":false,"start":"2010-12-28T15:00:00.0000000Z","end":"2011-01-04T15:00:00.0000000Z","editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/16"},  
{"title":"Person 6 - OnCall (OSS On Call)","id":17,"allDay":false,"start":"2011-01-04T15:00:00.0000000Z","end":"2011-01-11T15:00:00.0000000Z","editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/17"},  
{"title":"Christmas","id":2,"allDay":true,"start":"2010-12-25T07:00:00.0000000Z","end":null,"editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/2"},  
{"title":"New Years Eve","id":3,"allDay":true,"start":"2010-12-31T07:00:00.0000000Z","end":null,"editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/3"},  
{"title":"New Years Day","id":4,"allDay":true,"start":"2011-01-01T07:00:00.0000000Z","end":null,"editable":false,"className":"fc-event-title-calendar","url":"/TimeManagement/Edit/4"}]

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about fullcalendar