Skip to content

Commit

Permalink
Merge branch 'build-ui-builder-with-live-svelte' of github.com:Beacon…
Browse files Browse the repository at this point in the history
…CMS/beacon_live_admin into build-ui-builder-with-live-svelte
  • Loading branch information
cibernox committed Dec 15, 2023
2 parents 9741cf3 + 901685a commit 56a95ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
12 changes: 10 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 @@ -87,6 +87,14 @@ defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
end
end

def handle_event("enable_visual_mode", _args, socket) do
{:noreply, assign(socket, visual_mode: true)}
end

def handle_event("disable_visual_mode", _args, socket) do
{:noreply, assign(socket, visual_mode: false)}
end

defp save_page(socket, :new, page_params) do
case Content.create_page(socket.assigns.site, page_params) do
{:ok, page} ->
Expand Down Expand Up @@ -135,8 +143,8 @@ defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
<%= @page_title %>
<:actions>
<.button :if={@live_action == :new} phx-disable-with="Saving..." form="page-form" class="uppercase">Create Draft Page</.button>
<.button :if={!@visual_mode} phx-click="enable_visual_mode" form="page-form" class="uppercase">Visual Editor</.button>
<.button :if={@visual_mode} phx-click="disable_visual_mode" form="page-form" class="uppercase">Code Editor</.button>
<.button :if={!@visual_mode} phx-click="enable_visual_mode" phx-target={@myself} form="page-form" class="uppercase">Visual Editor</.button>
<.button :if={@visual_mode} phx-click="disable_visual_mode" phx-target={@myself} form="page-form" class="uppercase">Code Editor</.button>
<.button :if={@live_action == :edit} phx-disable-with="Saving..." form="page-form" class="uppercase">Save Changes</.button>
<.button :if={@live_action == :edit} phx-click={show_modal("publish-confirm-modal")} phx-target={@myself} class="uppercase">Publish</.button>
</:actions>
Expand Down
15 changes: 0 additions & 15 deletions lib/beacon/live_admin/live/page_editor_live/new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@ defmodule Beacon.LiveAdmin.PageEditorLive.New do
{:noreply, socket}
end

@impl true
def handle_event("enable_visual_mode", _args, socket) do
socket = assign(socket, visual_mode: true)
path = Beacon.LiveAdmin.Router.beacon_live_admin_path(socket, socket.assigns.beacon_page.site, "/pages/new", %{visual_mode: "true"})
{:noreply, push_patch(socket, to: path)}
end

@impl true
def handle_event("disable_visual_mode", _args, socket) do
socket = assign(socket, visual_mode: false)
path = Beacon.LiveAdmin.Router.beacon_live_admin_path(socket, socket.assigns.beacon_page.site, "/pages/new")
{:noreply, push_patch(socket, to: path)}
end


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

0 comments on commit 56a95ec

Please sign in to comment.