From 761e3808135c3f95142bac40081fa88df862347c Mon Sep 17 00:00:00 2001 From: sorax Date: Mon, 9 Sep 2024 09:33:34 +0200 Subject: [PATCH] mix move_up --- assets/js/hooks/index.ts | 9 +++++---- lib/radiator_web/live/outline_component.ex | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/assets/js/hooks/index.ts b/assets/js/hooks/index.ts index d9ada6bb..c6c50d0e 100644 --- a/assets/js/hooks/index.ts +++ b/assets/js/hooks/index.ts @@ -15,10 +15,11 @@ export const Hooks = { }); this.handleEvent("move_node", ({ uuid, parent_id, prev_id }) => { - // const node = getItemById(uuid)!; - // setNodeAttribute(node, "parent", parent_id); - // setNodeAttribute(node, "prev", prev_id); - // const x = moveNode(node); + const node = getItemById(uuid)!; + setAttribute(node, "parent", parent_id); + setAttribute(node, "prev", prev_id); + + moveNode(node); }); this.el.addEventListener("keydown", (event) => { diff --git a/lib/radiator_web/live/outline_component.ex b/lib/radiator_web/live/outline_component.ex index e23401ad..40ed047e 100644 --- a/lib/radiator_web/live/outline_component.ex +++ b/lib/radiator_web/live/outline_component.ex @@ -207,17 +207,17 @@ defmodule RadiatorWeb.OutlineComponent do defp generate_event_id(id), do: Ecto.UUID.generate() <> ":" <> id defp move_up(socket, uuid, prev_id) do - %{uuid: prev_uuid, parent_id: prev_parent_id} = NodeRepository.get_node!(prev_id) + %{parent_id: prev_parent_id, prev_id: prev_prev_id} = NodeRepository.get_node!(prev_id) user_id = socket.assigns.user_id Dispatch.move_node(uuid, user_id, generate_event_id(socket.id), parent_id: prev_parent_id, - prev_id: prev_uuid + prev_id: prev_prev_id ) socket - |> push_event("move_node", %{uuid: uuid, parent_id: prev_parent_id, prev_id: prev_uuid}) + |> push_event("move_node", %{uuid: uuid, parent_id: prev_parent_id, prev_id: prev_prev_id}) end defp move_down(socket, _uuid, _prev_id) do