Skip to content

Commit

Permalink
This does nothing yet, but the UI works
Browse files Browse the repository at this point in the history
  • Loading branch information
cibernox committed Jan 17, 2025
1 parent b7a437e commit 840b738
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
selectedAstElementId,
parentOfSelectedAstElement,
grandParentOfSelectedAstElement,
parentSelectedAstElementId,
grandParentSelectedAstElementId,
} from "$lib/stores/page"
import { findHoveredSiblingIndex, getBoundingRect, getDragDirection, type Coords } from "$lib/utils/drag-helpers"
import { live } from "$lib/stores/live"
Expand Down Expand Up @@ -168,7 +170,7 @@
}
function applyNewOrder() {
let parent = isParent ? $grandParentOfSelectedAstElement : $parentOfSelectedAstElement
let [parent, parentId] = isParent ? [$grandParentOfSelectedAstElement, $grandParentSelectedAstElementId] : [$parentOfSelectedAstElement, $parentSelectedAstElementId]
if (newIndex !== null && newIndex !== dragElementInfo.selectedIndex && !!parent) {
// Reordering happened, apply new order
Expand All @@ -188,9 +190,10 @@
parts[parts.length - 1] = newSelectedIndex.toString()
$selectedAstElementId = parts.join(".")
}
$pageAst = [...$pageAst]
// $pageAst = [...$pageAst]
// Update in the server
$live.pushEvent("update_page_ast", { id: $pageInfo.id, ast: $pageAst })
$live.pushEvent("update_page_node", { id: $pageInfo.id, node_id: parentId, node: parent })
// $live.pushEvent("update_page_ast", { id: $pageInfo.id, ast: $pageAst })
}
}
Expand Down
6 changes: 6 additions & 0 deletions lib/beacon/live_admin/live/page_editor_live/edit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ defmodule Beacon.LiveAdmin.PageEditorLive.Edit do

{:noreply, socket}
end

def handle_event("update_page_node", %{"node_id" => node_id, "node" => node}, socket) do

Check warning on line 58 in lib/beacon/live_admin/live/page_editor_live/edit.ex

View workflow job for this annotation

GitHub Actions / test: OTP 25.1 | Elixir 1.14.0 | Phoenix 1.7.0 | LV 0.20.2 | PG 13.0-alpine

variable "node" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 58 in lib/beacon/live_admin/live/page_editor_live/edit.ex

View workflow job for this annotation

GitHub Actions / test: OTP 25.1 | Elixir 1.14.0 | Phoenix 1.7.0 | LV 0.20.2 | PG 13.0-alpine

variable "node_id" is unused (if the variable is not meant to be used, prefix it with an underscore)
# TODO: update the ast node

{:noreply, socket}
end

def handle_event(
"render_component_in_page",
Expand Down

0 comments on commit 840b738

Please sign in to comment.