antoniandre / vue-cal-v4

A Vue.js full calendar, no dependency, no BS. :metal:
https://antoniandre.github.io/vue-cal-v4/
MIT License
1.25k stars 235 forks source link

v-model:events possible? #587

Closed NightFurySL2001 closed 1 month ago

NightFurySL2001 commented 2 months ago

It would certainly be more helpful to users if we can manage the full list of displayed events.

Right now v-model:events does not reflect newly-created events from @event-drag-create to user-defined variables, meaning that there is currently no way for users to remove a created event from the displayed calendar if not rejected in onEventCreate (which is quite performance intensive) unless refreshing :events.

This would certainly helps with #398 in the short term, where we can manually remove the event if certain criteria is violated.

antoniandre commented 1 month ago

Hi @NightFurySL2001 I understand what you say, and I guess you have seen the default delete button on click and hold of each event, but you're talking about programmatically removing some events at a specific time: a certain action that makes sense in your workflow. Vue Cal can't modify the external events given in props by Vue design, but it could emit that the list has changed. A v-model on the event sounds nice yes, it wasn't in the v4 for some reasons, but I'll see what I can do in the v5.

Currently in the v4 the way it works is that you completely control the array of events from outside and Vue Cal will repaint when it changes. On event create from drag, you should be able to store the delete function given in onEventCreate in the event or in your component and call it whenever. Usually a deletion would be triggered on a specific action, like on view change, or it can be onclick of the event or whatever, and the emitted events from vue-cal can help you get the event to delete if the action was on the event, or at least the date of that day by clicking a cell or on view change. then from there you can filter out the unwanted event from your externally handled list of events. You can also use the Date prototypes to manipulate dates and format them outside of Vue Cal

In the v5 it will definitely be easier. 👌