Our powerful JS Calendar component


Post by durban »

Hello, I tried to add a "Duplicate event" in the context menu (like the example below), but I have a problem.

https://www.bryntum.com/examples/calendar/custom-menus/

I'm using, instead of a CrudManager, a project, and when I duplicate an event, the resources are not bound to the new event.
So I tried to add directly the assignments to the project (code below), but it doesn't work. Is there something I'm missing?

duplicateEvent({ eventRecord }) {
	const dupe = eventRecord.copy();
	
// In case it was a recurring event, the dupe will be a one-off.
dupe.recurrence = null;
this.eventStore.add(dupe);
// On ajoute les assignements pour le nouvel événement
let newAssignments = [];
this.project.$assignmentStore._data.forEach(function (data) {
	if (data.eventId === eventRecord.data.id)
		newAssignments.push({ event: dupe.data.id, eventId: dupe.data.id, resource: data.resourceId, resourceId: data.resourceId })
	});

this.project.$assignmentStore._data = this.project.$assignmentStore._data.concat(newAssignments);
this.refresh();
}

Post by Animal »

A duplicate event is a good idea for the built in menu. I will think about adding it. The incantation is:

eventStore.assignmentStore.assignEventToResource(eventRecord, resourceRecords);

Post by Animal »


Post by durban »

It worked, thanks!


Post Reply