Page 1 of 1

[INFO REQ] Creating project.changes from the StateTrackingManager

Posted: Fri Sep 23, 2022 12:45 pm
by dominicdolan

Hi,

I was wondering if there is a more custom way of creating the change aggregates similar to project.changes. It would be helpful if I could use the StateTrackingManager queue and create an aggregate of changes from that?

For example, if I made 10 changes to a gantt chart I would like to be able to get the changes that happened between change 4 and change 8. And have it structured in a similar way to project.changes.

If it's not possible, that's fine, I should be able to do it myself but if there is an existing method for it that would be even better.

Thanks


Re: [INFO REQ] Creating project.changes from the StateTrackingManager

Posted: Fri Sep 23, 2022 4:00 pm
by marcio

Hello dominicdolan,

If I understood correctly, are you looking for something like https://www.bryntum.com/docs/gantt/api/Core/data/stm/StateTrackingManager#property-queue??

Like the list that you have in our example here https://www.bryntum.com/examples/gantt/undoredo/


Re: [INFO REQ] Creating project.changes from the StateTrackingManager

Posted: Fri Sep 23, 2022 5:37 pm
by dominicdolan

Is that the project.stm.queue property? That always seems to be an array of null for me.

This is my project config, is there some other setting I'm missing?

const transactions: Array<Transaction> = []
let ganttLoaded = false
const projectConfig = {
    ...projectData,

    listeners: {
        dataReady() {
            if (!ganttLoaded) {
                const stm = ((gantt.value as any)?.project.instance.value as ProjectModel).stm

                stm.enable()
            }

            ganttLoaded = true
        },
        change(args: any) {
            // always a list of nulls
            console.log(args.source.stm.queue)
        }
    },
    stm: {
        autoRecord : true,
        listeners: {
            recordingstop(context: { transaction: Transaction, stm: StateTrackingManager }) {
                transactions.push(context.transaction)
            },
        }
    },
}

The way I am getting the list of transactions is similar to the undo/redo example, but it's difficult to aggregate that data

Thanks


Re: [INFO REQ] Creating project.changes from the StateTrackingManager

Posted: Fri Sep 23, 2022 7:58 pm
by emil

Hi dominicdolan,

We've been working on a Gantt feature that captures a change log. It uses STM behind the scenes. Please see the screenshot below - is this similar at all to what you're looking for?

Thanks,

Emil

Screen Shot 2022-09-23 at 10.37.22.png
Screen Shot 2022-09-23 at 10.37.22.png (41.68 KiB) Viewed 382 times

Re: [INFO REQ] Creating project.changes from the StateTrackingManager

Posted: Mon Sep 26, 2022 11:01 am
by dominicdolan

It could be useful. We don't actually need this for visualizing data. It's instead going to be used for persisting data. So we know what data needs to be persisted based on the changes that have happened since the last time data was saved.

I think that would just be a more reliable way of saving data.

I have mostly coded it up myself at this point, it wasn't too difficult.

Thanks


Re: [INFO REQ] Creating project.changes from the StateTrackingManager

Posted: Tue Sep 27, 2022 7:14 am
by emil

Great! Thanks for the update.