PhoenixKitCRM.Web.CellFormat (PhoenixKitCRM v0.2.2)

Copy Markdown View Source

Shared formatters for CRM table/card cells.

Currently covers user-defined custom field values (format_custom_value/2) and the custom_* cell renderer used by RoleView and OrganizationsView.

Summary

Functions

Formats a custom field value according to its declared type.

Renders a "custom_<key>" column for the given user, given a resolved column_meta map (%{column_id => metadata} — see PhoenixKitCRM.ColumnConfig.column_metadata_map/1). Returns "—" if the column is unknown or the value is missing.

Functions

format_custom_value(list, arg2)

@spec format_custom_value(any(), String.t() | nil) :: String.t()

Formats a custom field value according to its declared type.

render_custom_cell(column_meta, column_id, user)

@spec render_custom_cell(%{optional(String.t()) => map()}, String.t(), map()) ::
  String.t()

Renders a "custom_<key>" column for the given user, given a resolved column_meta map (%{column_id => metadata} — see PhoenixKitCRM.ColumnConfig.column_metadata_map/1). Returns "—" if the column is unknown or the value is missing.

Callers should compute column_meta once per render cycle and pass it through, rather than calling ColumnConfig.get_column_metadata/2 per cell.