Button on before.blade.php when releasing an event, deletes it #19
Closed
jordivela007
started this conversation in
Ideas
Replies: 1 comment
-
|
I got it! in the before.blade.php i put this: <div ondragenter="onLivewireCalendarEventDragEnter(event, 'trash', '2000', 'border border-blue-400 border-4');"
ondragleave="onLivewireCalendarEventDragLeave(event, 'trash', '2000', 'border border-blue-400 border-4');"
ondragover="onLivewireCalendarEventDragOver(event);"
ondrop="onLivewireCalendarEventDropToTrash(event, 'trash', '2000', '2000', '0', '00', 'border border-blue-400 border-4');"
id="trash-2000" droppable="true">
<button type="button" title="{{ __('Delete') }}" class="btn btn-square btn-outline btn-primary">
<x-heroicon-o-trash />
</button>
</div>and in the blade template: <script>
function onLivewireCalendarEventDropToTrash(event, componentId) {
event.stopPropagation();
event.preventDefault();
let element = document.getElementById('trash-2000');
const eventId = event.dataTransfer.getData('id');
Livewire.dispatch('deleteEvent', {
uuid : eventId
});
}
</script>and in the component #[On('deleteEvent')]
public function deleteEvent(string $uuid)
{
$this->user = $uuid;
$event = Event::find($uuid);
$this->authorize('delete', $event);
$result = Event::where('id', $uuid)->delete();
if ($result) {
toast()
->success(__('Deleted Successfully') . ':' . $uuid, __('Event'))
->push();
} else {
toast()
->warning(__('Nothing to do'), __('Event'))
->push();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to create a button that supports to drop an event. But i didn't get it.
before.blade.php
Beta Was this translation helpful? Give feedback.
All reactions