Premium support for our pure JavaScript UI components

Post by tikhonov.a.p »

Good afternoon.

There is the following task:
Manage the changes that will be sent for saving when sync() is called.
For example: ignore changes for tasks, dependencies, assignments, resources if they have some property

I am studying the source code of Crudemanager and ProjectModel, but I have not yet found points through which I could manage this.

Please tell me the classes/methods that you need to look at

Post by marcio »

Hi tikhonov.a.p

I believe you are looking for the beforeSync method, with that, you can return false to avoid syncing based on some condition

project.on('beforesync', function() {
    if (some condition) return false;

Best regards,

Post by tikhonov.a.p »

Yes, it might help. However, I need to not interrupt the synchronization altogether. And skip some "Changes".

My goal is to make a multiproject mapping. Where only the main project could be edited, and attempts to change external ones would be ignored.

I know that there is a readOnly flag on the task, however, I'm afraid it doesn't always work correctly.(There are a number of tickets that prove this)

The solution to my problem seemed to me that for "additional" projects I would create additional taskstores and hoped that by modifying the TaskStore data methods I would be able to influence the synchronized data.

Perhaps you have some ideas?

Post by alex.l »

Looks like you want to prevent changes throw UI but allow it on data level. Might be better in that case to catch user changes on taskEdit, taskResize, cellEdit features level? Or maybe disable them (features) at all, if different projects used at different time or components.

All the best,

Post by tikhonov.a.p »

Of course, in these places I was also going to add validation data and different behavior when working in multi-project mode

However, for "security", you never know if someone will be able to somehow "with definitely established stars" do something like that.
And to understand how I can influence synchronization is very useful for further work with your wonderful product

Post by arcady »

beforeSync should work fine to skip certain changes persisting

project.on('beforesync', ({ pack }) => {
    // do not persists any task changes
    delete pack.tasks

    // find changes of dependency w/ id==1
    const indexToSanitize = pack.dependencies.updated.findIndex((i) => == 1)
    // do not persist the changes
    pack.dependencies.updated..splice(indexToSanitize, 1)

Post by tikhonov.a.p »

Thx, i will try do it

Post Reply