Scheduler - In Month view , not bale to create event because of collision=true

Hi,

I am using angular app with dhmlx scheduler 6.0.4 (latest npm package).
I have set collision plugin as true in config to prevent creating events in the same time. So , whats happening is, if I go to a month view and create an event ( with the default start and end date , which is 12:00 - 12:05. basically not changing anything in the lightbox values), it creates an event. Then again if I click the same date to create another event for a diff slot, the lightbox does not even open because it tries to open with the default startdate/enddate and an event already exists there. So this is not letting me to create event in any other time slot. I was able to reproduce this in one of your sample also.

https://docs.dhtmlx.com/scheduler/samples/03_extensions/15_collision.html

Hello @rajeswarij,

Looks like an issue in the logic of the collision plugin, thank you for noticing it. It happens, because scheduler already creates an event, when the lightbox for a new event appears(and deletes it, when you click cancel button). So plugin blocks lightbox from appear. I sent a request to the dev team, and they will work on a fix.

In case of month view, you can use a workaround, the logic could be to disable collision check for the “month” mode for new events, with onEventCreated and onEventCollision events.

The code may look like follows:

scheduler.attachEvent("onEventCreated", function(id,ev){
    let mode = scheduler.getState().mode; 
    if(mode == "month"){
        let event = scheduler.getEvent(id)
        event.disableCollisionCheck = true;
    }
});

scheduler.attachEvent("onEventSave",function(id,ev,is_new){
    let mode = scheduler.getState().mode; 
    if(mode == "month" && ev.disableCollisionCheck){
        // remove the unnecessary property
        ev.disableCollisionCheck = false;
    }
    return true;
})

scheduler.attachEvent("onEventCollision", function (ev, evs){
    let mode = scheduler.getState().mode; 
    if(mode == "month" && ev.disableCollisionCheck){ 
        return false;
    } else {
        alert("The time is occupied")
        return true;
    }
});

Here is a demo:
https://snippet.dhtmlx.com/um5co1bn

It’s a workaround, and it’s quite untested, so you will find some issues in its work, please notify me.

Best regards,

Hi Siarhei,

Thanks for the workaround code. Will try to use this and see. Anyway, do you have any ETA for when fix will be available for this issue?

Hi @rajeswarij,

Unfortunately, there is no ETA, but I will post here any updates on this issue.

Kind regards,

1 Like