Our pure JavaScript Scheduler component


Post by lucaas »

I have some weird errors when dragging milestone events in a Scheduler configured with an assignment store.
Uncaught TypeError: Cannot read property 'id' of null
    at RowManager.getRowById (scheduler.umd.js:69564)
    at HorizontalEventMapper.getTimeSpanRenderData (scheduler.umd.js:126873)
    at Scheduler.generateTplData (scheduler.umd.js:120694)
    at scheduler.umd.js:101214
    at Array.forEach (<anonymous>)
    at EventDrag.setupProductDragData (scheduler.umd.js:101200)
    at EventDrag.getDragData (scheduler.umd.js:107490)
    at EventDrag.getDragData (scheduler.umd.js:101249)
    at EventDrag.onDragStart (scheduler.umd.js:107050)
    at EventDrag.onDragStart (scheduler.umd.js:100872)
    at DragHelper.trigger (scheduler.umd.js:33986)
    at DragHelper.callPreventable (scheduler.umd.js:33836)
    at DragHelper.internalMove (scheduler.umd.js:22053)
    at DragHelper.onMouseMove (scheduler.umd.js:22114)
    at HTMLDocument.handler (scheduler.umd.js:23016)
I tracked down the error to the `getAssignmentForEventAndResource` method in the `AssignmentStore` not finding the assignment record.

Unfortunatly, I haven't been able to reproduce the issue outside of our application.

The following patch seems to solve the issue for me, but I am not sure it is the correct approach.
diff --git a/AssignmentStore.js b/AssignmentStore.js
index 187858f..2b2a6e6 100644
--- a/AssignmentStore.js
+++ b/AssignmentStore.js
@@ -414,7 +414,7 @@ export default class AssignmentStore extends AjaxStore {
         //return me.records.find(a => key == me.modelClass.makeAssignmentEventResourceCompositeKey(a.eventId, a.resourceId));

         // noinspection EqualityComparisonWithCoercionJS
-        return me.records.find(assignment => assignment.event == event && assignment.resource == resource);
+        return me.records.find(assignment => assignment.event.id == event.id && assignment.resource.id == resource.id);
     }

     //endregion

Post by saki »

Would you please try to reproduce it with one of our demos or give us the code that triggers it? If it is a bug, we would fix it in the AssignmentStore code.

Post by lucaas »

It is a bit hard to reproduce reliably. I think it might be due to a combination of buffered rendering and assignments.

Here is a screen capture of the issue:

Image

I can reproduce the issue in the https://www.bryntum.com/examples/scheduler/multiassign/ demo using the following code:
var scheduler = bryntum.query('scheduler');

scheduler.resourceStore.removeAll();

var resources = Array(1000).fill(null).map((item, index) => ({
    id: `test-resource-${index}`,
    name: `Test ${index}`,
}));

scheduler.resourceStore.add(resources);

scheduler.eventStore.add({
    id         : 'test-event-01',
    startDate  : new Date(2017, 0, 1, 13),
    endDate    : new Date(2017, 0, 1, 13),
    name       : 'Milestone',
});

scheduler.assignmentStore.add([
    {
        id: 'test-assignment-01',
        eventId: 'test-event-01',
        resourceId: 'test-resource-1',
    }, {
        id: 'test-assignment-02',
        eventId: 'test-event-01',
        resourceId: 'test-resource-2',
    }
]);
I then drag the milestones down so it starts scrolling and let it go. The error appears some times, but not consistently.

The milestones also dissapears after I release it sometimes. Scrolling down and up again to refersh the view shows the milestone where it was dropped.

Post by saki »


Post Reply