PhoenixKitCRM.ColumnConfig (PhoenixKitCRM v0.2.2)

Copy Markdown View Source

Per-scope column configuration for CRM tables and card views.

Mirrors PhoenixKit.Users.TableColumns but is keyed by (user_uuid, scope) so each admin can have their own column layout per role page and for the Organizations page. Persistence goes through PhoenixKitCRM.UserRoleView.

Scopes

  • {:role, role_uuid} — users-of-role page; columns mirror the standard PhoenixKit user fields.
  • :organizations — Organizations page; users with account_type = "organization".

Summary

Functions

All available column ids for validation.

Available columns for a scope, split into :standard and :custom.

Returns a flat %{column_id => metadata} map for a scope.

Default selected column ids for a scope.

Returns metadata for a single column id, or nil. The :label field is translated via gettext.

Returns the selected column ids for a user+scope, falling back to defaults.

Persists the selected column ids for a user+scope. Empty list resets to defaults.

Filter input list to only valid column ids for the scope, preserving order.

Functions

all_column_ids(scope)

@spec all_column_ids(PhoenixKitCRM.UserRoleView.scope()) :: [String.t()]

All available column ids for validation.

available_columns(arg1)

@spec available_columns(PhoenixKitCRM.UserRoleView.scope()) :: %{
  standard: [{String.t(), map()}],
  custom: [{String.t(), map()}]
}

Available columns for a scope, split into :standard and :custom.

Each value is an ordered list of {column_id, metadata} tuples — standard columns follow the order declared in this module, custom columns follow the position ordering from PhoenixKit.Users.CustomFields.

column_metadata_map(scope)

@spec column_metadata_map(PhoenixKitCRM.UserRoleView.scope()) :: %{
  required(String.t()) => map()
}

Returns a flat %{column_id => metadata} map for a scope.

Use this once per render cycle and pass the result through render helpers (render_cell, column_label) instead of calling get_column_metadata/2 per cell — that path rebuilds available_columns/1 on every lookup.

default_columns(arg1)

@spec default_columns(PhoenixKitCRM.UserRoleView.scope()) :: [String.t()]

Default selected column ids for a scope.

get_column_metadata(scope, column_id)

@spec get_column_metadata(PhoenixKitCRM.UserRoleView.scope(), String.t()) ::
  map() | nil

Returns metadata for a single column id, or nil. The :label field is translated via gettext.

get_columns(user_uuid, scope)

@spec get_columns(binary(), PhoenixKitCRM.UserRoleView.scope()) :: [String.t()]

Returns the selected column ids for a user+scope, falling back to defaults.

update_columns(user_uuid, scope, columns)

@spec update_columns(binary(), PhoenixKitCRM.UserRoleView.scope(), [String.t()]) ::
  {:ok, PhoenixKitCRM.UserRoleViewConfig.t()} | {:error, Ecto.Changeset.t()}

Persists the selected column ids for a user+scope. Empty list resets to defaults.

validate_columns(scope, columns)

@spec validate_columns(PhoenixKitCRM.UserRoleView.scope(), [String.t()]) :: [
  String.t()
]

Filter input list to only valid column ids for the scope, preserving order.