PhoenixKitManufacturing.ColumnConfig (PhoenixKitManufacturing v0.3.2)

Copy Markdown View Source

Shared column-registry engine for Manufacturing's admin list LiveViews.

A 1:1 adaptation of PhoenixKitWarehouse.ColumnConfig — same macro, same filter/sort primitives, only the use Gettext backend and module names changed. It currently backs a single consumer, PhoenixKitManufacturing.ColumnConfig.Machines (the Machines index), but keeps the use PhoenixKitManufacturing.ColumnConfig, scope: "..." shape so any future Manufacturing list page that grows configurable columns (Operations, Defect Reasons, …) can adopt the same engine instead of a bespoke one-off, mirroring how the warehouse module reused this engine across six near-identical *_column_config.ex files.

Each column is a map with structural metadata:

  • :id — string identifier persisted in the per-user view config.
  • :label — zero-arity fn returning the translated header label.
  • :default? — included in default_columns/0.
  • :align:left (default) or :right.
  • :sortable? / :sort_key — sortability + key extractor (entry -> term).
  • :default_dir — direction the column toggles to on first sort.
  • :filterable? / :filter_type:text | :enum | :date_range | :numeric_range.

  • :filter_apply(entries, value) -> entries.
  • :filter_options — for :enum only, (entries -> [{value, label}]).

Cell/header rendering stays in the LiveView — only structural metadata lives here so it can be reused for table, sort headers, and filter chips.

Summary

Functions

date_of(dt)

date_range_filter(get_fn)

datetime_to_unix(dt)

decimal_to_float(d)

distinct_options(entries, key)

enum_filter(get_fn)

numeric_range_filter(get_fn)

text_filter(get_fn)

to_number(d)