Hi,
I'm using SchedulerPro. I was trying to create an option in my "eventMenu" to change an event property from true to false and vice versa so I did this:
eventMenu: {
items: {
lockEvent: {
text: "Lock",
icon: "b-fa b-fa-fw b-fa-lock",
weight: 400,
onItem : ({ eventRecord }) => {
eventRecord.data.locked = true;
eventRecord.iconCls = 'b-fa b-fa-fw b-fa-lock';
}
},
unlockEvent: {
text: "Unlock",
icon: "b-fa b-fa-fw b-fa-lock-open",
weight: 400,
onItem : ({ eventRecord }) => {
eventRecord.data.locked = false;
eventRecord.iconCls = '';
}
},
},
processItems({ items, eventRecord }){
if(eventRecord.data.locked){
items.lockEvent.hidden = true,
items.unlockEvent.hidden = false
}
else {
items.lockEvent.hidden = false,
items.unlockEvent.hidden = true
}
},
}
The transition from true to false works properly, but the transition from false to true isn't: the action must be repeated twice in order for it to work because after the first false->true transition the value is set back to false after the onItem function completion.
I found this workaround:
lockEvent: {
text: "Lock",
icon: "b-fa b-fa-fw b-fa-lock",
weight: 400,
onItem : ({ eventRecord }) => {
eventRecord.data.locked = true;
eventRecord.iconCls = 'b-fa b-fa-fw b-fa-lock';
window.setTimeout(() =>{
console.log(eventRecord.data.locked)
eventRecord.data.locked = true;
}, 100) //setting the timeout to 0 didn't work
}
},
The problem seems to lie in something that happens after the commit because:
- I noticed that the problem vanishes if autoCommit and autoSync are disabled
- Moreover, maintaining autoCommit and autoSync to false, I tried manually calling the commit function in my code and observed that property value changes some time after the end of the call.
I attached a project sample. To reproduce the problem you need to load/commit the data from a server.