# `PhoenixKitManufacturing.ViewConfigs`
[🔗](https://github.com/BeamLabEU/phoenix_kit_manufacturing/blob/0.4.1/lib/phoenix_kit_manufacturing/view_configs.ex#L1)

Minimal per-user, per-scope view-preference store for Manufacturing's
admin list pages — currently the Machines index's saved columns and
active filters (see `PhoenixKitManufacturing.ColumnConfig` /
`Web.ColumnManagement`).

Core owns the module's tables now (see
`PhoenixKit.Migrations.Postgres.V144`); a standalone preferences table
would need its own core PR. Instead this module stores a
`%{"columns" => [...], "active_filters" =>
[...]}`-shaped map as a JSON-encoded blob in `phoenix_kit_settings`
(core's flat key-value table), one row per `(scope, user_uuid)` pair,
keyed `"manufacturing_view_config:<scope>:<user_uuid>"`.

This is a 1:1 adaptation of `PhoenixKitWarehouse.ViewConfigs` — same
trade-off applies: `phoenix_kit_settings` has no secondary index on "all
rows for this user", which is fine at this module's scale (currently one
scope — `manufacturing_machines` — times however many users actually
customize columns) but is not a pattern to reach for at higher fan-out.

# `get_view_config`

```elixir
@spec get_view_config(binary(), String.t()) :: map()
```

Returns the user's saved view config for `scope`, or `%{}` if none exists yet.

# `merge_view_config`

```elixir
@spec merge_view_config(binary(), String.t(), map()) ::
  {:ok, map()} | {:error, Ecto.Changeset.t()}
```

Merges `partial` into the user's existing view config for `scope` and
persists the result. Keys absent from `partial` are preserved.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
