You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chuckn0rris opened this issue
Mar 10, 2023
· 2 comments
Assignees
Labels
bugSomething isn't workingforumIssues from forumlarge-accountReported by large customerOEMOEM customerpremiumresolvedFixed but not yet released (available in the nightly builds)
Hello,
we recently figured out the rootcause for a problem we were having in our gantt solution. We implement the CrudManger to communicate with our remote backend (autoSync is enabled). So after each sync we get back the actual record ids to unphantom added records. We had the same issue as described in #4935 even tough we were using a version that included the fix for that. We made a workaround which overrode the the "id" field getter of the "Location" class. This only partly solved random issues we were having which now turned out to be related to the "selectedRecordsCollection" of the gantt.
After debugging for a good amount of time, we figured out, that the "idChange" event in the task store was never fired. The "onModelChange" method in the Store class get's called twice when adding a record. First with the initial data and an assinged phantom id and a second time when the sync respone has been applied and an "id" has been provided. The problem seems to be logic in the method "onModelChange" of the class "ChronoPartOfProjectStoreMixin" that overrides the "silent" arugment which than gets passed to the "Store" instance "onModelChange" method. In the "Store.onModelChange" the "idChange" event is only fired, if silent is not "false". Since the argument is overriden to "true", the event is not fired when a record "id" has been proviced in the sync application. This results in a bunch of things not happening that are listening to that event, like rebuilding selection indicies and the bugfix mentioned above.
We have worked around this with an override of the "Store.onModelChange" as following which solves our problem:
const anyStore = Store as any;
const originalOnModelChange = anyStore.prototype.onModelChange;
anyStore.prototype.onModelChange = function onModelChange(
this: Store,
record: Model,
toSet: ToSetDict,
wasSet: ToSetDict,
silent: boolean,
fromRelationUpdate: boolean
) {
// Call original method
originalOnModelChange.call(this, record, toSet, wasSet, silent, fromRelationUpdate);
if (silent && 'id' in wasSet) {
const { oldValue, value } = toSet.id;
this.trigger('idChange', {
store: this,
record,
oldValue,
value,
});
}
};
Since none of the online examples have a remote backend, we couldn't easily validate, if the behaviour also happens in an example. Since the PHP sample is the only sample with a remote backend and requires local installation of dependencies, we couldn't test it due to time constraints.
I hope this is enough inforation for you guys to investigate this. It's important to use a remote backend for properly check this. Running the PHP sample locally and debugging according to the above insturctions should show the issue.
The text was updated successfully, but these errors were encountered:
Considering the code this happens if a record has changed both its id and some other field served by the Engine.
Test case for the issue:
t.it('Should trigger idChange when responding it from the server together w/ some other Engine handled field',asynct=>{t.mockUrl('load',{responseText : {tasks : {rows : [{id : 1,name : 'Task',startDate : '2023-03-10',duration : 1}]}}});constproject=newProjectModel({loadUrl : 'load',syncUrl : 'sync'});t.firesOnce(project.eventStore,'idChange');awaitproject.load();t.notOk(project.getChangesetPackage(),'No data in set package exists before sync');const[newTask]=project.eventStore.add({name : 'Task 2',duration : 1});t.mockUrl('sync',{responseText : {tasks : {rows : [{$PhantomId : newTask.id,id : 2,duration : 2}]}}});awaitproject.sync();t.is(newTask.get('id'),2,'id has been successfully updated');t.is(newTask.get('endDate'),newDate(2023,2,12),'End date has been successfully updated');project.destroy();});
bugSomething isn't workingforumIssues from forumlarge-accountReported by large customerOEMOEM customerpremiumresolvedFixed but not yet released (available in the nightly builds)
Forum post
Hello,
we recently figured out the rootcause for a problem we were having in our gantt solution. We implement the CrudManger to communicate with our remote backend (autoSync is enabled). So after each sync we get back the actual record ids to unphantom added records. We had the same issue as described in #4935 even tough we were using a version that included the fix for that. We made a workaround which overrode the the "id" field getter of the "Location" class. This only partly solved random issues we were having which now turned out to be related to the "selectedRecordsCollection" of the gantt.
After debugging for a good amount of time, we figured out, that the "idChange" event in the task store was never fired. The "onModelChange" method in the Store class get's called twice when adding a record. First with the initial data and an assinged phantom id and a second time when the sync respone has been applied and an "id" has been provided. The problem seems to be logic in the method "onModelChange" of the class "ChronoPartOfProjectStoreMixin" that overrides the "silent" arugment which than gets passed to the "Store" instance "onModelChange" method. In the "Store.onModelChange" the "idChange" event is only fired, if silent is not "false". Since the argument is overriden to "true", the event is not fired when a record "id" has been proviced in the sync application. This results in a bunch of things not happening that are listening to that event, like rebuilding selection indicies and the bugfix mentioned above.
We have worked around this with an override of the "Store.onModelChange" as following which solves our problem:
Since none of the online examples have a remote backend, we couldn't easily validate, if the behaviour also happens in an example. Since the PHP sample is the only sample with a remote backend and requires local installation of dependencies, we couldn't test it due to time constraints.
I hope this is enough inforation for you guys to investigate this. It's important to use a remote backend for properly check this. Running the PHP sample locally and debugging according to the above insturctions should show the issue.
The text was updated successfully, but these errors were encountered: