Hi Dev Team,
In our project, We have shared the project data between Gantt and Scheduler Pro. In the process, we are trying to commit eventStore for which we are using the following code
project.eventStore.commit()
I have attached the screenshot of the issue I am getting. How to fix this issue?
Hi Dev Team,
The data of the individual stores are loaded using axios. Now I'm trying to commit the individual stores, but when I try to commit the event store I'm getting the following issue "this.eventStore.getResourcesForEvent is not a function".
This is how i have loaded the data
componentDidMount() {
console.log("panel mounted");
let me = this,
{
current: container
} = this.containerRef,
project = (window.project = new ProjectModel(projectConfig));
axios.get("datasets/tasks.json").then((result) => {
let stores = [
"dependencyStore",
"assignmentStore",
"eventStore",
"resourceStore",
"calendarManagerStore",
"timeRangeStore",
],
storesLoaded = {
tasks: false,
dependencies: false,
assignments: false,
resources: false,
calendars: false,
timeRanges: false,
};
stores.forEach((storeName) => {
let store = project[storeName],
storeId = store.id;
store.clear();
let onAdd = function() {
console.log("add", arguments);
storesLoaded[storeId] = true;
let allStoresLoaded = true;
for (var i in storesLoaded) {
allStoresLoaded = allStoresLoaded &&
storesLoaded[i];
}
if (allStoresLoaded) {
project.load().then(() => {
project.stm.enable();
project.stm.autoRecord =
true;
project.stm
.resetQueue();
project.resourceStore
.commit();
project.eventStore
.commit();
});
}
store.un("add", onAdd);
};
store.on("add", onAdd);
});
stores
.slice()
.reverse()
.forEach((storeName) => {
let store = project[storeName],
storeId = store.id;
store.add(result.data[storeId].rows);
store.trigger("load", {
data: result.data[storeId].rows
});
});
});
me.gantt = window.gantt = new Gantt({
...ganttConfig,
project,
});
}
We would need a showcase that we can run, investigate and debug to know the reason for that specific error you're getting.
However, the approach seems to be too complicated because you need to take care of the order of stores for load and commit. We already have methods for handling the data of whole project so we recommend to utilize them: