On Scheduler Pro 4.0.0
This might be a bug around replacing resources, we're getting an id collision error. But I'm also messaging in the forum to ask if the way we're replacing resources is not good. Is there a better way than just removing and inserting at the same spot?
Minimal Reproduction:
const resourceStore = this.scheduleEngine.resourceStore;
const previous = [
{
id: '1',
name: '1',
},
{
id: '2',
name: '2',
children: [
{
id: '2-1',
name: '2-1',
},
],
},
{
id: '3',
name: '3',
},
];
const current = [
{
id: '1',
name: '1',
},
{
id: '2',
name: '2',
children: [
{
id: '2-1',
name: '2-1',
children: [
{
id: '2-1-1',
name: '2-1-1',
},
],
},
],
},
{
id: '3',
name: '3',
},
];
resourceStore.add(previous);
for (let i = 0; i < 3; i++) {
console.log(`removing ${previous[i].id}`);
resourceStore.remove(previous[i].id);
console.log(`adding ${current[i].id}`);
resourceStore.insert(i, current[i]);
}
}
logs
removing 1
adding 1
removing 2
adding 2
removing 3
adding 3
core.js:4352 ERROR Error: Id collision on 3
at ResourceStore.register (schedulerpro.module.js:27617)
at ClassDefEx.joinStore (schedulerpro.module.js:19657)
at ClassDefEx.joinStore (schedulerpro.module.js:99396)
at schedulerpro.module.js:16390
at Array.forEach (<anonymous>)
at schedulerpro.module.js:16388
at Array.forEach (<anonymous>)
at ClassDefEx.internalAppendInsert (schedulerpro.module.js:16386)
at ClassDefEx.insertChild (schedulerpro.module.js:16271)
at ResourceStore.insert (schedulerpro.module.js:22145)
Thank in advance