use strict context boundaries and remove all n+1 queries
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -17,12 +17,9 @@
|
||||
<%= if @ammo_group.count == 0, do: gettext("Empty"), else: @ammo_group.count %>
|
||||
</span>
|
||||
|
||||
<span
|
||||
:if={@ammo_group |> Ammo.get_original_count() != @ammo_group.count}
|
||||
class="rounded-lg title text-lg"
|
||||
>
|
||||
<span :if={@original_count != @ammo_group.count} class="rounded-lg title text-lg">
|
||||
<%= gettext("Original Count:") %>
|
||||
<%= @ammo_group |> Ammo.get_original_count() %>
|
||||
<%= @original_count %>
|
||||
</span>
|
||||
|
||||
<span :if={@ammo_group.notes} class="rounded-lg title text-lg">
|
||||
@ -32,38 +29,35 @@
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Purchased on:") %>
|
||||
<.date date={@ammo_group.purchased_on} />
|
||||
<.date id={"#{@ammo_group.id}-purchased-on"} date={@ammo_group.purchased_on} />
|
||||
</span>
|
||||
|
||||
<span :if={@ammo_group |> Ammo.get_last_used_shot_group()} class="rounded-lg title text-lg">
|
||||
<span :if={@last_used_date} class="rounded-lg title text-lg">
|
||||
<%= gettext("Last used on:") %>
|
||||
<.date date={@ammo_group |> Ammo.get_last_used_shot_group() |> Map.get(:date)} />
|
||||
<.date id={"#{@ammo_group.id}-last-used-on"} date={@last_used_date} />
|
||||
</span>
|
||||
|
||||
<%= if @ammo_group.price_paid do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Price paid:") %>
|
||||
<%= gettext("$%{amount}",
|
||||
amount: @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2)
|
||||
) %>
|
||||
</span>
|
||||
<span :if={@ammo_group.price_paid} class="rounded-lg title text-lg">
|
||||
<%= gettext("Price paid:") %>
|
||||
<%= gettext("$%{amount}", amount: display_currency(@ammo_group.price_paid)) %>
|
||||
</span>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("CPR:") %>
|
||||
<%= gettext("$%{amount}",
|
||||
amount: @ammo_group |> Ammo.get_cpr() |> :erlang.float_to_binary(decimals: 2)
|
||||
) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span :if={@cpr} class="rounded-lg title text-lg">
|
||||
<%= gettext("CPR:") %>
|
||||
<%= gettext("$%{amount}", amount: display_currency(@cpr)) %>
|
||||
</span>
|
||||
|
||||
<span :if={@show_container and @ammo_group.container} class="rounded-lg title text-lg">
|
||||
<span
|
||||
:if={@show_container && Containers.get_container!(@ammo_group.container_id, @current_user)}
|
||||
class="rounded-lg title text-lg"
|
||||
>
|
||||
<%= gettext("Container:") %>
|
||||
|
||||
<.link
|
||||
navigate={Routes.container_show_path(Endpoint, :show, @ammo_group.container)}
|
||||
navigate={Routes.container_show_path(Endpoint, :show, @ammo_group.container_id)}
|
||||
class="link"
|
||||
>
|
||||
<%= @ammo_group.container.name %>
|
||||
<%= Containers.get_container!(@ammo_group.container_id, @current_user).name %>
|
||||
</.link>
|
||||
</span>
|
||||
</div>
|
||||
|
@ -1,17 +1,17 @@
|
||||
<div
|
||||
id={"container-#{@container.id}"}
|
||||
class="overflow-hidden max-w-full mx-4 mb-4 px-8 py-4
|
||||
flex flex-col justify-center items-center space-y-4
|
||||
flex flex-col justify-around items-center space-y-4
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out"
|
||||
>
|
||||
<div class="max-w-full mb-4 flex flex-col justify-center items-center space-y-2">
|
||||
<.link navigate={Routes.container_show_path(Endpoint, :show, @container)} class="link">
|
||||
<h1 class="px-4 py-2 rounded-lg title text-xl">
|
||||
<%= @container.name %>
|
||||
</h1>
|
||||
</.link>
|
||||
<.link navigate={Routes.container_show_path(Endpoint, :show, @container)} class="link">
|
||||
<h1 class="px-4 py-2 rounded-lg title text-xl">
|
||||
<%= @container.name %>
|
||||
</h1>
|
||||
</.link>
|
||||
|
||||
<div class="flex flex-col justify-center items-center space-y-2">
|
||||
<span :if={@container.desc} class="rounded-lg title text-lg">
|
||||
<%= gettext("Description:") %>
|
||||
<%= @container.desc %>
|
||||
@ -27,20 +27,23 @@
|
||||
<%= @container.location %>
|
||||
</span>
|
||||
|
||||
<%= unless @container.ammo_groups |> Enum.empty?() do %>
|
||||
<%= if @container |> Ammo.get_ammo_groups_count_for_container!(@current_user) != 0 do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Packs:") %>
|
||||
<%= @container |> Containers.get_container_ammo_group_count!() %>
|
||||
<%= @container |> Ammo.get_ammo_groups_count_for_container!(@current_user) %>
|
||||
</span>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Rounds:") %>
|
||||
<%= @container |> Containers.get_container_rounds!() %>
|
||||
<%= @container |> Ammo.get_round_count_for_container!(@current_user) %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<div class="flex flex-wrap justify-center items-center">
|
||||
<.simple_tag_card :for={tag <- @container.tags} :if={@container.tags} tag={tag} />
|
||||
<div
|
||||
:if={@tag_actions || @container.tags != []}
|
||||
class="flex flex-wrap justify-center items-center"
|
||||
>
|
||||
<.simple_tag_card :for={tag <- @container.tags} tag={tag} />
|
||||
|
||||
<%= if @tag_actions, do: render_slot(@tag_actions) %>
|
||||
</div>
|
||||
|
@ -1,12 +1,7 @@
|
||||
<time
|
||||
:if={@date}
|
||||
datetime={@date |> Date.to_iso8601(:extended)}
|
||||
x-data={~s<{
|
||||
<time :if={@date} id={@id} datetime={@date |> Date.to_iso8601(:extended)} x-data={~s<{
|
||||
date:
|
||||
Intl.DateTimeFormat([], {timeZone: 'Etc/UTC', dateStyle: 'short'})
|
||||
.format(new Date("#{Date.to_iso8601(@date, :extended)}"))
|
||||
}>}
|
||||
x-text="date"
|
||||
>
|
||||
}>} x-text="date">
|
||||
<%= @date |> Date.to_iso8601(:extended) %>
|
||||
</time>
|
||||
|
@ -1,12 +1,7 @@
|
||||
<time
|
||||
:if={@datetime}
|
||||
datetime={cast_datetime(@datetime)}
|
||||
x-data={~s/{
|
||||
<time :if={@datetime} id={@id} datetime={cast_datetime(@datetime)} x-data={~s/{
|
||||
datetime:
|
||||
Intl.DateTimeFormat([], {dateStyle: 'short', timeStyle: 'long'})
|
||||
.format(new Date("#{cast_datetime(@datetime)}"))
|
||||
}/}
|
||||
x-text="datetime"
|
||||
>
|
||||
}/} x-text="datetime">
|
||||
<%= cast_datetime(@datetime) %>
|
||||
</time>
|
||||
|
@ -0,0 +1,46 @@
|
||||
<div class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center space-y-4
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out">
|
||||
<h1 class="title text-xl">
|
||||
<%= @invite.name %>
|
||||
</h1>
|
||||
|
||||
<%= if @invite.disabled_at |> is_nil() do %>
|
||||
<h2 class="title text-md">
|
||||
<%= if @invite.uses_left do %>
|
||||
<%= gettext(
|
||||
"Uses Left: %{uses_left_count}",
|
||||
uses_left_count: @invite.uses_left
|
||||
) %>
|
||||
<% else %>
|
||||
<%= gettext("Uses Left: Unlimited") %>
|
||||
<% end %>
|
||||
</h2>
|
||||
<% else %>
|
||||
<h2 class="title text-md">
|
||||
<%= gettext("Invite Disabled") %>
|
||||
</h2>
|
||||
<% end %>
|
||||
|
||||
<.qr_code
|
||||
content={Routes.user_registration_url(Endpoint, :new, invite: @invite.token)}
|
||||
filename={@invite.name}
|
||||
/>
|
||||
|
||||
<h2 :if={@use_count && @use_count != 0} class="title text-md">
|
||||
<%= gettext("Uses: %{uses_count}", uses_count: @use_count) %>
|
||||
</h2>
|
||||
|
||||
<div class="flex flex-row flex-wrap justify-center items-center">
|
||||
<code
|
||||
id={"code-#{@invite.id}"}
|
||||
class="mx-2 my-1 text-xs px-4 py-2 rounded-lg text-center break-all text-gray-100 bg-primary-800"
|
||||
phx-no-format
|
||||
><%= Routes.user_registration_url(Endpoint, :new, invite: @invite.token) %></code>
|
||||
<%= if @code_actions, do: render_slot(@code_actions) %>
|
||||
</div>
|
||||
|
||||
<div :if={@inner_block} class="flex space-x-4 justify-center items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
</div>
|
@ -15,7 +15,7 @@
|
||||
"User was confirmed at%{confirmed_datetime}",
|
||||
confirmed_datetime: ""
|
||||
) %>
|
||||
<.datetime datetime={@user.confirmed_at} />
|
||||
<.datetime id={"#{@user.id}-confirmed-at"} datetime={@user.confirmed_at} />
|
||||
<% else %>
|
||||
<%= gettext("Email unconfirmed") %>
|
||||
<% end %>
|
||||
@ -26,7 +26,7 @@
|
||||
"User registered on%{registered_datetime}",
|
||||
registered_datetime: ""
|
||||
) %>
|
||||
<.datetime datetime={@user.inserted_at} />
|
||||
<.datetime id={"#{@user.id}-inserted-at"} datetime={@user.inserted_at} />
|
||||
</p>
|
||||
</h3>
|
||||
|
||||
|
Reference in New Issue
Block a user