Premium support for our pure JavaScript UI components


Post 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


Post 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/

Best regards,
Márcio


Post 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


Post 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 243 times

Post 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


Post by emil »

Great! Thanks for the update.


Post Reply