计划程序中FullCalendar限制的可选时间

Dre*_*rew 0 jquery scheduler fullcalendar momentjs fullcalendar-scheduler

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

我希望有一些类似的东西,selectConstraint: {duration: '04:00'} 或者duration: '240'(几分钟内)。

或者...也许限制了可选插槽的数量?我将其分解为15分钟的增量,因此是否有办法将选择限制为最多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);
    },
});
Run Code Online (Sandbox Code Playgroud)

小智 5

您可以将fullCalendar的selectAllow和持续时间用作“小时”功能:

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