<%= if @live_action in [:new, :edit] do %> <%= live_modal @socket, Shift73kWeb.UserManagement.FormComponent, id: @user.id || :new, title: @page_title, action: @live_action, user: @user, current_user: @current_user %> <% end %> <%= if @delete_user do %> <%= live_modal @socket, Shift73kWeb.UserManagement.DeleteComponent, id: @delete_user.id, title: "Delete User", delete_user: @delete_user, current_user: @current_user %> <% end %>

<%= icon_div @socket, "bi-people", [class: "icon baseline"] %> Listing Users

<%# filtering and new item creation %>
<%= live_patch to: Routes.user_management_index_path(@socket, :new, Enum.into(@query, [])), class: "btn btn-primary mb-3 mb-sm-0" do %> <%= icon_div @socket, "bi-person-plus", [class: "icon baseline me-1"] %> New User <% end %> <%= form_for :filter, "#", [phx_change: "filter-change"], fn flt -> %>
<%= icon_div @socket, "bi-filter", [class: "icon"] %> <%= text_input flt, :filter, name: "filter", class: "form-control", placeholder: "Filter users...", value: @query.filter %> <%= if @query.filter == "" do %>
<% end %>
<%# main data table %>
<%= if !@page do %> <% else %> <%= for user <- @page.entries do %> <% end %> <% end %>
Email <%= if @query.sort_by == "email", do: icon_div @socket, (@query.sort_order == "desc" && "bi-sort-up-alt" || "bi-sort-down-alt"), [class: "icon baseline ms-1"] %> Role <%= if @query.sort_by == "role", do: icon_div @socket, (@query.sort_order == "desc" && "bi-sort-up-alt" || "bi-sort-down-alt"), [class: "icon baseline ms-1"] %> Created at <%= if @query.sort_by == "inserted_at", do: icon_div @socket, (@query.sort_order == "desc" && "bi-sort-up-alt" || "bi-sort-down-alt"), [class: "icon baseline ms-1"] %> Confirmed?
Loading...
<%= user.email %> <%= user.role |> Atom.to_string() |> String.capitalize() %> <%= dt_out(user.inserted_at) %> <%= if user.confirmed_at do %> Yes <%= icon_div @socket, "bi-check", [class: "icon baseline fs-4 text-success"], [role: "img", aria_hidden: false] %> <% else %> No <%= icon_div @socket, "bi-x", [class: "icon baseline fs-4 text-warning"], [role: "img", aria_hidden: false] %> <% end %> <%= live_patch to: Routes.user_management_index_path(@socket, :edit, user.id, Enum.into(@query, [])), class: "btn btn-outline-primary btn-sm text-nowrap" do %> <%= icon_div @socket, "bi-pencil", [class: "icon baseline", style: "margin-right:0.125rem;"] %> Edit <% end %> <%= if Roles.can?(@current_user, user, :delete) do %> <% end %>
<%# pagination interface %> <%= if @page do %>
<%#
%> <%# items per page selector %>
<%= form_for :page_size, "#", [phx_change: "page-size-change"], fn pgsz -> %> <%= select pgsz, :page_size, [10, 15, 20, 30, 50, 100] |> Enum.map(fn n -> {"#{n} per page", n} end), value: @query.page_size, id: "table_page_size_page_size", name: "page_size", class: "form-select" %> <% end %> <%= @page.total_entries %> found
<%# main pagination %>
<% end %>