Skip to content

Commit

Permalink
fixup 6: outdent/indent functions for outline nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Sep 9, 2024
1 parent 78acee2 commit 4827525
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/radiator/outline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,6 @@ defmodule Radiator.Outline do
end
end

defp do_intend_node(_node, nil), do: {:error, :no_prev_node}

defp do_intend_node(node, prev_node) do
new_previous_id =
prev_node
|> order_child_nodes()
|> List.last()
|> get_node_id()

move_node(node.uuid, prev_id: new_previous_id, parent_id: prev_node.uuid)
{:ok, node}
end

@doc """
Moves a node to another parent.
Expand Down Expand Up @@ -495,6 +482,19 @@ defmodule Radiator.Outline do
end)
end

defp do_intend_node(_node, nil), do: {:error, :no_prev_node}

defp do_intend_node(node, prev_node) do
new_previous_id =
prev_node
|> order_child_nodes()
|> List.last()
|> get_node_id()

move_node(node.uuid, prev_id: new_previous_id, parent_id: prev_node.uuid)
{:ok, node}
end

defp parent_and_prev_consistent?(_, nil), do: true
defp parent_and_prev_consistent?(nil, _), do: true

Expand Down

0 comments on commit 4827525

Please sign in to comment.