defmodule ChiyaWeb.NoteListLive do use ChiyaWeb, :live_view @impl true def mount(_params, __session, socket) do {:ok, {notes, meta}} = Chiya.Notes.list_admin_notes(%{}) {:ok, socket |> assign(%{notes: notes, meta: meta})} end @impl true def handle_params(params, _uri, socket) do case Chiya.Notes.list_admin_notes(params) do {:ok, {notes, meta}} -> {:noreply, socket |> assign(%{notes: notes, meta: meta})} {:error, data} -> IO.inspect(data) {:noreply, socket} end end @impl true def handle_event("update-filter", params, socket) do params = Map.delete(params, "_target") {:noreply, push_patch(socket, to: ~p"/admin/notes?#{params}")} end @impl true def render(assigns) do ~H""" <.header> <.icon name="hero-document-text" /> Notes <:subtitle>Notes are the content, the heart of your site. <:actions> <.link href={~p"/admin/notes/new"}> <.button><.icon name="hero-plus-small" /> New Note <.link href={~p"/admin/notes/import"}> <.button><.icon name="hero-arrow-down-tray" /> Import Note
<.filter_form fields={[name: [op: :ilike_and]]} meta={@meta} id="user-filter-form" />
<%= for note <- @notes do %>

<%= note.name %>

<% end %>
""" end end