From 8557a2f7f0244521deb37158538f12551deeb3ed Mon Sep 17 00:00:00 2001 From: Chneemann Date: Thu, 14 Nov 2024 04:40:45 +0100 Subject: [PATCH] docs: add JSDoc comments to DragDropService --- src/app/services/drag-drop.service.ts | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/app/services/drag-drop.service.ts b/src/app/services/drag-drop.service.ts index 0558e7d..b104d5a 100644 --- a/src/app/services/drag-drop.service.ts +++ b/src/app/services/drag-drop.service.ts @@ -10,6 +10,17 @@ export class DragDropService { constructor() {} + /** + * This function is called when a drag event starts. + * + * It sets the `id` of the item being dragged to the `dataTransfer` object + * and emits an event indicating that the item has been moved from a certain + * status. + * + * @param event The drag event. + * @param id The id of the item being dragged. + * @param status The status of the item being dragged. + */ startDragging(event: DragEvent, id: string | undefined, status: string) { if (id !== undefined) { event.dataTransfer?.setData('text/plain', id); @@ -17,6 +28,16 @@ export class DragDropService { } } + /** + * Allows a drop event to occur by preventing the default handling of the event. + * + * This function is called during the dragover event to indicate that the dragged + * item can be dropped in the current target. It prevents the default behavior and + * emits an event indicating that the item is being moved to a specified status. + * + * @param event The drag event. + * @param status The status to which the item is being moved. + */ allowDrop(event: DragEvent, status: string) { event.preventDefault(); const dataTransfer = event.dataTransfer; @@ -25,6 +46,16 @@ export class DragDropService { } } + /** + * This function is called when the user drops an item that was being dragged. + * + * It prevents the default behavior of the drop event and emits an event + * indicating that the item has been dropped. It also emits an event indicating + * that the item has been moved to a certain status. + * + * @param event The drag event. + * @param status The status to which the item is being moved. + */ drop(event: DragEvent, status: string) { event.preventDefault(); const dataTransfer = event.dataTransfer;