Premium support for our pure JavaScript UI components


Post by xbtc »

Hello,

we are using the React GANNT chart and implemented our own save logic by extending the ProjectModel class and implementing a custom sendRequest method:

class CDSProjectModel extends ProjectModel {

public async sendRequest(request: any): Promise<any> {
	// Custom save logic and communication with backend happens here
	// Send request is not called for changes to dependencies...
}
}

When the user makes changes to tasks the sendRequestMethod is triggered as we expect. However if a user does changes to dependencies (i.e. changing the lag of a dependency or setting it inactive, etc.) the sendRequest method is not triggered and thus we cannot persist the changes to the backend.

For debug purposes I also attached a listener to the dependency store by doing:

gantt.dependencyStore.on('change', (event) => {console.log("Dependency change: ", event})

On making changes to dependencies the 'change' event is triggered as expected. A sync or save via sendRequest of the ProjectModel is never triggered though.

I also tried setting gantt.dependencyStore.writeAllFields=true just in case.

Do we have to do some additional configuration? Is there anything we have to set up first in order for the ProjectModel sendRequest method to get triggered on changes to the dependency store's records?

I know this question is maybe not specific enough but would appreciate any hints as we are currently pretty lost in fixing this issue...

Many thanks in advance


Post by alex.l »

First of all, please check the next:

  • try to remove your override and see if original sendRequest will be called.
  • check if you used latest version of the product.
  • check if you use autoSync : true

I tried to add console.log() into original sendRequest and I see it called when I changed lag.
How exactly did you change lag when you see that problem?
Original sendRequest method contains around 110 lines of code and trigger some events, please be careful with overriding and review the code.

All the best,
Alex


Post by xbtc »

Hi Alex - thank you very much for your reply.

Yes we are using the latest version (5.0.5), autoSync is true and the original sendRequest method also does not get called when changing the lag.

I change the lag the following way: Let's say the predecessor column currently contains "3+2d" (which means task three plus 3 days) i try to change it to "3+5d".

I think I am getting closer to the source of the issue though. For the dependency model we use we do the following to map our data fields:

class CDSDependencyModel extends DependencyModel {
	static get fields(): any[] {
		return [
			{ name: ENTITY_CONFIG.dependencyIdField, dataSource: ENTITY_CONFIG.dependencyIdField },
			{ name: 'fromEvent', dataSource: '_tpg_predecessortask_value' },
			{ name: 'toEvent', dataSource: '_tpg_successortask_value' },
			// If the following line is commented out everything behaves as expected
			{ name: 'lag', dataSource: 'tpg_lag' },
			{ name: 'lagUnit', dataSource: 'tpg_lagunit' },
			{ name: 'fromSide', dataSource: 'tpg_fromside' },
			{ name: 'toSide', dataSource: 'tpg_toside' },
			{ name: 'type', dataSource: 'tpg_type', type: 'number', defaultValue: 2 },
			{ name: 'active', dataSource: 'tpg_active' },
		];
	}
}

If I comment out the mapping of lag to our data field 'tpg_lag' an update and sendRequest is triggered on changing the lag for a task.

If the lag field is mapped to dataSource 'tpg_lag', the value of field "tpg_lag" of the record in the dependency store is updated correctly on user input, however the GANTT UI does not show the change and sendRequest ist also not triggered.

Do we do anything wrong here concerning the mapping?


Post by xbtc »

One more general question: You say we should be careful to override sendRequest. Is there another preferred approach to connect the GANTT component to a custom backend?


Post by mats »

Opened issue for the bug you found: https://github.com/bryntum/support/issues/4759


Post by xbtc »

Thanks for logging the bug. Just wanted to add that this issue does not only occur for the lag field, but also for example for the "active" field. I suspect it affects all mapped dependency fields...


Post by alex.l »

Thank's for your note, I've updated the ticket with this information.

One more general question: You say we should be careful to override sendRequest. Is there another preferred approach to connect the GANTT component to a custom backend?

Not sure what is custom backend. If you want to change data format before send it to server as well as adjust them before apply a response, we have events:
https://bryntum.com/docs/gantt/api/Gantt/model/ProjectModel#event-beforeSend

Fires before a request is sent to the server.

crudManager.on('beforeSend', function ({ params, type, requestConfig }) {
    // let's set "sync" request parameters
    if (type == 'sync') {
        // dynamically depending on "flag" value
        if (flag) {
            params.foo = 'bar';
        }
        else {
            params.foo = 'smth';
        }
    }
    
// check requestConfig to apply changes on request });

https://bryntum.com/docs/gantt/api/Gantt/model/ProjectModel#event-beforeResponseApply

Fires before server response gets applied to the stores. Return false to prevent data applying. This event can be used for server data preprocessing. To achieve it user can modify the response object.

beforeResponseApply has an access to response object, check params.

All the best,
Alex


Post by xbtc »

Thanks alot for elaborating Alex. I think we will switch to using events sometime in the future. Looks cleaner to me than overriding the sendRequest method.

Concerning the bug: It is really critical to us, as our customers currently cannot save changes made to task dependencies and thus generate a lot of support tickets. When can we roughly expect a fix?


Post by tasnim »

Sorry, I can't say anything about that yet. But, you should track the ticket to see when there is progress on it


Post by xbtc »

Dear tasnim,

we are using Bryntum products in a real world scenario with real customers where our reputation is on the line. We are talking about functionality which was already working in the past and seems to be broken now.

Therefore we would expect a rough estimate on when a fix will be available as we cannot communicate to our customers "we don't know". Even if you tell us it takes you several month we could live with that and implement a workaround. I therefore kindly ask you to provide a rough timeline on when we can expect a fix.


Post Reply