From cc4573e346a06616a4a711e42bf9e4f9ee73e6c7 Mon Sep 17 00:00:00 2001 From: ks0m1c_dharma Date: Fri, 22 Dec 2023 20:03:47 +0800 Subject: [PATCH] Test SideNotes View --- lib/vyasa_web/live/gita_live/show.ex | 24 +++++++++++++++++++++++- lib/vyasa_web/router.ex | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/vyasa_web/live/gita_live/show.ex b/lib/vyasa_web/live/gita_live/show.ex index c33e0145..b95f63ec 100644 --- a/lib/vyasa_web/live/gita_live/show.ex +++ b/lib/vyasa_web/live/gita_live/show.ex @@ -15,10 +15,15 @@ defmodule VyasaWeb.GitaLive.Show do <:subtitle> <%= @chapter.chapter_summary %> + <.list :for={{_dom_id, text} <- @streams.verses}> <:item title={"#{text.chapter_number}.#{text.verse_number}"}>

<%= text.text |> String.split("редред") |> List.first() %>

<:item><%= text.transliteration %> <:item><%= text.word_meanings %> + <.sidenote> + <%= @chapter.name_transliterated %> + <:subtitle> <%= @chapter.chapter_summary %> + <.back navigate={~p"/gita"}>Back to Gita @@ -26,9 +31,26 @@ defmodule VyasaWeb.GitaLive.Show do end #<.link patch={~p"/gita/#{@chapter.id}"} phx-click={JS.push_focus()}> <.button>Annotate @impl true - def handle_params(%{"id" => id}, _, socket) do + def handle_params(%{"id" => id} = params, _, socket) do {:noreply, socket |> assign(:chapter, Gita.chapters(id)) |> stream(:verses, Gita.verses(id))} + |> apply_action(socket.assigns.live_action, params) + end + + + defp apply_action(socket, :sangh, %{"id" => _chapter, "sangh_id" => _sId} = _params) do + socket + |> assign(:sangh, []) + end + + defp apply_action(socket, :new_sangh, %{"id" => _chapter} = _params) do + socket + |> assign(:sangh, []) + end + + #pokemon clause + defp apply_action(socket, _action, _params) do + socket end end diff --git a/lib/vyasa_web/router.ex b/lib/vyasa_web/router.ex index 34aec15b..106a7735 100644 --- a/lib/vyasa_web/router.ex +++ b/lib/vyasa_web/router.ex @@ -20,6 +20,8 @@ defmodule VyasaWeb.Router do get "/", PageController, :home live "/gita/", GitaLive.Index, :index live "/gita/:id", GitaLive.Show, :show + live "/gita/:id/sangh/new", GitaLive.Show, :new_sangh + live "/gita/:id/sangh/:sangh_id", GitaLive.Show, :sangh live "/texts", TextLive.Index, :index live "/texts/new", TextLive.Index, :new live "/texts/:id/edit", TextLive.Index, :edit