Our state of the art Gantt chart


Post by ahmad.siddique »

Hi everyone,

I want to build custom logic and call functions for different actions performed through undo-redo.
For that, I want the values of the current and previous state of the action performed when undo or redo is pressed

I am using onRestoringStop on STM

gantt?.project?.stm?.on({
            restoringStop: onRestoringStop,
        });

and the data I am getting on undo-redo pressed is very ambiguous

Screenshot 2023-11-16 at 5.36.09 PM.png
Screenshot 2023-11-16 at 5.36.09 PM.png (260.79 KiB) Viewed 602 times

I am not sure how I can get the value of the current and previous state.


Post by marcio »

Hey,

Could you please clarify what you mean by "previous state"? Do you mean the last transactions?

As far as I understood, you can check https://bryntum.com/products/gantt/docs/api/Core/data/stm/StateTrackingManager#property-queue and then use https://bryntum.com/products/gantt/docs/api/Core/data/stm/StateTrackingManager#function-redo to go back to the state that you're looking for.

Best regards,
Márcio


Post by ahmad.siddique »

Thanks for the quick response,
Yes i mean last transactions, you got that part right.

The undo and redo is working perfectly fine, I want to get the values which are being undo and redo when undo or redo key is pressed so that i can save those values or perform related operations on backend.


Post by marcio »

Hey,

It seems that you can use a similar approach as we use to list the actions here https://bryntum.com/products/gantt/examples/undoredo/

Check the part that starts on

transaction.queue.map((action, idx) => {

Best regards,
Márcio


Post by ahmad.siddique »

I was trying to implement your solution but have an issue here.

For example, if I change the percent done of a task from the Gantt chart it logs around 30 - 40 transactions for this one event.
What I want is that there should be only one value in the queue so that I can send a request to the backend to change the value in the database.

As you can see in the screenshot attached below

Screenshot 2024-01-18 at 7.19.15 PM.png
Screenshot 2024-01-18 at 7.19.15 PM.png (254.08 KiB) Viewed 479 times

Post by marcio »

Hey,

So, in the case that you described, as the task is predecessor of others and it's also linked to Launch SaaS Product as a related task, changing the percent done of that task will trigger other updates of linked tasks, and that's the expected behavior (as if you have more percent done of the Configure firewall task, it'll be closer to complete the main task that's Launch SaaS Product).

But as you can see, they're all nested inside 1 and they are all related to that first update. I believe that's how is supposed to work with linked tasks.

What's your idea on that linked case scenario?

Best regards,
Márcio


Post by ahmad.siddique »

Yes, I understand that changing the percent done of one task will trigger change on other linked tasks as well. The thing here is that when I change the percent done on a task it adds 30 items in the queue that are just related to the task on which I am changing the percent done and not the linked tasks.

So for example if I have only one task in the whole project. and I changed its percent Done from 10% to 20% it will add 34 items in the queue each with a different percent Done value... All I want is to that only one item in the queue with the percent done value of 20 so that I can send a request to the backend with that value.

Is there any way I can know that the percentage was changed from 10 to 20 from that list of items?

Screenshot 2024-01-19 at 1.06.32 PM.png
Screenshot 2024-01-19 at 1.06.32 PM.png (222.84 KiB) Viewed 405 times

Post by kronaemmanuel »

Hey Ahmad,

Can you please share the code + steps you're doing? I'm unable to get the same behavior on our examples.

Best Regards,
Krona


Post by ahmad.siddique »

kronaemmanuel wrote: Fri Jan 19, 2024 11:05 am

Hey Ahmad,

Can you please share the code + steps you're doing? I'm unable to get the same behavior on our examples.

Best Regards,
Krona

https://bryntum.com/products/gantt/examples/undoredo/

  1. Visit this link
  2. remove all tasks except one
  3. change its percentage by 10 or 20
  4. expand the steps in the sidebar.

Post by kronaemmanuel »

Hey Ahmad,

I've opened an issue on github to track this: https://github.com/bryntum/support/issues/8302. Please subscribe to the issue for more updates.

Regards,
Krona


Post Reply