Skip to content

Commit

Permalink
Page Builder - enable the editor on New pages (#172)
Browse files Browse the repository at this point in the history
* Enable visual editor on new pages

* Improve structure metadata

* Allow users switching back to code editor

* Remove unused variable
  • Loading branch information
ChristianTovar committed Jul 12, 2024
1 parent bc786ab commit 7b55020
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 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 @@ -236,8 +236,10 @@ defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
<.header>
<%= @page_title %>
<:actions>
<.button :if={@live_action == :edit && @editor == "code" && @page.format == :heex} type="button" phx-click="enable_editor" phx-value-editor="visual" class="uppercase">Visual Editor</.button>
<.button :if={@live_action == :edit && @editor == "visual"} type="button" phx-click="enable_editor" phx-value-editor="code" class="uppercase">Code Editor</.button>
<.button :if={@live_action in [:new, :edit] && @editor == "code" && @page.format == :heex} type="button" phx-click="enable_editor" phx-value-editor="visual" class="uppercase">
Visual Editor
</.button>
<.button :if={@live_action in [:new, :edit] && @editor == "visual"} type="button" phx-click="enable_editor" phx-value-editor="code" class="uppercase">Code Editor</.button>
<.button :if={@live_action == :new} phx-disable-with="Saving..." form="page-form" class="uppercase">Create Draft Page</.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>
Expand Down
6 changes: 4 additions & 2 deletions lib/beacon/live_admin/live/page_editor_live/new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ defmodule Beacon.LiveAdmin.PageEditorLive.New do

defp build_new_page(site, [layout | _] = _layouts) do
%Beacon.Content.Page{
path: "",
path: "/New Page #{NaiveDateTime.utc_now()}",
site: site,
layout_id: layout.id,
layout: layout
layout: layout,
title: "New Page",
template: "<div>Welcome to BeaconCMS!</div>"
}
end

Expand Down

0 comments on commit 7b55020

Please sign in to comment.