Search documentation of phoenix_kit

# PhoenixKit.Emails.TableColumns (phoenix_kit v1.6.19)

View Source

Manages table column customization for email logs display.

Provides functionality to:

- Define available columns for email logs table
- Load user's column preferences from Settings
- Save column preferences to Settings
- Reorder columns via drag-and-drop

Column preferences are stored in Settings under the key "emails_table_columns".

# Summary

## Functions

get_available_columns()

Returns all available columns for email logs table with metadata.

get_user_table_columns()

Loads user's selected columns from Settings or returns defaults.

reorder_columns(current_columns, arg2)

Reorders columns based on drag-and-drop interaction.

reset_columns()

Resets columns to default configuration.

update_user_table_columns(selected_columns)

Saves user's column preferences to Settings.

# Functions

# get_available_columns()

Returns all available columns for email logs table with metadata.

Column structure:

- `field`: Database field name
- `label`: Display label in UI
- `type`: Data type (:string, :datetime, :badge, :actions, :activity_events, :details_composite)
- `required`: Cannot be hidden if true

## Examples

    iex> PhoenixKit.Emails.TableColumns.get_available_columns()
    [
      %{field: "to", label: "Email", type: :string, required: true},
      %{field: "subject", label: "Subject", type: :string, required: true},
      ...
    ]

# get_user_table_columns()

Loads user's selected columns from Settings or returns defaults.

Returns list of column field names in user's preferred order.

## Examples

    iex> PhoenixKit.Emails.TableColumns.get_user_table_columns()
    ["to", "subject", "status", "sent_at", "actions"]

# reorder_columns(current_columns, arg2)

Reorders columns based on drag-and-drop interaction.

## Parameters

- `current_columns`: Current list of selected columns
- `params`: Map with "from" (source index) and "to" (target index)

## Examples

    iex> PhoenixKit.Emails.TableColumns.reorder_columns(["to", "subject", "status"], %{"from" => 0, "to" => 2})
    ["subject", "status", "to"]

# reset_columns()

Resets columns to default configuration.

## Examples

    iex> PhoenixKit.Emails.TableColumns.reset_columns()
    ["to", "subject", "status", "sent_at", "actions"]

# update_user_table_columns(selected_columns)

Saves user's column preferences to Settings.

## Parameters

- `selected_columns`: List of column field names in desired order

## Examples

    iex> PhoenixKit.Emails.TableColumns.update_user_table_columns(["to", "subject", "status", "actions"])
    {:ok, _setting}