Issue
We are using the Scheduler
implementation of the CrudManager
where we are experiencing issues when checking the
CrudManager for changes.
this.scheduler.crudManager.changes;
A large % of attempts will resolve in no changes which will not proceed with our desired implementation. This affects:
- EventModel Create
- EventModel Edit
- EventModel Drag
- EventModel Resize
Even when attempting to use the following inbuilt event, occasionally the event is still not being hit.
crudManager.on('hasChanges', function (crud) {
// ... updateJob logic called here
});
Current Implementation
private async createCrudManager(): Promise<Partial<CrudManagerConfig>> {
const resourceStore = await this.generateResourceStore(this.schedulerEngineers, this.schedulerTeams);
const eventStore = await this.generateEventStore(this.schedulerJobs);
const assignmentStore = await this.generateAssignmentStore(false, eventStore);
return {
resourceStore,
eventStore,
assignmentStore,
};
}
this.scheduler = new Scheduler({
appendTo: this.host,
startDate,
endDate,
columns,
height,
crudManager,
...
})
Below is our implementation when we want to create or update an EventModel.
@Method()
public async updateJob(record: JobModel, job: Partial<Job>): Promise<void> {
const { assignmentStore } = this.scheduler;
// Prevent multiple commits from this flow.
assignmentStore.suspendAutoCommit();
// suspend scheduler refreshing
this.scheduler.suspendRefresh();
// If it was a provisional event, passed in here from drag-create or dblclick or contextmenu,
// it's now it's no longer a provisional event and will not be removed in the focusout handler
// Also, when promoted to be permanent, auto syncing will kick in if configured.
record.isCreating = false;
record.beginBatch();
for (const jobKey in job) {
record.set(jobKey, job[jobKey]);
}
record.endBatch();
const changes: CrudManagerChanges = this.crudManagerChanges;
if (changes) {
// ... Using the identified changes from the CrudManager, create patch documents to shape the payload the server requires.
// ... Emit Event to update Job
}
else {
// Revert changes, Reset the state management and redraw once
record.revertChanges();
assignmentStore.resumeAutoCommit();
await this.scheduler.resumeRefresh(true);
}