Skip to content

Commit

Permalink
[BUG FIX] handle unordered move (#4416)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrensiegel authored Nov 9, 2023
1 parent 75bfec3 commit d14246c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/oli_web/live/resources/pages_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ defmodule OliWeb.Resources.PagesView do

assign(socket,
ctx: ctx,
last_selected_slug: nil,
breadcrumbs: breadcrumb(project),
project_hierarchy: project_hierarchy,
project: project,
Expand Down Expand Up @@ -522,6 +523,8 @@ defmodule OliWeb.Resources.PagesView do
"""
end

socket = socket |> assign(last_selected_slug: slug)

{:noreply,
show_modal(
socket,
Expand Down Expand Up @@ -550,6 +553,27 @@ defmodule OliWeb.Resources.PagesView do
{:noreply, hide_modal(socket, modal_assigns: nil)}
end

def handle_event(
"MoveModal.move_item",
%{"to_uuid" => to_uuid},
socket
) do
%{
author: author,
project: project,
modal_assigns: %{hierarchy: hierarchy}
} = socket.assigns

# This handles the case where the page that was selected to be moved
# does not exist within the hierarchy.
revision = AuthoringResolver.from_revision_slug(project.slug, socket.assigns.last_selected_slug)
%{revision: to_container} = Hierarchy.find_in_hierarchy(hierarchy, to_uuid)

{:ok, _} = ContainerEditor.move_to(revision, nil, to_container, author, project)

{:noreply, hide_modal(socket, modal_assigns: nil)}
end

def handle_event("MoveModal.remove", %{"from_uuid" => from_uuid}, socket) do
%{
author: author,
Expand Down

0 comments on commit d14246c

Please sign in to comment.