Skip to content

Commit

Permalink
mix move_up
Browse files Browse the repository at this point in the history
  • Loading branch information
sorax committed Sep 9, 2024
1 parent 6cae557 commit 761e380
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions assets/js/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/radiator_web/live/outline_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 761e380

Please sign in to comment.