vue-cal
vue-cal copied to clipboard
Forbid creating overlapping events
Hi, I want forbid overlapping events. I tried to figured out how to do it into the onEventCreate callback but don't find a way to check if a actually created event is overlapping with another. I there a way to access any function to check if the event is overlapping with another event? Thanks in advance
I have the same problem. How to prevent overlapping in event creation or event resizing? @antoniandre
tried minEventWidth: 100, it does not resize event, but overlap still there
You need to manually add code to check if the event is overlapping with another on onEventCreate. On your callback you will have access to the created event, if you defined your other events on your data() as events you access them with this.events. Then it is just an algorithmic problem of finding the overlaps. ~~This is a common problem in interview questions. TL;DR - IIRC the best way is to sort them by the ending time..~~ Actually in this case is much simpler since you only want to see with the newly created event overlaps so you do not need to sort or anything fancy just iterate sequentially through your events and check if they overlap with the newly created... It's just a single for-loop with one if clause inside.
If you do not mind adding extra dependencies and the overhead of copying data around you can use moment-range which supports the overlaps operation...
Thanks :) A parameter in vue-cal would also be nice @antoniandre ;-)
reported in #80 (2019) says that it's on the feature list, no ETA.
This is also indirectly related to #370 as in theory this problem could be solved by accepting/rejecting the resizing events to check for overlaps.
I also have the same problem. In my opinion overlapping should need to be enabled, not be the default behaviour and needing additional custom code to disable.
Has anyone already written the code to make this work and willing to share please? @Olli @crisclacerda @Spacarar @ChaerilM @hanifbirgani ?