improve templates
This commit is contained in:
@ -12,11 +12,12 @@
|
||||
phx-change="validate"
|
||||
phx-submit="save"
|
||||
>
|
||||
<%= if @changeset.action && not @changeset.valid? do %>
|
||||
<div class="invalid-feedback col-span-3 text-center">
|
||||
<%= changeset_errors(@changeset) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div
|
||||
:if={@changeset.action && not @changeset.valid?()}
|
||||
class="invalid-feedback col-span-3 text-center"
|
||||
>
|
||||
<%= changeset_errors(@changeset) %>
|
||||
</div>
|
||||
|
||||
<%= label(f, :ammo_left, gettext("Rounds left"), class: "title text-lg text-primary-600") %>
|
||||
<%= number_input(f, :ammo_left,
|
||||
|
@ -23,9 +23,10 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
|
||||
~H"""
|
||||
<div
|
||||
id={"ammo_group-#{@ammo_group.id}"}
|
||||
class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out"
|
||||
class="mx-4 my-2 px-8 py-4
|
||||
flex flex-col justify-center items-center
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out"
|
||||
>
|
||||
<.link navigate={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)} class="mb-2 link">
|
||||
<h1 class="title text-xl title-primary-500">
|
||||
@ -39,31 +40,28 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
|
||||
<%= if @ammo_group.count == 0, do: gettext("Empty"), else: @ammo_group.count %>
|
||||
</span>
|
||||
|
||||
<%= if @ammo_group |> Ammo.get_original_count() != @ammo_group.count do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Original Count:") %>
|
||||
<%= @ammo_group |> Ammo.get_original_count() %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span
|
||||
:if={@ammo_group |> Ammo.get_original_count() != @ammo_group.count}
|
||||
class="rounded-lg title text-lg"
|
||||
>
|
||||
<%= gettext("Original Count:") %>
|
||||
<%= @ammo_group |> Ammo.get_original_count() %>
|
||||
</span>
|
||||
|
||||
<%= if @ammo_group.notes do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Notes:") %>
|
||||
<%= @ammo_group.notes %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span :if={@ammo_group.notes} class="rounded-lg title text-lg">
|
||||
<%= gettext("Notes:") %>
|
||||
<%= @ammo_group.notes %>
|
||||
</span>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Purchased on:") %>
|
||||
<.date date={@ammo_group.purchased_on} />
|
||||
</span>
|
||||
|
||||
<%= if @ammo_group |> Ammo.get_last_used_shot_group() do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Last used on:") %>
|
||||
<.date date={@ammo_group |> Ammo.get_last_used_shot_group() |> Map.get(:date)} />
|
||||
</span>
|
||||
<% end %>
|
||||
<span :if={@ammo_group |> Ammo.get_last_used_shot_group()} class="rounded-lg title text-lg">
|
||||
<%= gettext("Last used on:") %>
|
||||
<.date date={@ammo_group |> Ammo.get_last_used_shot_group() |> Map.get(:date)} />
|
||||
</span>
|
||||
|
||||
<%= if @ammo_group.price_paid do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
@ -81,25 +79,24 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<%= if @show_container and @ammo_group.container do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Container:") %>
|
||||
<span :if={@show_container and @ammo_group.container} class="rounded-lg title text-lg">
|
||||
<%= gettext("Container:") %>
|
||||
|
||||
<.link
|
||||
navigate={Routes.container_show_path(Endpoint, :show, @ammo_group.container)}
|
||||
class="link"
|
||||
>
|
||||
<%= @ammo_group.container.name %>
|
||||
</.link>
|
||||
</span>
|
||||
<% end %>
|
||||
<.link
|
||||
navigate={Routes.container_show_path(Endpoint, :show, @ammo_group.container)}
|
||||
class="link"
|
||||
>
|
||||
<%= @ammo_group.container.name %>
|
||||
</.link>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<%= if assigns |> Map.has_key?(:inner_block) do %>
|
||||
<div class="mt-4 flex space-x-4 justify-center items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div
|
||||
:if={assigns |> Map.has_key?(:inner_block)}
|
||||
class="mt-4 flex space-x-4 justify-center items-center"
|
||||
>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
@ -23,7 +23,8 @@ defmodule CanneryWeb.Components.ContainerCard do
|
||||
~H"""
|
||||
<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
|
||||
class="overflow-hidden max-w-full mx-4 mb-4 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"
|
||||
>
|
||||
@ -34,24 +35,20 @@ defmodule CanneryWeb.Components.ContainerCard do
|
||||
</h1>
|
||||
</.link>
|
||||
|
||||
<%= if @container.desc do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Description:") %>
|
||||
<%= @container.desc %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span :if={@container.desc} class="rounded-lg title text-lg">
|
||||
<%= gettext("Description:") %>
|
||||
<%= @container.desc %>
|
||||
</span>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Type:") %>
|
||||
<%= @container.type %>
|
||||
</span>
|
||||
|
||||
<%= if @container.location do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Location:") %>
|
||||
<%= @container.location %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span :if={@container.location} class="rounded-lg title text-lg">
|
||||
<%= gettext("Location:") %>
|
||||
<%= @container.location %>
|
||||
</span>
|
||||
|
||||
<%= unless @container.ammo_groups |> Enum.empty?() do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
@ -66,21 +63,18 @@ defmodule CanneryWeb.Components.ContainerCard do
|
||||
<% end %>
|
||||
|
||||
<div class="flex flex-wrap justify-center items-center">
|
||||
<%= unless @container.tags |> Enum.empty?() do %>
|
||||
<%= for tag <- @container.tags do %>
|
||||
<.simple_tag_card tag={tag} />
|
||||
<% end %>
|
||||
<% end %>
|
||||
<.simple_tag_card :for={tag <- @container.tags} :if={@container.tags} tag={tag} />
|
||||
|
||||
<%= render_slot(@tag_actions) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= if assigns |> Map.has_key?(:inner_block) do %>
|
||||
<div class="flex space-x-4 justify-center items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div
|
||||
:if={assigns |> Map.has_key?(:inner_block)}
|
||||
class="flex space-x-4 justify-center items-center"
|
||||
>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
@ -135,11 +135,7 @@ defmodule CanneryWeb.Components.ContainerTableComponent do
|
||||
{container.tags |> Enum.map(fn %{name: name} -> name end),
|
||||
~H"""
|
||||
<div class="flex flex-wrap justify-center items-center">
|
||||
<%= unless @container.tags |> Enum.empty?() do %>
|
||||
<%= for tag <- @container.tags do %>
|
||||
<TagCard.simple_tag_card tag={tag} />
|
||||
<% end %>
|
||||
<% end %>
|
||||
<TagCard.simple_tag_card :for={tag <- @container.tags} :if={@container.tags} tag={tag} />
|
||||
|
||||
<%= render_slot(@tag_actions, @container) %>
|
||||
</div>
|
||||
|
@ -18,8 +18,8 @@ defmodule CanneryWeb.Components.InviteCard do
|
||||
<div
|
||||
id={"invite-#{@invite.id}"}
|
||||
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"
|
||||
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 %>
|
||||
@ -56,11 +56,9 @@ defmodule CanneryWeb.Components.InviteCard do
|
||||
<%= render_slot(@code_actions) %>
|
||||
</div>
|
||||
|
||||
<%= if @inner_block do %>
|
||||
<div class="flex space-x-4 justify-center items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div :if={@inner_block} class="flex space-x-4 justify-center items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
@ -34,20 +34,19 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= for {values, i} <- @rows |> Enum.with_index() do %>
|
||||
<tr class={if i |> Integer.is_even(), do: @row_class, else: @alternate_row_class}>
|
||||
<%= for %{key: key} = value <- @columns do %>
|
||||
<td class={["p-2", value[:class]]}>
|
||||
<%= case values |> Map.get(key) do %>
|
||||
<% {_custom_sort_value, value} -> %>
|
||||
<%= value %>
|
||||
<% value -> %>
|
||||
<%= value %>
|
||||
<% end %>
|
||||
</td>
|
||||
<tr
|
||||
:for={{values, i} <- @rows |> Enum.with_index()}
|
||||
class={if i |> Integer.is_even(), do: @row_class, else: @alternate_row_class}
|
||||
>
|
||||
<td :for={%{key: key} = value <- @columns} class={["p-2", value[:class]]}>
|
||||
<%= case values |> Map.get(key) do %>
|
||||
<% {_custom_sort_value, value} -> %>
|
||||
<%= value %>
|
||||
<% value -> %>
|
||||
<%= value %>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -14,8 +14,8 @@ defmodule CanneryWeb.Components.TagCard do
|
||||
<div
|
||||
id={"tag-#{@tag.id}"}
|
||||
class="mx-4 mb-4 px-8 py-4 space-x-4 flex justify-center items-center
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out"
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out"
|
||||
>
|
||||
<.simple_tag_card tag={@tag} />
|
||||
<%= render_slot(@inner_block) %>
|
||||
|
@ -119,16 +119,14 @@ defmodule CanneryWeb.Components.Topbar do
|
||||
</li>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= if Accounts.allow_registration?() do %>
|
||||
<li class="mx-2 my-1">
|
||||
<.link
|
||||
navigate={Routes.user_registration_path(Endpoint, :new)}
|
||||
class="text-primary-600 text-white hover:underline truncate"
|
||||
>
|
||||
<%= dgettext("actions", "Register") %>
|
||||
</.link>
|
||||
</li>
|
||||
<% end %>
|
||||
<li :if={Accounts.allow_registration?()} class="mx-2 my-1">
|
||||
<.link
|
||||
navigate={Routes.user_registration_path(Endpoint, :new)}
|
||||
class="text-primary-600 text-white hover:underline truncate"
|
||||
>
|
||||
<%= dgettext("actions", "Register") %>
|
||||
</.link>
|
||||
</li>
|
||||
<li class="mx-2 my-1">
|
||||
<.link
|
||||
navigate={Routes.user_session_path(Endpoint, :new)}
|
||||
|
@ -14,8 +14,8 @@ defmodule CanneryWeb.Components.UserCard do
|
||||
<div
|
||||
id={"user-#{@user.id}"}
|
||||
class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center text-center
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out"
|
||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||
transition-all duration-300 ease-in-out"
|
||||
>
|
||||
<h1 class="px-4 py-2 rounded-lg title text-xl break-all">
|
||||
<%= @user.email %>
|
||||
@ -43,11 +43,9 @@ defmodule CanneryWeb.Components.UserCard do
|
||||
</p>
|
||||
</h3>
|
||||
|
||||
<%= if @inner_block do %>
|
||||
<div class="px-4 py-2 flex space-x-4 justify-center items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div :if={@inner_block} class="px-4 py-2 flex space-x-4 justify-center items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
Reference in New Issue
Block a user