Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use resourceId from eventSource if it exists #418

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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