Our pure JavaScript Scheduler component


Post by nico-priv »

Hello,
I have an error when i drag and drop an event.
It's works fine for one drag and the second this error appear.

Drag error.png
Drag error.png (176.96 KiB) Viewed 172 times

I don't know what the problem is, I updated the schedule to version 5.1.0 and since then I have this error.


Post by mats »

Tried 5.1.1? Can you please upload a small test case for us?


Post by nico-priv »

Sorry, it's complicated to make a test case of my project. I will try. But I think my problem may be the way I populate the schedule.
"this.schedu" is my scheduler.

this.schedulerService.interWorkers.pipe(takeUntil(this.destroyed$)).subscribe(
      data => {
        this.interWorkers = data;

    const e = new EventStore({
      modelClass: InterventionWorkerSchedulerGpModel as any,
      data: this.interWorkers
    });

    const assig: any[] = [];
    this.interWorkers.forEach(ap => {
      ap.resourceIds.forEach(r => {
        const a: any = {
          resourceId: r,
          eventId: ap.id
        };

        assig.push(a);
      });
    });

    this.schedu.assignments = assig;
    this.schedu.eventStore = e;

  }
);

Post by nico-priv »

Here is a test case
[Removed by moderator. Please never post licensed Bryntum source code in open sources]


Post by tasnim »

I cannot reproduce it in the test case that you provided. Could you please provide a test where I can reproduce the issue?

Best of luck,
Tasnim


Post by nico-priv »

Hello, i tried the test case and i have an error.
Try several times to drag and drop one of the events already created.

scheduler drag error.png
scheduler drag error.png (111.6 KiB) Viewed 143 times

Post by alex.l »

This happened because of the way you set data into the scheduler.

First of all we highly recommend to use wrappers for work with frameworks. Please see https://bryntum.com/docs/scheduler/guide/Scheduler/quick-start/angular
https://bryntum.com/docs/scheduler/guide/Scheduler/integration/angular/guide

Second, you set eventStore class after scheduler initialized which is not necessary in your case and looks weird. If you want to work with inline data, please see https://bryntum.com/docs/scheduler/guide/Scheduler/integration/angular/data-binding

And the main problem is that when you replace a full eventStore instance with already created records after assignments data, it causes this problem. Basically, it's race condition because of such approach. Assignments check if any events available with id defined and set a link with assigned resource to event record. But in your case events are not there at the moment and more than that it won't happen after you set events as well, because you replaced full eventStore.

In 2 words, try to set assignments data after eventStore replacement.


  this.scheduler.eventStore = e;
  this.scheduler.assignments = assig;

But I highly recommend to read our guides and update your code to not have problems in the future :)
Good luck!

All the best,
Alex


Post by nico-priv »

Thank :D


Post Reply