Our state of the art Gantt chart


Post by mrefaat »

Task 1.2.2 when outdented it sends update event for this task only without updating rest of below tasks ending in duplicate wbs
you can use this project : Outdent Issue

Attachments
Outdent Task.mp4
(1.37 MiB) Downloaded 10 times

Post by Maxim Gorkovsky »

Like in your other similar post, this error is caused by salesforce when you're trying to call Salesforce API. I don't know what is the problem there, however when looking at your event listeners I notices few things you should not do.

Here in the update listener, you take one field and assign it to another field, triggering another update and another handler.

getFlatTasks(records) {
        let flatTasks = [];
        for (let record of records) {
          record.wbs = record.wbsCode;// here
          flatTasks.push(record); //{id:record.id}
          if (record.children) {
            flatTasks.push(...this.getFlatTasks(record.children));
          }
          record.children = [];//and here
        }
        return flatTasks;
      }

// This method should be smth like this
getFlatTasks(records) {
        let flatTasks = [];
        for (let record of records) {
          const output = Object.assign({}, record, {
            wbs: record.wbsCode,
            children: []
          });
          flatTasks.push(output); //{id:record.id}
          if (record.children) {
            flatTasks.push(...this.getFlatTasks(record.children));
          }
        }
        return flatTasks;
      }

Post by mrefaat »

The problem was when i outdent a task let's say with wbs 1.2.1. The Gant should send update events for all tasks at level 1.2.x and 1.2 and 1 to update there wbs. This doesn't happen, so as a workaround i'm chaining those tasks and sending them for the update to database.


Post by Maxim Gorkovsky »

Do I understand correctly that you solved the problem?


Post by mrefaat »

My Solution is not very clen because i'm adding all the tasks of the project for an update.
So it does work now but ideally you should fix the update trigger to send the affected tasks


Post by Maxim Gorkovsky »

you should fix the update trigger to send the affected tasks

What do you mean by update trigger? By design, update event is triggered for every individual record update: https://bryntum.com/products/gantt/docs/api/Core/data/Store#event-update

If can use different API to get set of changes. hasChanges event to know when data is changed: https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#event-hasChanges and changes API to get set of changes from the project model: https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#property-changes

gantt.project.on({ hasChanges() {
  // read changes here, sync them
  sync(project.changes)
})

Post Reply