From 08131289d292e36408497fe6a4108167e490c2d4 Mon Sep 17 00:00:00 2001 From: Adrian Salamon Date: Wed, 4 Oct 2023 13:07:29 -0700 Subject: [PATCH] fix: add more page titles --- lib/haj_web/live/applications_live/index.ex | 2 +- lib/haj_web/live/applications_live/show.ex | 7 +++++++ .../live/applications_live/show.html.heex | 2 +- .../live/responsibility_live/history.ex | 7 ++++++- lib/haj_web/live/responsibility_live/index.ex | 6 +++--- lib/haj_web/live/responsibility_live/show.ex | 20 ++++++++++--------- lib/haj_web/live/song_live/index.ex | 3 ++- lib/haj_web/live/song_live/show.ex | 9 ++++++++- lib/haj_web/router.ex | 2 +- 9 files changed, 40 insertions(+), 18 deletions(-) diff --git a/lib/haj_web/live/applications_live/index.ex b/lib/haj_web/live/applications_live/index.ex index 7aaeac6..2f62973 100644 --- a/lib/haj_web/live/applications_live/index.ex +++ b/lib/haj_web/live/applications_live/index.ex @@ -29,7 +29,7 @@ defmodule HajWeb.ApplicationsLive.Index do {:ok, socket - |> assign(:title, "Ansökningar #{current_spex.year.year}") + |> assign(:page_title, "Ansökningar") |> assign(:show, current_spex) |> assign(:applications, applications) |> assign(:stats, stats) diff --git a/lib/haj_web/live/applications_live/show.ex b/lib/haj_web/live/applications_live/show.ex index efd30d2..c10d437 100644 --- a/lib/haj_web/live/applications_live/show.ex +++ b/lib/haj_web/live/applications_live/show.ex @@ -16,6 +16,13 @@ defmodule HajWeb.ApplicationsLive.Show do {:ok, assign(socket, application: application, show: show)} end + def handle_params(params, _url, socket) do + {:noreply, apply_action(socket, socket.assigns.live_action, params)} + end + + defp apply_action(socket, :show, _params), do: assign(socket, :page_title, "Ansökan") + defp apply_action(socket, :approve, _params), do: assign(socket, :page_title, "Antag") + attr :large, :boolean, default: false attr :name, :string slot :inner_block diff --git a/lib/haj_web/live/applications_live/show.html.heex b/lib/haj_web/live/applications_live/show.html.heex index 67a3137..10be409 100644 --- a/lib/haj_web/live/applications_live/show.html.heex +++ b/lib/haj_web/live/applications_live/show.html.heex @@ -71,7 +71,7 @@ <.modal - :if={@live_action in [:confirm]} + :if={@live_action in [:approve]} id="app-confirm-modal" show on_cancel={JS.navigate(~p"/applications/#{@application}")} diff --git a/lib/haj_web/live/responsibility_live/history.ex b/lib/haj_web/live/responsibility_live/history.ex index b990d6d..956c0e9 100644 --- a/lib/haj_web/live/responsibility_live/history.ex +++ b/lib/haj_web/live/responsibility_live/history.ex @@ -13,7 +13,12 @@ defmodule HajWeb.ResponsibilityLive.History do {current, prev} = Enum.split_with(responsibilities, fn %{show_id: id} -> id == current_show.id end) - {:ok, assign(socket, current_responsibilities: current, prev_responsibilities: prev)} + {:ok, + assign(socket, + page_title: "Dina ansvar", + current_responsibilities: current, + prev_responsibilities: prev + )} end attr :navigate, :any, required: true diff --git a/lib/haj_web/live/responsibility_live/index.ex b/lib/haj_web/live/responsibility_live/index.ex index 9ae0ed9..68ba4d2 100644 --- a/lib/haj_web/live/responsibility_live/index.ex +++ b/lib/haj_web/live/responsibility_live/index.ex @@ -18,19 +18,19 @@ defmodule HajWeb.ResponsibilityLive.Index do defp apply_action(socket, :edit, %{"id" => id}) do socket - |> assign(:page_title, "Edit Responsibility") + |> assign(:page_title, "Redigera ansvar") |> assign(:responsibility, Responsibilities.get_responsibility!(id)) end defp apply_action(socket, :new, _params) do socket - |> assign(:page_title, "New Responsibility") + |> assign(:page_title, "Nytt ansvar") |> assign(:responsibility, %Responsibility{}) end defp apply_action(socket, :index, _params) do socket - |> assign(:page_title, "Listing Responsibilities") + |> assign(:page_title, "Ansvar") |> assign(:responsibility, nil) end diff --git a/lib/haj_web/live/responsibility_live/show.ex b/lib/haj_web/live/responsibility_live/show.ex index 563a170..3a1e7d8 100644 --- a/lib/haj_web/live/responsibility_live/show.ex +++ b/lib/haj_web/live/responsibility_live/show.ex @@ -16,16 +16,16 @@ defmodule HajWeb.ResponsibilityLive.Show do def handle_params(%{"id" => id} = params, _, socket) do responsibility = Responsibilities.get_responsibility!(id) - socket = - socket - |> assign(:responsibility, responsibility) - - {:noreply, socket |> apply_action(socket.assigns.live_action, params)} + {:noreply, + socket + |> assign(:responsibility, responsibility) + |> apply_action(socket.assigns.live_action, params)} end defp apply_action(socket, :show, %{"id" => _id}) do - socket - |> assign(page_title: "Ansvar") + %{responsibility: responsibility} = socket.assigns + + assign(socket, page_title: responsibility.name) end defp apply_action(socket, :edit, %{"id" => _id}) do @@ -85,7 +85,7 @@ defmodule HajWeb.ResponsibilityLive.Show do authorized = Policy.authorize?(:responsibility_comment_create, user, responsibility) socket - |> assign(page_title: "Testamenten") + |> assign(page_title: "#{responsibility.name} · Testamenten") |> assign(show: show) |> assign(comments: Responsibilities.get_comments_for_show(responsibility, show.id)) |> assign(authorized: authorized) @@ -97,8 +97,10 @@ defmodule HajWeb.ResponsibilityLive.Show do end defp apply_action(socket, :history, _params) do + %{responsibility: responsibility} = socket.assigns + socket - |> assign(page_title: "Historik") + |> assign(page_title: "#{responsibility.name} · Historik") |> assign( :responsible_users, Responsibilities.get_users_for_responsibility_grouped(socket.assigns.responsibility.id) diff --git a/lib/haj_web/live/song_live/index.ex b/lib/haj_web/live/song_live/index.ex index e50cb1a..06a9499 100644 --- a/lib/haj_web/live/song_live/index.ex +++ b/lib/haj_web/live/song_live/index.ex @@ -14,7 +14,8 @@ defmodule HajWeb.SongLive.Index do [key: "#{year.year}: #{title}", value: id] end) - {:ok, assign(socket, songs: songs, show: show, show_options: show_options)} + {:ok, + assign(socket, page_title: "Sånger", songs: songs, show: show, show_options: show_options)} end def handle_event("select_show", %{"show" => show_id}, socket) do diff --git a/lib/haj_web/live/song_live/show.ex b/lib/haj_web/live/song_live/show.ex index 68a6745..7fe5c4b 100644 --- a/lib/haj_web/live/song_live/show.ex +++ b/lib/haj_web/live/song_live/show.ex @@ -15,7 +15,14 @@ defmodule HajWeb.SongLive.Show do lyrics = parse_lyrics(song.text) - {:noreply, assign(socket, song: song, lyrics: lyrics, player: false, loaded: false)} + {:noreply, + assign(socket, + page_title: song.name, + song: song, + lyrics: lyrics, + player: false, + loaded: false + )} end def handle_event("play_pause", _params, socket) do diff --git a/lib/haj_web/router.ex b/lib/haj_web/router.ex index d7f392f..154f290 100644 --- a/lib/haj_web/router.ex +++ b/lib/haj_web/router.ex @@ -90,7 +90,7 @@ defmodule HajWeb.Router do ## Applications live "/applications", ApplicationsLive.Index, :index live "/applications/:id", ApplicationsLive.Show, :show - live "/applications/:id/confirm", ApplicationsLive.Show, :confirm + live "/applications/:id/confirm", ApplicationsLive.Show, :approve ## Songs live "/songs", SongLive.Index, :index