2022-11-24 12:44:34 -05:00
|
|
|
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl">
|
|
|
|
<h1 class="text-xl">
|
|
|
|
<%= gettext("contexts") %>
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<.form
|
|
|
|
:let={f}
|
2023-03-16 19:49:19 -04:00
|
|
|
for={%{}}
|
|
|
|
as={:search}
|
2022-11-24 12:44:34 -05:00
|
|
|
phx-change="search"
|
|
|
|
phx-submit="search"
|
|
|
|
class="self-stretch flex flex-col items-stretch"
|
|
|
|
>
|
|
|
|
<%= text_input(f, :search_term,
|
|
|
|
class: "input input-primary",
|
|
|
|
value: @search,
|
|
|
|
phx_debounce: 300,
|
|
|
|
placeholder: gettext("search")
|
|
|
|
) %>
|
|
|
|
</.form>
|
|
|
|
|
|
|
|
<%= if @contexts |> Enum.empty?() do %>
|
|
|
|
<h1 class="self-center text-primary-500">
|
|
|
|
<%= gettext("no contexts found") %>
|
|
|
|
</h1>
|
|
|
|
<% else %>
|
|
|
|
<.live_component
|
|
|
|
module={MemexWeb.Components.ContextsTableComponent}
|
|
|
|
id="contexts-index-table"
|
|
|
|
current_user={@current_user}
|
|
|
|
contexts={@contexts}
|
|
|
|
>
|
|
|
|
<:actions :let={context}>
|
2023-02-04 11:29:06 -05:00
|
|
|
<.link
|
|
|
|
:if={is_owner?(context, @current_user)}
|
|
|
|
patch={Routes.context_index_path(@socket, :edit, context.slug)}
|
2023-03-14 23:51:50 -04:00
|
|
|
aria-label={gettext("edit %{context_slug}", context_slug: context.slug)}
|
2023-02-04 11:29:06 -05:00
|
|
|
>
|
|
|
|
<%= dgettext("actions", "edit") %>
|
|
|
|
</.link>
|
|
|
|
<.link
|
|
|
|
:if={is_owner_or_admin?(context, @current_user)}
|
|
|
|
href="#"
|
|
|
|
phx-click="delete"
|
|
|
|
phx-value-id={context.id}
|
|
|
|
data-confirm={dgettext("prompts", "are you sure?")}
|
2023-03-14 23:51:50 -04:00
|
|
|
aria-label={gettext("delete %{context_slug}", context_slug: context.slug)}
|
2023-02-04 11:29:06 -05:00
|
|
|
>
|
|
|
|
<%= dgettext("actions", "delete") %>
|
|
|
|
</.link>
|
2022-11-24 12:44:34 -05:00
|
|
|
</:actions>
|
|
|
|
</.live_component>
|
|
|
|
<% end %>
|
|
|
|
|
2023-02-04 11:29:06 -05:00
|
|
|
<.link
|
|
|
|
:if={@current_user}
|
|
|
|
patch={Routes.context_index_path(@socket, :new)}
|
|
|
|
class="self-end btn btn-primary"
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "new context") %>
|
|
|
|
</.link>
|
2022-11-24 12:44:34 -05:00
|
|
|
</div>
|
2022-07-25 20:11:08 -04:00
|
|
|
|
2023-02-04 11:29:06 -05:00
|
|
|
<.modal :if={@live_action in [:new, :edit]} return_to={Routes.context_index_path(@socket, :index)}>
|
|
|
|
<.live_component
|
|
|
|
module={MemexWeb.ContextLive.FormComponent}
|
|
|
|
id={@context.id || :new}
|
|
|
|
current_user={@current_user}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
context={@context}
|
|
|
|
return_to={Routes.context_index_path(@socket, :index)}
|
|
|
|
/>
|
|
|
|
</.modal>
|