Skip to content

Commit

Permalink
Extract resourceId from eventSource if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jboulay committed Feb 4, 2018
1 parent 8cf5f78 commit dbc63c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/models/EventDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ once we do away with the deprecated eventResourceField.
EventDef.prototype.applyMiscProps = function(rawProps) {
rawProps = $.extend({}, rawProps) // clone, because of delete

this.resourceIds = Resource.extractIds(rawProps, this.source.calendar)
this.resourceIds = Resource.extractIds(rawProps, this.source)

delete rawProps.resourceId
delete rawProps.resourceIds
Expand Down
3 changes: 2 additions & 1 deletion src/models/EventSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { EventSource } from 'fullcalendar'

// defineStandardProps won't work :(
// TODO: find a better way
(EventSource.prototype as any).standardPropMap.resourceEditable = true // automatically transfer
(EventSource.prototype as any).standardPropMap.resourceEditable = true; // automatically transfer
(EventSource.prototype as any).standardPropMap.resourceId = true
8 changes: 6 additions & 2 deletions src/models/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
export default class Resource {


static extractIds(rawProps, calendar) {
const resourceField = calendar.opt('eventResourceField') || 'resourceId'
static extractIds(rawProps, source) {
const resourceField = source.calendar.opt('eventResourceField') || 'resourceId'
const resourceIds = []

if (rawProps.resourceIds) {
Expand All @@ -16,6 +16,10 @@ export default class Resource {
resourceIds.push(Resource.normalizeId(rawProps[resourceField]))
}

if (source[resourceField]) {
resourceIds.push(Resource.normalizeId(source[resourceField]))
}

return resourceIds
}

Expand Down

0 comments on commit dbc63c8

Please sign in to comment.