FullCalendar在调度程序中的可选时间限制 [英] FullCalendar limit amount of selectable time in scheduler

查看:957
本文介绍了FullCalendar在调度程序中的可选时间限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的日程安排视图中,我试图将用户可以选择的时间限制为最多4小时。我认为 selectConstraint 是票据,但是没有看到应用最大可选持续时间的方法。

In my scheduler view, I'm trying to limit the amount of time a user can select to a maximum of 4 hours. I thought that selectConstraint would be the ticket, but don't see a way to apply a max selectable duration.

我希望沿着 selectConstraint:{duration:'04:00'} 或者持续时间:'240'(以分钟为单位)。

I was hoping for something along the lines of selectConstraint: {duration: '04:00'} or perhaps duration: '240' (in minutes).

或...可能会限制可选插槽的数量?我已经把它分成了15分钟的增量,那么有没有办法将选择限制到最多16个插槽?

Or... maybe limit the number of selectable slots?? I have it broken up into 15 minute increments, so is there a way to limit the select to a maximum of 16 slots?

我一直在冲刷 FullCalendar Docs (这是我认为比较差的IMO ...),但我似乎无法找到关键

I've been scouring the FullCalendar Docs (which is I think is rather poor IMO...), but I can't seem to find the key ingredient.

$('#schedulerCalendar')
$ b

Anyone?

$('#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 和瞬间持续时间

You can use fullCalendar's selectAllow and moment duration asHours functions:

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

这篇关于FullCalendar在调度程序中的可选时间限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆