Our pure JavaScript Scheduler component


Post by eugenem »

I've initialized STM like this, and undo/redo seems to work fine. But one strange thing: after events are loaded the first time, I get the option to undo, which removes all events. I definitely don't want to undo the initial load...

    this.projectModel = new ProjectModel({
      stm: {
        autoRecord: true,
        disabled: false
      },
      resourceStore: {
        // Add some custom fields
        groupers: [
          // type could be 'Machines', 'Operators', etc
          { field: 'type', ascending: true }
        ]
      },
      eventStore: {
        // Add a custom field and redefine durationUnit to default to hours
        //fields: ['dt', { name: 'durationUnit', defaultValue: 'hour' }]
        fields: ['companyId']
      },
      autoLoad: true,
      autoSync: true,
      phantomIdField: 'phantomId',
      transport: {
        load: {
          url: '/api/Scheduler/GetB',
          headers: {
            'Authorization': `Bearer ` + token
          },
        },
        sync: {
          url: '/api/Scheduler/SaveB',
          headers: {
            'Authorization': `Bearer ` + token
          },
        }
      },
      listeners: {
        sync: () => {
          this.loadProject();
        }
      }
    });

Post by saki »

Would you please create a runnable showcase? We would need it to investigate and debug.

FYI: STM is enabled here https://bryntum.com/examples/gantt/frameworks/angular/advanced/dist/advanced/index.html w/o the initial undo.


Post by eugenem »

Well, I don't have gantt examples. Is there angular example with undo?


Post by saki »

Yes, the above is Angular example. We do not have it for Scheduler, only for Gantt, but you can always download trial version which contains the complete sources of the example code. Also, the approach would be same because https://bryntum.com/docs/gantt/#Core/data/stm/StateTrackingManager is a core class that is used both in Scheduler and Gantt.


Post by eugenem »

Couldn't compile Gantt sample, something with node-sass. I see that the difference in your config is that you don't set

stm: { disabled: false }

I've tried to comment it at my config, and stm stopped working. I also check it at runtime, and it's indeed disabled. How is it supposed to enable itself?


Post by Maxim Gorkovsky »

You can enable STM using API: https://bryntum.com/docs/scheduler/#Core/data/stm/StateTrackingManager#function-enable

project.stm.enable()

I should note that Scheduler/model/ProjectModel cannot load data using transport layer. This feature starts from SchedulerPro/model/ProjectModel. And pro project should handle initial commit.
Which project do you actually use? Do you also use crud manager? Are there any more places in your code which load/populate the project with data?


Post by eugenem »

I've got SchedulerPro, so the project supports crud and other stuff.

How do I know when the initial load happed to enable stm?


Post by saki »

There is also scheduler example (https://bryntum.com/examples/scheduler/undoredo/) and that doesn't do anything special to enable the STM:

    project : {
        stm : {
            autoRecord : true
        }
    // ...

however, it uses CrudManager that takes care of the initial population of stores. If you use another method then you need to enable STM after you initially populate the stores. So you just enable it after you shall populate the stores in your code.


Post by eugenem »

I'm using CRUd as well, you can see it in the first message. I don't do anything else related to sync...


Post by alex.l »

Hi eugenem,

Could you kindly attach a runnable test case here, we should be able to reproduce the problem you described to help you with that.

All the best,
Alex

All the best,
Alex


Post Reply