cannery/lib/cannery_web/live/container_live/index.html.heex

201 lines
6.5 KiB
Plaintext

<div class="flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
<%= gettext("Containers") %>
</h1>
<%= if @containers |> Enum.empty?() and @search |> is_nil() do %>
<h2 class="title text-xl text-primary-600">
<%= gettext("No containers") %>
<%= display_emoji("😔") %>
</h2>
<.link patch={~p"/containers/new"} class="btn btn-primary">
<%= dgettext("actions", "Add your first container!") %>
</.link>
<% else %>
<.link patch={~p"/containers/new"} class="btn btn-primary">
<%= dgettext("actions", "New Container") %>
</.link>
<div class="w-full flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-4 max-w-2xl">
<.form
:let={f}
for={%{}}
as={:search}
phx-change="search"
phx-submit="search"
class="grow flex items-center"
>
<%= text_input(f, :search_term,
class: "grow input input-primary",
phx_debounce: 300,
placeholder: gettext("Search containers"),
role: "search",
value: @search
) %>
</.form>
<.toggle_button action="toggle_table" value={@view_table}>
<span class="title text-lg text-primary-600">
<%= gettext("View as table") %>
</span>
</.toggle_button>
</div>
<%= if @containers |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-600">
<%= gettext("No containers") %>
<%= display_emoji("😔") %>
</h2>
<% else %>
<%= if @view_table do %>
<.live_component
module={CanneryWeb.Components.ContainerTableComponent}
id="containers-index-table"
action={@live_action}
containers={@containers}
current_user={@current_user}
>
<:tag_actions :let={container}>
<div class="mx-4 my-2">
<.link
patch={~p"/containers/edit_tags/#{container}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Tag %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-tags"></i>
</.link>
</div>
</:tag_actions>
<:actions :let={container}>
<.link
patch={~p"/containers/edit/#{container}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Edit %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-edit"></i>
</.link>
<.link
patch={~p"/containers/clone/#{container}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Clone %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-copy"></i>
</.link>
<.link
href="#"
class="text-primary-600 link"
phx-click="delete"
phx-value-id={container.id}
data-confirm={
dgettext("prompts", "Are you sure you want to delete %{name}?",
name: container.name
)
}
aria-label={
dgettext("actions", "Delete %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
</:actions>
</.live_component>
<% else %>
<div class="w-full flex flex-row flex-wrap justify-center items-stretch">
<.container_card
:for={container <- @containers}
container={container}
current_user={@current_user}
>
<:tag_actions>
<div class="mx-4 my-2">
<.link
patch={~p"/containers/edit_tags/#{container}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Tag %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-tags"></i>
</.link>
</div>
</:tag_actions>
<.link
patch={~p"/containers/edit/#{container}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Edit %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-edit"></i>
</.link>
<.link
patch={~p"/containers/clone/#{container}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Clone %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-copy"></i>
</.link>
<.link
href="#"
class="text-primary-600 link"
phx-click="delete"
phx-value-id={container.id}
data-confirm={
dgettext("prompts", "Are you sure you want to delete %{name}?",
name: container.name
)
}
aria-label={
dgettext("actions", "Delete %{container_name}", container_name: container.name)
}
>
<i class="fa-fw fa-lg fas fa-trash"></i>
</.link>
</.container_card>
</div>
<% end %>
<% end %>
<% end %>
</div>
<%= case @live_action do %>
<% modifying when modifying in [:new, :edit, :clone] -> %>
<.modal return_to={~p"/containers"}>
<.live_component
module={CanneryWeb.ContainerLive.FormComponent}
id={@container.id || :new}
title={@page_title}
action={@live_action}
container={@container}
return_to={~p"/containers"}
current_user={@current_user}
/>
</.modal>
<% :edit_tags -> %>
<.modal return_to={~p"/containers"}>
<.live_component
module={CanneryWeb.ContainerLive.EditTagsComponent}
id={@container.id}
title={@page_title}
action={@live_action}
container={@container}
current_path={~p"/containers/edit_tags/#{@container}"}
current_user={@current_user}
/>
</.modal>
<% _ -> %>
<% end %>