Skip to content

Commit

Permalink
fix enable editor
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrocp committed Jan 17, 2025
1 parent 31fd651 commit 5ebd38c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
12 changes: 0 additions & 12 deletions lib/beacon/live_admin/live/page_editor_live/edit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ defmodule Beacon.LiveAdmin.PageEditorLive.Edit do
{:noreply, socket}
end

def handle_event("enable_editor", %{"editor" => editor}, socket) do
path =
Beacon.LiveAdmin.Router.beacon_live_admin_path(
socket,
socket.assigns.beacon_page.site,
"/pages/#{socket.assigns.page.id}",
%{editor: editor}
)

{:noreply, push_patch(socket, to: path)}
end

def handle_event(
"render_component_in_page",
%{"component_id" => component_id, "page_id" => page_id},
Expand Down
16 changes: 14 additions & 2 deletions lib/beacon/live_admin/live/page_editor_live/form_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,35 @@ defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
|> LiveMonacoEditor.set_value(template, to: "template")
|> assign_form(changeset)

path =
case socket.assigns.live_action do
:new -> "/pages/new"
:edit -> "/pages/#{socket.assigns.page.id}"
end

path =
Beacon.LiveAdmin.Router.beacon_live_admin_path(
socket,
socket.assigns.site,
"/pages/#{socket.assigns.page.id}",
path,
%{editor: "code"}
)

{:noreply, push_patch(socket, to: path)}
end

def handle_event("enable_editor", %{"editor" => "visual"}, socket) do
path =
case socket.assigns.live_action do
:new -> "/pages/new"
:edit -> "/pages/#{socket.assigns.page.id}"
end

path =
Beacon.LiveAdmin.Router.beacon_live_admin_path(
socket,
socket.assigns.site,
"/pages/#{socket.assigns.page.id}",
path,
%{editor: "visual"}
)

Expand Down
13 changes: 0 additions & 13 deletions lib/beacon/live_admin/live/page_editor_live/new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,6 @@ defmodule Beacon.LiveAdmin.PageEditorLive.New do
{:noreply, socket}
end

# FIXME: enable_editor sync template
def handle_event("enable_editor", %{"editor" => editor}, socket) do
path =
Beacon.LiveAdmin.Router.beacon_live_admin_path(
socket,
socket.assigns.beacon_page.site,
"/pages/new",
%{editor: editor}
)

{:noreply, push_patch(socket, to: path)}
end

@impl true
def handle_event(
"render_component_in_page",
Expand Down

0 comments on commit 5ebd38c

Please sign in to comment.