Premium support for our pure JavaScript UI components


Post by jandresampaio »

Hi,

We're manually loading assignments, events and resources, depending on the current timeAxis start and end.
Sometimes this would lead to assignment store catching a "remove" action, when the new dataset is empty, which is not desirable, since we're basically dealing with a dataset operation.

The point is:
1) why suspend events doesn't work as expected and still triggers dataset in your example with the code attached, on the multiple assignments?
2) why triggering assignments remove when the dataset was in fact loaded with an empty array? how can we workaround this? Because we need to catch the assignments that were removed, like when unassigning.

Code attached that demonstrates our issues.

Thank you

Attachments
app.module (2).zip
(1.06 KiB) Downloaded 71 times

Post by mats »

1) why suspend events doesn't work as expected and still triggers dataset in your example with the code attached, on the multiple assignments?

This might be considered a bug, we'll discuss.

why triggering assignments remove when the dataset was in fact loaded with an empty array? how can we workaround this? Because we need to catch the assignments that were removed, like when unassigning.

I don't see 'remove' event fired, just 'dataset' which is expected since a new array was set.


Post by jandresampaio »

Maybe some timing issue, here's the console log of the remove, followed by dataset.

Evidence - remove followed by dataset.PNG
Evidence - remove followed by dataset.PNG (103.86 KiB) Viewed 1259 times

So, what is the recommended approach for reloading stores? I guess we're not the only ones doing this.
This is a major issue for us since it might wipe out all the existing assignments when moving to a different timespan and the new timespan doesn't have any...


Post by mats »

Reloading stores can be done like you do it, what's the problem you face with your current approach?


Post by jandresampaio »

-The "remove" action is triggered on the assignment store
-We save assignment whenever the assignment store is changed (except on the dataset action). We also save the removed assignments.
-If this remove is triggered when assigning an empty dataset, we don't know if it's a "Unassign". From what we know, we don't have a way to distinguish between those two.


Post by mats »

Looks correct to me when running it in the demo, this is the output i see in the console:

Action:  dataset
app.js:97 scheduler assignments:  (7) [AssignmentModelEx, AssignmentModelEx, AssignmentModelEx, AssignmentModelEx, AssignmentModelEx, AssignmentModelEx, AssignmentModelEx]
app.js:96 Action:  remove
app.js:97 scheduler assignments:  []
app.js:96 Action:  dataset
app.js:97 scheduler assignments:  []

Setting empty assignments on this demo will of course trigger remove of the initial assignments.


Post by jandresampaio »

If this remove is triggered when assigning an empty dataset, we don't know if it's a "Unassign". From what we know, we don't have a way to distinguish between those two.


Post by alex.l »

Hi jandresampaio,

Changing data in stores is async. Please check: https://bryntum.com/docs/scheduler/#Scheduler/data/AssignmentStore
So events happen after you called scheduler.resumeEvents();. This is why you don't see them if you used commented line setTimeout( () => scheduler.resumeEvents(), 2000);.

There is no difference via remove assignment and unassign.

If you change your code like this:

  scheduler.suspendEvents(false);
  await scheduler.resourceStore.loadDataAsync([resources[0], resources[1]]);
  await scheduler.eventStore.loadDataAsync([]);
  await scheduler.assignmentStore.loadDataAsync([]);
  scheduler.resumeEvents();

you will be able to suspend events as you need.

All the best,
Alex

All the best,
Alex


Post by jandresampaio »

Hi Alex,

Thanks for the update. Makes sense. Until the latest 4.0.8 version, we used this setTimout of 300ms as a workaround, because we were setting all the properties on scheduler synchronously and it was working. Has any change been introduced lately?

Thanks you.


Post by alex.l »

Hi jandresampaio,

This operation was async before 4.0.8 too, and you were need to use timeout anyway. It's hard to say why 300ms was enough and now it's not enough, too many possible options.

All the best,
Alex


Post Reply