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

201 lines
6.5 KiB
Plaintext
Raw Normal View History

2022-01-31 21:42:24 -05:00
<div class="flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
2022-02-15 17:33:07 -05:00
<%= gettext("Containers") %>
2022-01-31 21:42:24 -05:00
</h1>
2022-12-03 20:07:51 -05:00
<%= if @containers |> Enum.empty?() and @search |> is_nil() do %>
2022-02-17 22:29:01 -05:00
<h2 class="title text-xl text-primary-600">
2022-02-15 23:52:44 -05:00
<%= gettext("No containers") %>
<%= display_emoji("😔") %>
2022-02-01 00:11:37 -05:00
</h2>
2022-01-31 21:42:24 -05:00
2023-04-14 23:34:11 -04:00
<.link patch={~p"/containers/new"} class="btn btn-primary">
<%= dgettext("actions", "Add your first container!") %>
</.link>
2022-01-31 21:42:24 -05:00
<% else %>
2023-04-14 23:34:11 -04:00
<.link patch={~p"/containers/new"} class="btn btn-primary">
<%= dgettext("actions", "New Container") %>
</.link>
2022-11-10 18:51:24 -05:00
2023-03-23 22:07:25 -04:00
<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">
2022-12-03 20:07:51 -05:00
<.form
:let={f}
2023-03-17 21:06:08 -04:00
for={%{}}
as={:search}
2022-12-03 20:07:51 -05:00
phx-change="search"
phx-submit="search"
2023-03-23 22:07:25 -04:00
class="grow flex items-center"
2022-12-03 20:07:51 -05:00
>
<%= text_input(f, :search_term,
2023-03-23 22:07:25 -04:00
class: "grow input input-primary",
2022-12-03 20:07:51 -05:00
phx_debounce: 300,
2024-07-28 12:52:41 -04:00
placeholder: gettext("Search containers"),
role: "search",
value: @search
2022-12-03 20:07:51 -05:00
) %>
</.form>
2022-11-10 18:51:24 -05:00
<.toggle_button action="toggle_table" value={@view_table}>
<span class="title text-lg text-primary-600">
<%= gettext("View as table") %>
</span>
</.toggle_button>
</div>
2022-12-03 20:20:11 -05:00
2023-03-23 22:07:25 -04:00
<%= if @containers |> Enum.empty?() do %>
<h2 class="title text-xl text-primary-600">
<%= gettext("No containers") %>
<%= display_emoji("😔") %>
</h2>
2022-12-03 21:56:14 -05:00
<% else %>
2023-03-23 22:07:25 -04:00
<%= if @view_table do %>
<.live_component
module={CanneryWeb.Components.ContainerTableComponent}
2023-05-12 21:50:23 -04:00
id="containers-index-table"
2023-03-23 22:07:25 -04:00
action={@live_action}
containers={@containers}
current_user={@current_user}
>
2023-03-23 22:07:25 -04:00
<:tag_actions :let={container}>
2023-02-04 10:28:13 -05:00
<div class="mx-4 my-2">
<.link
2023-04-14 23:34:11 -04:00
patch={~p"/containers/edit_tags/#{container}"}
2023-02-04 10:28:13 -05:00
class="text-primary-600 link"
2023-03-17 21:00:24 -04:00
aria-label={
dgettext("actions", "Tag %{container_name}", container_name: container.name)
}
2023-02-04 10:28:13 -05:00
>
<i class="fa-fw fa-lg fas fa-tags"></i>
</.link>
</div>
</:tag_actions>
2023-03-23 22:07:25 -04:00
<:actions :let={container}>
<.link
2023-04-14 23:34:11 -04:00
patch={~p"/containers/edit/#{container}"}
2023-03-23 22:07:25 -04:00
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>
2022-02-05 01:59:40 -05:00
2023-03-23 22:07:25 -04:00
<.link
2023-04-14 23:34:11 -04:00
patch={~p"/containers/clone/#{container}"}
2023-03-23 22:07:25 -04:00
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>
2022-11-10 19:02:35 -05:00
2023-03-23 22:07:25 -04:00
<.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}
2023-02-04 10:28:13 -05:00
>
2023-03-23 22:07:25 -04:00
<:tag_actions>
<div class="mx-4 my-2">
<.link
2023-04-14 23:34:11 -04:00
patch={~p"/containers/edit_tags/#{container}"}
2023-03-23 22:07:25 -04:00
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
2023-04-14 23:34:11 -04:00
patch={~p"/containers/edit/#{container}"}
2023-03-23 22:07:25 -04:00
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
2023-04-14 23:34:11 -04:00
patch={~p"/containers/clone/#{container}"}
2023-03-23 22:07:25 -04:00
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 %>
2022-01-31 21:42:24 -05:00
<% end %>
2022-12-03 21:56:14 -05:00
<% end %>
2022-01-31 21:42:24 -05:00
</div>
<%= case @live_action do %>
<% modifying when modifying in [:new, :edit, :clone] -> %>
2023-04-14 23:34:11 -04:00
<.modal return_to={~p"/containers"}>
<.live_component
module={CanneryWeb.ContainerLive.FormComponent}
id={@container.id || :new}
title={@page_title}
action={@live_action}
container={@container}
2023-04-14 23:34:11 -04:00
return_to={~p"/containers"}
current_user={@current_user}
/>
</.modal>
<% :edit_tags -> %>
2023-04-14 23:34:11 -04:00
<.modal return_to={~p"/containers"}>
<.live_component
module={CanneryWeb.ContainerLive.EditTagsComponent}
id={@container.id}
title={@page_title}
action={@live_action}
container={@container}
2023-04-14 23:34:11 -04:00
current_path={~p"/containers/edit_tags/#{@container}"}
current_user={@current_user}
/>
</.modal>
<% _ -> %>
<% end %>