# `PhoenixKitManufacturing.Web.ColumnManagement`
[🔗](https://github.com/BeamLabEU/phoenix_kit_manufacturing/blob/0.4.1/lib/phoenix_kit_manufacturing/web/column_management.ex#L1)

`use`-macro that injects column-management `handle_event/3` callbacks into a
LiveView. Generic across scopes — pass the column-config module and scope via
options:

    use PhoenixKitManufacturing.Web.ColumnManagement,
      column_config: PhoenixKitManufacturing.ColumnConfig.Machines,
      scope: "manufacturing_machines"

This is a 1:1 adaptation of `PhoenixKitWarehouse.Web.ColumnManagement` —
same macro, same event contract, only the module namespace and the
`ViewConfigs`/`Gettext` backends it delegates to changed.

## Required socket assigns (set them in `mount/3`)

  * `:current_user_uuid` — used for persistence keying.
  * `:selected_columns` — initial list of visible column ids.
  * `:active_filters` — initial list of column ids with active filter inputs.
  * `:filter_values` — initial `%{column_id => value}` map (session-local).
  * `:show_column_modal` — `false`.
  * `:temp_selected_columns` / `:temp_active_filters` — `nil`.

Use `assign_column_state/2` to bootstrap all of the above from the persisted
config.

## View refresh

Filter changes (`set_filter_value`, `clear_filter`, save) need to recompute
the visible list. The macro calls `__view_config_changed__/1` after mutating
state. The default implementation is identity; the host LV overrides it:

    defoverridable __view_config_changed__: 1
    def __view_config_changed__(socket) do
      # rebuild socket.assigns.entries from source + selected/filters/sort
    end

## Persisted shape (`view_config`)

    %{
      "columns" => ["id", ...],
      "active_filters" => ["id", ...]
    }

Filter values are intentionally NOT persisted — they reset between sessions
to avoid the "ghost filter" UX (user opens the page next week and finds zero
results because of a saved filter they forgot about).

# `assign_column_state`

```elixir
@spec assign_column_state(Phoenix.LiveView.Socket.t(), module()) ::
  Phoenix.LiveView.Socket.t()
```

Bootstrap all column-management assigns from the persisted config. Pass the
column-config module so this helper stays scope-agnostic.

# `save_view_config`

Persist the selected columns + active filters for the current user and apply
them to the socket. Kept here (rather than in the `__using__` quote) so the
macro stays thin; `view_module.__view_config_changed__/1` lets each using
LiveView hook in after a successful save.

---

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