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:
jamey
2026-03-08 07:34:17 +00:00
parent 0834437340
commit db28cb8d9f
4 changed files with 23 additions and 14 deletions

View File

@@ -10,7 +10,8 @@ defmodule BerrypodWeb.Admin.Newsletter.CampaignForm do
|> assign(:page_title, "New campaign")
|> assign(:campaign, nil)
|> assign(:subscriber_count, Newsletter.confirmed_subscriber_count())
|> assign(:form, to_form(%{"subject" => "", "body" => ""}, as: :campaign))}
|> assign(:form, to_form(%{"subject" => "", "body" => ""}, as: :campaign))
|> assign(:save_status, :idle)}
end
@impl true
@@ -42,7 +43,7 @@ defmodule BerrypodWeb.Admin.Newsletter.CampaignForm do
@impl true
def handle_event("validate", %{"campaign" => params}, socket) do
{:noreply, assign(socket, :form, to_form(params, as: :campaign))}
{:noreply, assign(socket, form: to_form(params, as: :campaign), save_status: :idle)}
end
def handle_event("save_draft", %{"campaign" => params}, socket) do
@@ -51,10 +52,10 @@ defmodule BerrypodWeb.Admin.Newsletter.CampaignForm do
{:noreply,
socket
|> assign(:campaign, campaign)
|> put_flash(:info, "Campaign saved")}
|> assign(:save_status, :saved)}
{:error, _changeset} ->
{:noreply, put_flash(socket, :error, "Please fill in subject and body")}
{:noreply, assign(socket, :save_status, :error)}
end
end
@@ -211,6 +212,7 @@ defmodule BerrypodWeb.Admin.Newsletter.CampaignForm do
<.button type="submit">
Save draft
</.button>
<.inline_feedback status={@save_status} />
<button
type="button"