Skip to content

Commit

Permalink
fix: add more page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansalamon committed Oct 4, 2023
1 parent 6979604 commit 0813128
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/haj_web/live/applications_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions lib/haj_web/live/applications_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/haj_web/live/applications_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</div>

<.modal
:if={@live_action in [:confirm]}
:if={@live_action in [:approve]}
id="app-confirm-modal"
show
on_cancel={JS.navigate(~p"/applications/#{@application}")}
Expand Down
7 changes: 6 additions & 1 deletion lib/haj_web/live/responsibility_live/history.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/haj_web/live/responsibility_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 11 additions & 9 deletions lib/haj_web/live/responsibility_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/haj_web/live/song_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion lib/haj_web/live/song_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/haj_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0813128

Please sign in to comment.