FullCalendar 限制调度程序中的可选时间量

FullCalendar limit amount of selectable time in scheduler

在我的调度程序视图中,我试图将用户可以 select 的时间限制为最多 4 小时。我认为 selectConstraint 会是门票,但没有找到应用最大 select 可用持续时间的方法。

我希望得到类似于 selectConstraint: {duration: '04:00'}duration: '240'(几分钟内)的结果。

或者...可能会限制 select 可用插槽的数量??我将它分成 15 分钟的增量,那么有没有办法将 select 限制为最多 16 个插槽?

我一直在搜索 FullCalendar Docs(我认为这是相当糟糕的 IMO...),但我似乎找不到关键成分。

有人吗?

$('#schedulerCalendar').fullCalendar({
     defaultView: 'agendaDay',
     defaultDate: moment(systemDate),
     eventClick: $scope.eventClick,
     editable: true,
     eventOverlap: false,
     selectable: true,
     selectHelper: true,
     select: $scope.dayClick,
     slotDuration : '00:15:00',
     slotEventOverlap: false,
     allDaySlot: false,

     // Display only business hours (8am to 5pm)
     minTime: "08:00",
     maxTime: "17:00",

     businessHours: {
         dow: [ 1, 2, 3, 4, 5], // Monday - Thursday
         start: '08:00', // start time (8am)
         end: '17:00', // end time (5pm)
     },

    hiddenDays: [ 0, 6 ],  // Hide Sundays and Saturdays

    events: function (start, end, timezone, callback) {
        callback($scope.eventSources);
    },
});

您可以使用 fullCalendar 的 selectAllow and moment duration asHours 功能:

$('#schedulerCalendar').fullCalendar({  
    //....
    selectAllow: function(selectInfo) { 
         var duration = moment.duration(selectInfo.end.diff(selectInfo.start));
         return duration.asHours() <= 4;
    },
    //...
});