defmodule MvWeb.CustomFieldValueLive.Index do @moduledoc """ LiveView for displaying and managing custom field values. ## Features - List all custom field values with their values and types - Show which member each custom field value belongs to - Display custom field information - Navigate to custom field value details and edit forms - Delete custom field values ## Relationships Each custom field value is linked to: - A member (the custom field value owner) - A custom field (defining value type and behavior) ## Events - `delete` - Remove a custom field value from the database ## Note Custom field values are typically managed through the member edit form. This view provides a global overview of all custom field values. """ use MvWeb, :live_view @impl true def render(assigns) do ~H""" <.header> Listing Custom field values <:actions> <.button variant="primary" navigate={~p"/custom_field_values/new"}> <.icon name="hero-plus" /> New Custom field value <.table id="custom_field_values" rows={@streams.custom_field_values} row_click={ fn {_id, custom_field_value} -> JS.navigate(~p"/custom_field_values/#{custom_field_value}") end } > <:col :let={{_id, custom_field_value}} label="Id">{custom_field_value.id} <:action :let={{_id, custom_field_value}}>
<.link navigate={~p"/custom_field_values/#{custom_field_value}"}>Show
<.link navigate={~p"/custom_field_values/#{custom_field_value}/edit"}>Edit <:action :let={{id, custom_field_value}}> <.link phx-click={JS.push("delete", value: %{id: custom_field_value.id}) |> hide("##{id}")} data-confirm="Are you sure?" > Delete
""" end @impl true def mount(_params, _session, socket) do {:ok, socket |> assign(:page_title, "Listing Custom field values") |> stream(:custom_field_values, Ash.read!(Mv.Membership.CustomFieldValue))} end @impl true def handle_event("delete", %{"id" => id}, socket) do custom_field_value = Ash.get!(Mv.Membership.CustomFieldValue, id) Ash.destroy!(custom_field_value) {:noreply, stream_delete(socket, :custom_field_values, custom_field_value)} end end