add tag editing to containers
This commit is contained in:
@ -4,17 +4,21 @@ defmodule CanneryWeb.Components.ContainerCard do
|
||||
"""
|
||||
|
||||
use CanneryWeb, :component
|
||||
import CanneryWeb.Components.TagCard
|
||||
alias Cannery.{Repo, Containers}
|
||||
alias CanneryWeb.Endpoint
|
||||
|
||||
def container_card(assigns) do
|
||||
def container_card(%{container: container} = assigns) do
|
||||
assigns = assigns |> Map.put(:container, container |> Repo.preload([:tags, :ammo_groups]))
|
||||
|
||||
~H"""
|
||||
<div
|
||||
id={"container-#{@container.id}"}
|
||||
class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center
|
||||
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"
|
||||
>
|
||||
<div class="mb-4 flex flex-col justify-center items-center">
|
||||
<div class="mb-4 flex flex-col justify-center items-center space-y-2">
|
||||
<%= live_redirect to: Routes.container_show_path(Endpoint, :show, @container),
|
||||
class: "link" do %>
|
||||
<h1 class="px-4 py-2 rounded-lg title text-xl">
|
||||
@ -40,6 +44,25 @@ defmodule CanneryWeb.Components.ContainerCard do
|
||||
<%= @container.location %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<%= if @container.ammo_groups do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
<%= gettext("Rounds:") %>
|
||||
<%= @container |> Containers.get_container_rounds!() %>
|
||||
</span>
|
||||
<% 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 %>
|
||||
|
||||
<%= if assigns |> Map.has_key?(:tag_actions) do %>
|
||||
<%= render_slot(@tag_actions) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= if assigns |> Map.has_key?(:inner_block) do %>
|
||||
|
@ -13,15 +13,20 @@ defmodule CanneryWeb.Components.TagCard do
|
||||
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"
|
||||
style={"color: #{@tag.text_color}; background-color: #{@tag.bg_color}"}
|
||||
>
|
||||
<%= @tag.name %>
|
||||
</h1>
|
||||
|
||||
<.simple_tag_card tag={@tag} />
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def simple_tag_card(assigns) do
|
||||
~H"""
|
||||
<h1
|
||||
class="mx-2 my-1 px-4 py-2 rounded-lg title text-xl"
|
||||
style={"color: #{@tag.text_color}; background-color: #{@tag.bg_color}"}
|
||||
>
|
||||
<%= @tag.name %>
|
||||
</h1>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user