Our state of the art Gantt chart


Post by rodel.ocfemia »

Hi,
The sync still not triggering. Please find my code below with just few modifications.
I tried to debug, the project is not null.

class customCycleResolutionPopup extends CycleResolutionPopup {
    async onApplyButtonClick() {
      const me = this as any,
        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
        { selectedResolutions } = me;

  let project: any;
  if (selectedResolutions.size) {
    // apply selected resolutions
    selectedResolutions.forEach((resolution: any) => {
      const resolutionParameters = me.getResolutionParameters(resolution);
      if (!project) {
        project = resolutionParameters[0].project;
      }
      return resolution.resolve(...resolutionParameters);
    });

    me.continueWithResolutionResult('Resume');

    me.doResolve(selectedResolutions);
    // calls sync
    await (project as typeof ProjectModel).sync();
  } else {
    me.onCancelButtonClick();
  }
}
  }

Post by tasnim »

Hi,

It is working for me here with your code just changed this

await (project as typeof ProjectModel).sync();

to

await (project as ProjectModel).sync();

as I'm testing with react typescript

msedge_ASNmCu05Bl.gif
msedge_ASNmCu05Bl.gif (896.27 KiB) Viewed 197 times

What version of Gantt are you using? Could you please provide a runnable test case so we can reproduce the issue here and debug it?

Best regards,
Tasnim


Post by rodel.ocfemia »

Hi,
If I do this

await (project as ProjectModel).sync();

it gives me this error. This happens only on our code, but not in your example code.

'ProjectModel' refers to a value, but is being used as a type here. Did you mean 'typeof ProjectModel'?ts(2749)

We are using the following version.

 "@bryntum/gantt": "5.5.2",
 "@bryntum/gantt-react": "5.5.2",

I have also reproduced the issue using your gantt basic sample code.

Scheduling Cycle2.zip
(2.24 MiB) Downloaded 48 times

This code is using the following, but still sync is not triggering.

await (project as ProjectModel).sync();

Post by tasnim »

Hi rodel.ocfemia,

I checked your application and I saw that you don't have https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#config-silenceInitialCommit silenceInitialCommit set to false. It is needed as the popup's result is going to be considered as initial commit.

Now you shouldn't need autSync set to true

I'm attaching your edited working app, please find it below.

Best regards,
Tasnim

Attachments
Scheduling Cycle2 Edited.zip
(2.09 MiB) Downloaded 49 times

Post by rodel.ocfemia »

Hi Tasnim,
If I remove autSync = true, several functionalities will be broken such as adding, updating and deleting dependencies. It will require us more time to check and update all functionalities that currently use autoSync feature.

Is upgrading to newer version can fix the issue without any code updates?


Post by tasnim »

Hi,

Ok, then maybe suspending the autoSync before clicking on the apply popup and resuming the autoSync after data calculations are finished, should help. Please find the edited app attached below

Docs
Listen for data calculations finished https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#event-dataReady
Suspend autoSync https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#function-suspendAutoSync
Resume autoSync https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#function-resumeAutoSync

Please let us know if that woks for you!

Best regards,
Tasnim

Attachments
Scheduling Cycle2 Edited 2.0.zip
(2.09 MiB) Downloaded 54 times

Post by rodel.ocfemia »

Hi Tasnim,
First of all, I need to keep autoSync: true to not break any existing functionalities because the issue we are trying to fix is for one user only. Turning off autoSync caused all other features to not work such as creating, deleting, updating dependencies.

I tried your latest code Scheduling Cycle2 Edited 2.0.zip then I put back the autoSync: true. On page load when bryntum detects scheduling cycle records, the sync was automatically triggered, then the Scheduling popup is also displayed. The autosync should not be triggered automatically on page load. It should trigger only when I clicked on Apply button on the Scheduling Cycle popup window.

How can we do this?
On page load, if has scheduling cycle then suspend autosync. Then On Apply button click on Scheduling Cycle popup, resume autosync.

Using the following config

autoSync: true, 
// silenceInitialCommit: false, //turn to true

Post by alex.l »

Hi,

When you loaded your data, the Engine do calculations of the project. It called initial commit. Usually, initial commit makes many changes on first data load, because the whole project are recalculated. Not all users want these changes be saved. That's why we created silenceInitialCommit. It's enabled by default.

In your case, a conflict found during initial calculations, so it cannot be finished until you make a decision and resolve a conflict. When conflict(s) resolved, initial calculations continued and finished. But all these changes are part of initial commit. You cannot split changes, because nothing is initially committed at the moment and all data is not commited.

Solution here is to disable silenceInitialCommit and commit changes. To split changes, you will need to manually find that exactly required, but there is no built-in methods I can suggest for that.

All the best,
Alex


Post by bhargav battula »

Hi Tasmin

On continue to above discussion, We have impleimented same kind of logic earlier based on bryntum support team suggestions viewtopic.php?p=121004&hilit=Swapna#p121004

Now its not working as expected and throwing error as per screenshot.

As per above suggestion you provided we are able to select and close popup wihout any issue but sync call not triggered so unable to remove data from backend.

Please suggest on how to trigger sync call when we click on apply.

Thanks

Attachments
Error.PNG
Error.PNG (119.24 KiB) Viewed 151 times

Post by rodel.ocfemia »

Hi Alex,
Disabling silenceInitialCommit is triggering sync automatically on page load when there is scheduling cycle records. The sync passes all dependency Ids even those with no scheduling cycle issue then this caused the backend to delete all dependency records.

The following code provided by Tasnim is almost working, except that the await (project as ProjectModel).sync() does not trigger the sync.

class customCycleResolutionPopup extends CycleResolutionPopup {
    async onApplyButtonClick() {
      const me = this as any,
        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
        { selectedResolutions } = me;

  let project: any;
  if (selectedResolutions.size) {
    // apply selected resolutions
    selectedResolutions.forEach((resolution: any) => {
      const resolutionParameters = me.getResolutionParameters(resolution);
      if (!project) {
        project = resolutionParameters[0].project;
      }
      return resolution.resolve(...resolutionParameters);
    });

    me.continueWithResolutionResult('Resume');

    me.doResolve(selectedResolutions);
    // calls sync
    console.log('before sync');

    await (project as ProjectModel).sync();
    console.log('after sync');
  } else {
    me.onCancelButtonClick();
  }
}
  }

Post Reply