complete editor panel reorganisation polish
All checks were successful
deploy / deploy (push) Successful in 6m49s
All checks were successful
deploy / deploy (push) Successful in 6m49s
- fix Site tab not loading theme state on direct URL navigation - fix nav editor showing "Custom URL" for page links (detect by URL match) - add Home option to nav page picker - mark editor-reorganisation plan as complete - add dynamic-url-customisation and draft-publish-workflow plans Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -622,6 +622,17 @@ defmodule BerrypodWeb.ShopComponents.SiteEditor do
|
||||
attr :event_prefix, :string, default: "site_"
|
||||
|
||||
defp nav_editor(assigns) do
|
||||
# Build a set of known page URLs for quick lookup
|
||||
page_urls =
|
||||
Enum.flat_map(assigns.pages, fn page ->
|
||||
[page.slug, "/#{page.slug}"]
|
||||
end)
|
||||
|> MapSet.new()
|
||||
|> MapSet.put("/collections/all")
|
||||
|> MapSet.put("/")
|
||||
|
||||
assigns = assign(assigns, :page_urls, page_urls)
|
||||
|
||||
~H"""
|
||||
<div class="site-editor-nav-list">
|
||||
<ul :if={@items != []} class="site-editor-nav-items">
|
||||
@@ -630,6 +641,10 @@ defmodule BerrypodWeb.ShopComponents.SiteEditor do
|
||||
class="site-editor-nav-item"
|
||||
data-item-id={item.id}
|
||||
>
|
||||
<%
|
||||
# Determine if this item links to a known page (by URL match or page_id)
|
||||
is_page_link = item.page_id != nil or MapSet.member?(@page_urls, item.url)
|
||||
%>
|
||||
<form
|
||||
class="site-editor-nav-item-form"
|
||||
phx-change={@event_prefix <> "update_nav_item"}
|
||||
@@ -651,10 +666,10 @@ defmodule BerrypodWeb.ShopComponents.SiteEditor do
|
||||
class="admin-select admin-select-sm site-editor-nav-type"
|
||||
aria-label="Link type"
|
||||
>
|
||||
<option value="page" selected={item.page_id != nil}>Page</option>
|
||||
<option value="url" selected={item.page_id == nil}>Custom URL</option>
|
||||
<option value="page" selected={is_page_link}>Page</option>
|
||||
<option value="url" selected={not is_page_link}>Custom URL</option>
|
||||
</select>
|
||||
<%= if item.page_id != nil or (item.url == "" and @pages != []) do %>
|
||||
<%= if is_page_link or (item.url == "" and @pages != []) do %>
|
||||
<select
|
||||
name={"nav_item[#{item.id}][page_id]"}
|
||||
class="admin-select admin-select-sm site-editor-nav-page"
|
||||
@@ -662,6 +677,9 @@ defmodule BerrypodWeb.ShopComponents.SiteEditor do
|
||||
>
|
||||
<option value="">Select a page</option>
|
||||
<optgroup label="Pages">
|
||||
<option value="/" selected={item.url == "/" or item.url == "home"}>
|
||||
Home
|
||||
</option>
|
||||
<option
|
||||
:for={page <- @pages}
|
||||
value={page.slug}
|
||||
|
||||
@@ -173,7 +173,10 @@ defmodule BerrypodWeb.PageEditorHook do
|
||||
if socket.assigns.site_editing do
|
||||
socket
|
||||
else
|
||||
load_site_state(socket)
|
||||
# Site tab uses branding settings from theme, so load theme state too
|
||||
socket
|
||||
|> maybe_enter_theme_mode()
|
||||
|> load_site_state()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -305,9 +305,9 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
{if @editor_live_region_message, do: @editor_live_region_message}
|
||||
</div>
|
||||
|
||||
<%!-- Page settings for custom pages --%>
|
||||
<%!-- Page settings (custom and system pages, not product/collection) --%>
|
||||
<.page_settings_section
|
||||
:if={@page[:type] == "custom"}
|
||||
:if={@page[:type] in ["custom", "system"]}
|
||||
page={@page}
|
||||
form={@settings_form}
|
||||
dirty={@settings_dirty}
|
||||
@@ -364,7 +364,7 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
"""
|
||||
end
|
||||
|
||||
# Page settings section for custom pages (collapsible)
|
||||
# Page settings section (collapsible) for custom and system pages
|
||||
attr :page, :map, required: true
|
||||
attr :form, :map, default: nil
|
||||
attr :dirty, :boolean, default: false
|
||||
@@ -372,9 +372,11 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
|
||||
defp page_settings_section(assigns) do
|
||||
form = assigns.form || %{}
|
||||
is_custom = assigns.page[:type] == "custom"
|
||||
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:is_custom, is_custom)
|
||||
|> assign(:form_title, form["title"] || assigns.page.title || "")
|
||||
|> assign(:form_slug, form["slug"] || assigns.page.slug || "")
|
||||
|> assign(:form_meta, form["meta_description"] || assigns.page.meta_description || "")
|
||||
@@ -420,8 +422,10 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
id="page-settings-slug"
|
||||
name="page[slug]"
|
||||
value={@form_slug}
|
||||
class="admin-input"
|
||||
class={["admin-input", !@is_custom && "admin-input-disabled"]}
|
||||
pattern="[a-z0-9-]+"
|
||||
disabled={!@is_custom}
|
||||
title={if !@is_custom, do: "System page URLs cannot be changed", else: nil}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -437,7 +441,8 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
>{@form_meta}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="page-settings-checks">
|
||||
<%!-- Published and nav options only for custom pages --%>
|
||||
<div :if={@is_custom} class="page-settings-checks">
|
||||
<label class="admin-check-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -461,7 +466,7 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div :if={@form_show_in_nav} class="page-settings-nav-options">
|
||||
<div :if={@is_custom && @form_show_in_nav} class="page-settings-nav-options">
|
||||
<div class="page-settings-field page-settings-field-inline">
|
||||
<label class="page-settings-label" for="page-settings-nav-label">Nav label</label>
|
||||
<input
|
||||
@@ -708,7 +713,17 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
<.quantity_selector quantity={assigns[:quantity] || 1} in_stock={@product.in_stock} />
|
||||
|
||||
<p
|
||||
:if={assigns[:selected_variant] && !assigns[:selected_variant].is_available}
|
||||
:if={assigns[:product_discontinued]}
|
||||
class="variant-unavailable-msg"
|
||||
>
|
||||
This product is no longer available
|
||||
</p>
|
||||
|
||||
<p
|
||||
:if={
|
||||
!assigns[:product_discontinued] && assigns[:selected_variant] &&
|
||||
!assigns[:selected_variant].is_available
|
||||
}
|
||||
class="variant-unavailable-msg"
|
||||
>
|
||||
This option is currently unavailable
|
||||
@@ -716,7 +731,13 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
|
||||
<.add_to_cart_button
|
||||
mode={@mode}
|
||||
disabled={assigns[:selected_variant] && !assigns[:selected_variant].is_available}
|
||||
text={
|
||||
if assigns[:product_discontinued], do: "No longer available", else: "Add to basket"
|
||||
}
|
||||
disabled={
|
||||
assigns[:product_discontinued] ||
|
||||
(assigns[:selected_variant] && !assigns[:selected_variant].is_available)
|
||||
}
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user