Skip to content

Commit

Permalink
Add speaker to activity_show
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Jul 16, 2023
1 parent af35ea3 commit ea59b8f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/atomic_web/live/activity_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@
</dd>
</div>
<div class="col-span-2">
<div class="sm:grid sm:grid-cols-2">
<%= if @activity.speakers do %>
<div class="sm:grid sm:grid-cols-1">
<%= if @activity.speakers != [] do %>
<%= gettext("Speaker") %>
<%= for speaker <- @activity.speakers do %>
<div class="flex flex-col">
<div class="flex flex-col border-2 w-52 p-2 mt-2 rounded">
<div class="text-sm font-medium text-zinc-500">
<%= gettext("speaker") %>
</div>
<div class="mt-1 flex items-center">
<span class="mr-2 inline-flex h-9 w-9 items-center justify-center rounded-full bg-zinc-500">
Expand Down Expand Up @@ -177,6 +177,7 @@
</div>
</div>

<div class="flex flex-row space-x-1">
<%= if @current_user.role in [:admin] or is_admin?(@current_user, @activity) do %>
<span class="w-fit rounded bg-zinc-400 py-2 px-3.5 text-sm font-medium text-white shadow-sm hover:bg-zinc-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
<%= live_patch("Edit", to: Routes.activity_edit_path(@socket, :edit, @activity), class: "button") %>
Expand All @@ -188,3 +189,4 @@
<span class="w-fit rounded bg-zinc-400 py-2 px-3.5 text-sm font-medium text-white shadow-sm hover:bg-zinc-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
<%= live_redirect("Back", to: Routes.activity_index_path(@socket, :index)) %>
</span>
</div>
13 changes: 12 additions & 1 deletion lib/atomic_web/live/speaker_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ defmodule AtomicWeb.SpeakerLive.Index do

@impl true
def handle_params(params, _url, socket) do
{:noreply, apply_action(socket, socket.assigns.live_action, params)}
entries = [
%{
name: gettext("Speakers"),
route: Routes.speaker_index_path(socket, :index)
}
]

{:noreply,
socket
|> assign(:current_page, :speakers)
|> assign(:breadcrumb_entries, entries)
|> apply_action(socket.assigns.live_action, params)}
end

defp apply_action(socket, :edit, %{"id" => id}) do
Expand Down
13 changes: 13 additions & 0 deletions lib/atomic_web/live/speaker_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ defmodule AtomicWeb.SpeakerLive.Show do

@impl true
def handle_params(%{"id" => id}, _, socket) do
entries = [
%{
name: gettext("Speakers"),
route: Routes.speaker_index_path(socket, :index)
},
%{
name: gettext("Show"),
route: Routes.speaker_show_path(socket, :show, id)
}
]

{:noreply,
socket
|> assign(:page_title, page_title(socket.assigns.live_action))
|> assign(:current_page, :speakers)
|> assign(:breadcrumb_entries, entries)
|> assign(:speaker, Activities.get_speaker!(id))}
end

Expand Down

0 comments on commit ea59b8f

Please sign in to comment.