CroudTech / vue-fullcalendar

FullCalendar Wrapper for vue
MIT License
483 stars 100 forks source link

4.0.0-1: context.cmdFormatter & start.format is not a function #172

Open fullstackfool opened 6 years ago

fullstackfool commented 6 years ago

We've been using eventSources like:

{
          events({start, end, timeZone}, callback) {
            self.$http.get(`/holidays`, {
                timezone: timezone,
                start: start.format('YYYY/MM/DD')
            }).then(response => {
              callback(response.data.data)
            })
          },
          color: 'yellow',
          textColor: 'black',
},

Recently receiving errors of start.format is not a function.

Logging start shows it to be an object:

{
    end: Sun Nov 11 2018 00:00:00 GMT+0000 (Greenwich Mean Time) {}
    endStr: "2018-11-11T00:00:00Z"
    start: Sun Sep 30 2018 00:00:00 GMT+0100 (British Summer Time) {}
    startStr: "2018-09-30T00:00:00+01:00"
    timeZone: "local"
}

end:

f ( ) {
        if (!isResolved) {
            isResolved = true;
            success.apply(this, arguments);
        }
}

If i fix the format issue by updating to:

{
          events({start, end, timeZone}, callback) {
            self.$http.get(`/holidays`, {
                start: moment(start).format('YYYY/MM/DD'), 
                timezone: timezone
            }).then(response => {
              callback(response.data.data)
            })
          },
          color: 'yellow',
          textColor: 'black',
},

Then we get a new error: TypeError: context.cmdFormatter is not a function

Versions: vue-full-calendar: 4.0.0-1 fullcalendar: 4.0.0-alpha.2 moment: 2.22.2 moment-timezone: 0.5.21

I suspect we've changed another dependacy, which in turn has effected fullcalendar, but i can't figure out what. Does this error look familiar to anyone?

BrockReece commented 6 years ago

What happens if you log out moment(start), are you getting a valid moment obj?

fullstackfool commented 6 years ago

Invalid object.

Tracked the issue to when vue-full-calendar is using fullcalendar: 4.0.0-alpha.2. Forcing it to use 4.0.0-alpha fixes the issue.

ash-rain commented 6 years ago

+1 Subscribing. Having the same issue with the new alpha.

BrockReece commented 6 years ago

I am guessing then this is probably an error with fullcalendar: 4.0.0-alpha.2 rather than this repo. Is it worth opening an issue on their repo?

I am happy to fix the version of fullcalendar though to the more stable version if this is a blocker?

BrockReece commented 6 years ago

I am reading their release notes for v4, it looks like there is a section outlining some changes in 'Event Source Function'

Have you read the docs? Seems like the fetchInfo obj has some additional fields for startStr and endStr. Are they worth trying?

JackPriceBurns commented 6 years ago

It seems the first argument is this fetchInfo object that has both the start and the end date time stamps. The start and end are no longer passed separately? And the other arguments seem to return promises, not sure what they do.

fullstackfool commented 6 years ago

Quite possibly - looking into it now.

The fixed version would be a good temporary fix, thanks!

Edit: Also, if the package is going to use the alpha version of fullcalendar, shouldn't the local v4.0.0-1 release also be marked as Pre-release?

fullstackfool commented 6 years ago

Yeah, so the events have been combined, which you can then use to instantiate a moment object.

Then we get a new error: TypeError: context.cmdFormatter is not a function

Now going to try using an event url, instead of the function

identy commented 5 years ago

// titleFormat: 'MMMM'

error in title format

Xalior commented 5 years ago

This bug still exists in the final release of fullcal, and is in the base library itself outwith of the vue integrations it seems (I can reproduce it on the base library, exact same issues as @fullstackfool reports above)