FullCalendar-Scheduler Google Calendars ResourceID

2019-07-24 23:36发布

Reference: FullCalendar 3.9.0, FullCalendar-Scheduler 1.9.4

Can anyone confirm whether or not it is possible to group Google calendar events by resource? Adding a resourceId parameter to a calendar source as follows:

    var myCalSrc = {
    id: 1,
    googleCalendarId: '<myCalSrcURL>',
    color: '<myCalSrcColor>',
    className: '<myCalSrc-events>'
};

results in a blank display. The following note in the FullCalendar-Scheduler gcal.html file located in the demos directory states:

  /*
  NOTE: unfortunately, Scheduler doesn't know how to associated events from
  Google Calendar with resources, so if you specify a resource list,
  nothing will show up :(  Working on some solutions.
  */

However, the following threads appear to suggest there may have been a fix for this:

GitHub - Add ResourceId Parameter to gcal.js (fix supplied)

GitHub - Specify resourceId in Event Source settings

However, checking the gcal.js file reveals the fix has not been added to that file.

Is it possible to manually assign a resourceId to each of the Google Calendar feeds in order to replicate the Resources and Timeline view indicated by the FullCalendar Timeline View documentation?

Any guidance would be greatly appreciated.

1条回答
劫难
2楼-- · 2019-07-25 00:09

As per the issue in your second GitHub link (which your first one was merged with), https://github.com/fullcalendar/fullcalendar-scheduler/issues/124, the fix you mentioned is still awaiting testing (as of 11 Mar 2018). So if you're patient it will likely be added to a future release, assuming it passes the tests. In the meantime, here is a potential workaround:

In fullCalendar it's possible to define a separate eventDataTransform for every event source.

Therefore I think you should be able to use this to set a resource ID for each event depending on the Google Calendar it came from:

eventSources: [
  { 
    googleCalendarId: 'abc@group.calendar.google.com', 
    color: 'blue',
    eventDataTransform: function(event) {
      event.resourceId = 1;
      return event;
    } 
  }, 
  { 
    googleCalendarId: 'def@group.calendar.google.com', 
    color: 'green', 
    eventDataTransform: function(event) {
      event.resourceId = 2;
      return event;
    } 
  }, 
  { 
    googleCalendarId: 'ghi@group.calendar.google.com', 
    color: 'red' ,
    eventDataTransform: function(event) {
      event.resourceId = 3;
      return event;
    } 
  }
]

I'm not able to test this right now but it looks like it should work. Hopefully this will take place before it's rendered on the calendar and needs to belong to a resource.

查看更多
登录 后发表回答