migrate remaining admin pages to inline feedback
Replace put_flash with inline feedback for form saves: - Media library: metadata save shows "Saved" checkmark - Product show: storefront controls save shows "Saved" checkmark - Newsletter campaign form: draft save shows "Saved" checkmark Page-level outcomes (uploads, deletes, async operations) remain as flash/banner messages — these are the correct pattern for non-form actions. Completes Task 4 of notification overhaul. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ defmodule BerrypodWeb.Admin.ProductShow do
|
||||
|> assign(:page_title, product.title)
|
||||
|> assign(:product, product)
|
||||
|> assign(:form, form)
|
||||
|> assign(:save_status, :idle)
|
||||
|
||||
{:ok, socket}
|
||||
end
|
||||
@@ -40,7 +41,7 @@ defmodule BerrypodWeb.Admin.ProductShow do
|
||||
|> Map.put(:action, :validate)
|
||||
|> to_form(as: "product")
|
||||
|
||||
{:noreply, assign(socket, :form, form)}
|
||||
{:noreply, assign(socket, form: form, save_status: :idle)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@@ -63,12 +64,12 @@ defmodule BerrypodWeb.Admin.ProductShow do
|
||||
socket
|
||||
|> assign(:product, product)
|
||||
|> assign(:form, form)
|
||||
|> put_flash(:info, "Product updated")
|
||||
|> assign(:save_status, :saved)
|
||||
|
||||
{:noreply, socket}
|
||||
|
||||
{:error, changeset} ->
|
||||
{:noreply, assign(socket, :form, to_form(changeset, as: "product"))}
|
||||
{:noreply, assign(socket, form: to_form(changeset, as: "product"), save_status: :error)}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -206,6 +207,7 @@ defmodule BerrypodWeb.Admin.ProductShow do
|
||||
/>
|
||||
</label>
|
||||
<.button type="submit" variant="primary" class="admin-btn-sm">Save</.button>
|
||||
<.inline_feedback status={@save_status} />
|
||||
</.form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user