Premium support for our pure JavaScript UI components


Post by tikhonov.a.p »

Good afternoon. Prompt where to look on a following situation.

Task: Add tasks to the ProjectModel in readOnly status from another ProjectModel. Added tasks should not be synchronized when calling sync()

Gantt 5.1.1
What am I doing

  1. I load ProjectModel let's call it PM1
  2. I load another ProjectModel let's call it PM2
  3. I add a number of tasks from PM2 to PM1 and set their readOnly status
  4. I call the commite() method on Stores PM1. Judging by the description and code, it should reset the "changes" data and assume that the added tasks are already synchronized.
  5. I call gantt.project.changes - I get null (which is logical, I called commite earlier)
  6. Add a new task to PM1 (gantt.project.taskStore.add({name:"Task1"})
  7. I call gantt.project.changes. I see that there is only an action to add a task and update the parent.
    {
        "tasks": {
            "added": [
                {
                    "parentIndex": 11,
                    "startDate": "2022-08-10T09:00:00+03:00",
                    "endDate": "2022-08-10T18:00:00+03:00",
                    "duration": 1,
                    "durationUnit": "day",
                    "cls": "",
                    "name": "Task1",
                    "calendar": null,
                    "direction": "Forward",
                    "manuallyScheduled": false,
                    "earlyStartDate": "2022-08-10T09:00:00+03:00",
                    "earlyEndDate": "2022-08-10T18:00:00+03:00",
                    "constraintType": null,
                    "constraintDate": null,
                    "percentDone": 0,
                    "inactive": null,
                    "lateStartDate": "2022-09-12T09:00:00+03:00",
                    "lateEndDate": "2022-09-12T18:00:00+03:00",
                    "critical": false,
                    "effort": 8,
                    "effortUnit": "hour",
                    "effortDriven": true,
                    "schedulingMode": "FixedDuration",
                    "baselines": [],
                    "parentId": "7130865572493721602",
                    "taskCostCategory": "adaptation",
                    "$PhantomId": "_generatedClassDefEx448"
                }
            ],
            "updated": [
                {
                    "id": "7130865572493721602",
                    "parentIndex": 0,
                    "startDate": "2022-08-10T09:00:00+03:00",
                    "endDate": "2022-09-12T18:00:00+03:00",
                    "duration": 24,
                    "durationUnit": "day",
                    "cls": "",
                    "name": "ExternalPlan",
                    "calendar": null,
                    "direction": "Forward",
                    "manuallyScheduled": false,
                    "earlyStartDate": "2022-08-10T09:00:00+03:00",
                    "earlyEndDate": "2022-09-12T18:00:00+03:00",
                    "constraintType": "startnoearlierthan",
                    "constraintDate": "2022-08-10T00:00:00+03:00",
                    "percentDone": 0,
                    "inactive": false,
                    "lateStartDate": "2022-08-11T00:00:00+03:00",
                    "lateEndDate": "2022-09-12T18:00:00+03:00",
                    "critical": true,
                    "effort": 96,
                    "effortUnit": "hour",
                    "effortDriven": false,
                    "schedulingMode": "Normal",
                    "expanded": true,
                    "baselines": [],
                    "parentId": null,
                    "keyMilestone": false,
                    "taskCostCategory": "adaptation",
                    "guid": "e6ac9a05-2739-4450-9ae8-a14cea5275ab"
                }
            ]
        }
    }
  8. I call Sync and in payload I see a bunch of extra updates.
    {
        "type": "sync",
        "requestId": 16605632403071,
        "tasks": {
            "added": [
                {
                    "parentIndex": 11,
                    "startDate": "2022-08-10T09:00:00+03:00",
                    "endDate": "2022-08-10T18:00:00+03:00",
                    "duration": 1,
                    "durationUnit": "day",
                    "cls": "",
                    "name": "Task1",
                    "calendar": null,
                    "direction": "Forward",
                    "manuallyScheduled": false,
                    "earlyStartDate": "2022-08-10T09:00:00+03:00",
                    "earlyEndDate": "2022-08-10T18:00:00+03:00",
                    "constraintType": null,
                    "constraintDate": null,
                    "percentDone": 0,
                    "inactive": null,
                    "lateStartDate": "2022-09-12T09:00:00+03:00",
                    "lateEndDate": "2022-09-12T18:00:00+03:00",
                    "critical": false,
                    "effort": 8,
                    "effortUnit": "hour",
                    "effortDriven": true,
                    "schedulingMode": "FixedDuration",
                    "baselines": [],
                    "parentId": "7130865572493721602",
                    "taskCostCategory": "adaptation",
                    "$PhantomId": "_generatedClassDefEx448"
                }
            ],
            "updated": [
                {
                    "id": "7130865572493721602",
                    "parentIndex": 0,
                    "startDate": "2022-08-10T09:00:00+03:00",
                    "endDate": "2022-09-12T18:00:00+03:00",
                    "duration": 24,
                    "durationUnit": "day",
                    "cls": "",
                    "name": "ExternalPlan",
                    "calendar": null,
                    "direction": "Forward",
                    "manuallyScheduled": false,
                    "earlyStartDate": "2022-08-10T09:00:00+03:00",
                    "earlyEndDate": "2022-09-12T18:00:00+03:00",
                    "constraintType": "startnoearlierthan",
                    "constraintDate": "2022-08-10T00:00:00+03:00",
                    "percentDone": 0,
                    "inactive": false,
                    "lateStartDate": "2022-08-11T00:00:00+03:00",
                    "lateEndDate": "2022-09-12T18:00:00+03:00",
                    "critical": true,
                    "effort": 96,
                    "effortUnit": "hour",
                    "effortDriven": false,
                    "schedulingMode": "Normal",
                    "expanded": true,
                    "baselines": [],
                    "parentId": null,
                    "keyMilestone": false,
                    "taskCostCategory": "adaptation",
                    "guid": "e6ac9a05-2739-4450-9ae8-a14cea5275ab"
                },
                {
                    "id": "7132064585628844033",
                    "parentIndex": 0,
                    "readOnly": true,
                    "startDate": "2022-08-10T09:00:00+03:00",
                    "endDate": "2022-08-10T18:00:00+03:00",
                    "duration": 1,
                    "durationUnit": "day",
                    "cls": "",
                    "name": "Новая задача",
                    "calendar": null,
                    "direction": "Forward",
                    "manuallyScheduled": true,
                    "earlyStartDate": "2022-08-10T09:00:00+03:00",
                    "earlyEndDate": "2022-08-10T18:00:00+03:00",
                    "constraintType": null,
                    "constraintDate": null,
                    "percentDone": 0,
                    "inactive": false,
                    "lateStartDate": "2022-09-08T09:00:00+03:00",
                    "lateEndDate": "2022-09-08T18:00:00+03:00",
                    "critical": false,
                    "effort": 8,
                    "effortUnit": "hour",
                    "effortDriven": true,
                    "schedulingMode": "FixedDuration",
                    "baselines": [],
                    "parentId": "7130865572493721605",
                    "guid": "c4f9213d-f208-4ca7-90ca-041ab1cd6ac8"
                },
                {
                    "id": "7132064585628844034",
                    "parentIndex": 1,
                    "readOnly": true,
                    "startDate": "2022-08-11T09:00:00+03:00",
                    "endDate": "2022-08-11T18:00:00+03:00",
                    "duration": 1,
                    "durationUnit": "day",
                    "cls": "",
                    "name": "Новая задача",
                    "calendar": null,
                    "direction": "Forward",
                    "manuallyScheduled": true,
                    "earlyStartDate": "2022-08-11T09:00:00+03:00",
                    "earlyEndDate": "2022-08-11T18:00:00+03:00",
                    "constraintType": null,
                    "constraintDate": null,
                    "percentDone": 0,
                    "inactive": false,
                    "lateStartDate": "2022-09-09T09:00:00+03:00",
                    "lateEndDate": "2022-09-09T18:00:00+03:00",
                    "critical": false,
                    "effort": 8,
                    "effortUnit": "hour",
                    "effortDriven": true,
                    "schedulingMode": "FixedDuration",
                    "baselines": [],
                    "parentId": "7130865572493721605",
                    "guid": "eacba114-b5de-4660-9f68-66f7c4138b54"
                },
                {
                    "id": "7132064585628844035",
                    "parentIndex": 2,
                    "readOnly": true,
                    "startDate": "2022-08-12T09:00:00+03:00",
                    "endDate": "2022-08-12T18:00:00+03:00",
                    "duration": 1,
                    "durationUnit": "day",
                    "cls": "",
                    "name": "Новая задача",
                    "calendar": null,
                    "direction": "Forward",
                    "manuallyScheduled": true,
                    "earlyStartDate": "2022-08-12T09:00:00+03:00",
                    "earlyEndDate": "2022-08-12T18:00:00+03:00",
                    "constraintType": null,
                    "constraintDate": null,
                    "percentDone": 0,
                    "inactive": false,
                    "lateStartDate": "2022-09-12T09:00:00+03:00",
                    "lateEndDate": "2022-09-12T18:00:00+03:00",
                    "critical": false,
                    "effort": 8,
                    "effortUnit": "hour",
                    "effortDriven": true,
                    "schedulingMode": "FixedDuration",
                    "baselines": [],
                    "parentId": "7130865572493721605",
                    "guid": "fec54def-054e-446e-9540-53e99e1b4240"
                }
            ]
        }
    }

Tell me who or what is saturating Sync Payload.


Post by tikhonov.a.p »

Just tried to use filtering in beforeSync as advised earlier
viewtopic.php?f=51&t=21905&p=108356#p108356

it's work, however, it has little effect. Parts of the package filtered in beforeSync remain in changes


Post by arcady »

Yes they do. So you want to revert particular changes?
If yes then Store has revertChanges. It reverts all not persisted changes made on the store.

The method code looks like this:

    revertChanges() {
        const
            me          = this,
            { changes } = me;

        if (changes) {
            const event = { action : 'clearchanges', changes };

            me.add(me.removed.values, true);
            me.remove(me.added.values, true);
            me.modified.forEach(r => r.revertChanges(true));

            me.added.clear();
            me.modified.clear();
            me.removed.clear();

            me.trigger('change', event);
            me.trigger('refresh', event);
        }
    }

And model class also has revertChanges

    revertChanges(silent = false) {
        this.set(this.meta.modified, _undefined, silent);
    }

Looking at the methods code you can make your own code that would revert only changes you need.


Post by tikhonov.a.p »

No, I don't want to undo (revert) the changes.

I would like CRUD operations on some tasks to be simply ignored by the sync system.

I'm trying to load the tasks of another project into the current one. I don't need them to be saved in the current one. All you need to do is tighten them up every time. But when I do a download from multiple sources, the current project starts counting them as "New"


Post by arcady »

Ok then instead of revertChanges please check acceptChanges methods. That will treat the changes as already applied.

PS on Model level the method name is clearChanges (not acceptChanges)


Post by tikhonov.a.p »

I use the commit method, which uses ApplyChanges under the hood and observe the picture described above


Post by arcady »

Regarding your initial question - project.changes is used when building the payload.
If you provide us w/ a test case reproducing the difference in a sync payload and project changes we'll investigate what's going on.


Post Reply