FullCalendar显示本周活动以下的上周活动

时间:2010-12-08 19:41:23

标签: javascript fullcalendar

我正在开发一个管理On-Call日历的应用程序,使用FullCalendar来呈现它。大多数活动为1周,从周二上午8:00开始,到下周二上午8:00结束。另一个事件,可能是一个不同的人随叫随到,将跟随那个事件。

在走廊可用性测试期间,有人评论月日历视图难以阅读,因为前几周的事件不在堆栈的顶部,而是在该周开始的事件之下呈现。在观看时,眼睛会感觉它应该向下移动1行以查看剩余的时间线,因为上周的事件在那里,而不是向下移动到下一周。

我调查了我认为的问题:

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

对行进行排序,但在计算中使用事件的长度。由于本周的活动持续时间较长,因此总是排在最前面。为了测试,我将开始日期更改为星期三,以便持续时间更接近。这导致事件呈现我的预期,上周的事件在顶部,本周在底部。

我认为如果比较中的某个事件没有在那周开始,那么它应该只根据开始时间进行比较。我修改了函数:

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);
}

这解决了我的问题,渲染现在看起来很好 - 并通过了走廊测试。我不知道的是,这是否会对其他领域产生影响。我已经看过其他视图(月,周,日),它们似乎也正常呈现。我只是不熟悉FullCalendar足以在此处提交错误或功能请求,或者这甚至会被视为错误。

我想知道我修改的内容是否正确,或者修复此问题是不是更好的修改。

谢谢!

下面我给出了应该显示的内容的json结果:


[{"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"}]

1 个答案:

答案 0 :(得分:0)

听起来你正试图解决这个问题: http://code.google.com/p/fullcalendar/issues/detail?id=510

我认为你的mod不会导致任何不良行为,当你有2个事件都包装到第二行时,它会破坏,保证它们保持相同的顺序。一个防弹解决方案需要相当多的进一步工作,希望在某些时候能够解决这个问题。