PhoenixKit.Users.TableColumns (phoenix_kit v1.5.1)
View SourceTable column configuration for user management dashboard.
Provides dynamic column selection including standard user fields and custom fields from the V17 custom fields system. Manages column metadata, ordering, and persistence through the settings system.
Summary
Functions
Checks if a column is required (cannot be hidden).
Gets all available column IDs from both standard and custom fields.
Gets all available columns for the user table.
Gets metadata for a specific column.
Gets the default column configuration.
Gets the current user table columns from settings.
Reorders columns based on user drag-and-drop interaction.
Updates the user table columns in settings.
Validates a list of column IDs against available columns.
Functions
Checks if a column is required (cannot be hidden).
Examples
iex> PhoenixKit.Users.TableColumns.column_required?("email")
true
iex> PhoenixKit.Users.TableColumns.column_required?("username")
false
Gets all available column IDs from both standard and custom fields.
Gets all available columns for the user table.
Returns a map combining standard columns with active custom fields. Each column includes metadata like label, field path, and rendering information.
Examples
iex> PhoenixKit.Users.TableColumns.get_available_columns()
%{
"email" => %{label: "Email", field: "email", required: true},
"username" => %{label: "Username", field: "username", required: false},
"custom_123" => %{label: "Department", field: "custom_data.department", field_id: 123, field_type: "select", required: false}
}
Gets metadata for a specific column.
Examples
iex> PhoenixKit.Users.TableColumns.get_column_metadata("email")
%{label: "Email", field: "email", required: true}
Gets the default column configuration.
Returns the list of columns that should be visible by default if no user preference is saved in settings.
Gets the current user table columns from settings.
Returns the user's saved column preference, or the default configuration if no preference is saved.
Examples
iex> PhoenixKit.Users.TableColumns.get_user_table_columns()
["email", "username", "role", "status", "registered"]
Reorders columns based on user drag-and-drop interaction.
Takes the new order from the frontend and ensures it's valid and complete. Actions column is always appended at the end.
Examples
iex> PhoenixKit.Users.TableColumns.reorder_columns(["username", "email"], ["email", "username", "actions"])
["username", "email", "actions"]
Updates the user table columns in settings.
Saves the user's column preference to the settings table for persistence across page reloads and sessions.
Examples
iex> PhoenixKit.Users.TableColumns.update_user_table_columns(["email", "role", "status"])
{:ok, %Setting{}}
Validates a list of column IDs against available columns.
Returns only the valid column IDs from the input list.
Examples
iex> PhoenixKit.Users.TableColumns.validate_columns(["email", "invalid_id", "role"])
["email", "role"]