如何在其他事件中添加事件 - fullcalendar

时间:2016-07-01 21:49:57

标签: javascript angularjs events fullcalendar fullcalendar-scheduler

我尝试创建一个基于AngularJS的名单。对于这个项目,我使用的是fullcalendar(调度程序版本)。

这是我目前的状态:

enter image description here

我的目标是,我想将我的员工拖放到工作层中。例如,“Haris Bjelic”,在我的工作层内(显示为“WL from 01.06 - 04.06”)。

然后我知道“Haris Bjelic”需要在01.06到04.06工作(没有休息,呵呵)。首先,我尝试找到一个函数,使我有可能在其他事件中添加一个事件。在这种情况下,我首先创建了一个名为'Work Layer from 01.06的图层。 - 04.06'我可以拖动和放弃这一层中的任何员工,以平衡他们的工作时间。

在调度程序中,我的部门(如Bar,Service等)列在左侧。在右侧是可见的下一天。

目前我尝试了这个功能:

eventOverlap: function(stillEvent, movingEvent) {}

因此,如果我将“haris bjelic”拖放到'WL从01.06 - 04.06',我可以访问这两个事件,如果它们重叠到一起。所以我试图获得'draggable'事件的ID和'WL从01.06 - 04.06'的ID,以便在数据库中设置它。

如果这样做,我想将员工姓名附加到工作层的“标题”。如果我将“Haris Bjelic”和其他员工拖放到“WL从01.06 - 04.06”,结果需要看起来像这样:

'WL 01.06 - 04.06
  "Haris Bjelic"
  "Foo Employe"
  2 emplyoee are working in this Layer'

enter image description here 这是我想要的结果!

使用 eventOverlap 功能,我可以访问这两个事件。目前,当我将“haris bjelic”拖动到另一个事件并且触发了Overver功能时,我想要更改工作层的标题。

在eventOverlap中我尝试了这个:

stillEvent.text += "\n" + movingEvent.text;
element.fullCalendar('updateEvent', stillEvent);

它创建了一个新的事件而不是只更改文本!

见这里:

enter image description here

为什么updateEvent会创建一个新事件而不是更新旧事件?我把stillEvent放在updateEvent函数中。

1 个答案:

答案 0 :(得分:4)

事件中没有text属性,它是title。我还使用此代码在标题更新后从日历中删除movingEvent:

        eventOverlap: function(stillEvent, movingEvent) {
            stillEvent.title += "\n" + movingEvent.title;
            $('#calendar').fullCalendar('updateEvent', stillEvent);
            $('#calendar').fullCalendar('removeEvents', movingEvent._id);
            return false;
        },

        eventReceive: function(event) { // called when a proper external event is dropped
            $('#calendar').fullCalendar('removeEvents', event._id);
        },

此代码适用于与fullCalendar捆绑在一起的外部拖动演示。

相关问题