# `PhoenixKitCatalogue.Web.ViewConfig`
[🔗](https://github.com/BeamLabEU/phoenix_kit_catalogue/blob/v0.19.1/lib/phoenix_kit_catalogue/web/view_config.ex#L1)

Per-user table view config (columns / sort / filters / view mode) for the
catalogue admin tables. Stored in `phoenix_kit_users.custom_fields` under
the `"catalogue_view_configs"` key — no dedicated table. Precedent:
`PhoenixKit.Notifications.Prefs`.

## Global sort

For scopes in `@global_sort_scopes` the SORT half of the config is not
per-user: it lives in a module setting (`catalogue_sort_<scope>`), so every
admin sees the same ordering — when one of them switches the catalogues
index to "Manual order" and drags rows, everyone else is looking at that
same order (the live half rides `Catalogue.PubSub`; see
`broadcast_view_sort_changed/4` and `CataloguesLive.put_cfg/3`).
`load/2` overlays the global value over whatever the user row stored, so
the per-user copy is inert for these scopes. Columns / filters / view mode
stay per-user everywhere.

# `defaults`

```elixir
@spec defaults(PhoenixKitCatalogue.Web.TableConfig.scope()) :: map()
```

# `global_sort?`

```elixir
@spec global_sort?(PhoenixKitCatalogue.Web.TableConfig.scope()) :: boolean()
```

# `load`

```elixir
@spec load(map() | nil, PhoenixKitCatalogue.Web.TableConfig.scope()) :: map()
```

# `load_global_sort`

```elixir
@spec load_global_sort(PhoenixKitCatalogue.Web.TableConfig.scope()) ::
  {String.t(), :asc | :desc}
```

The shared sort for a global-sort scope: the `catalogue_sort_<scope>`
setting (`"<column>:<asc|desc>"`), falling back to the scope's default
when unset or when it names a column that is no longer sortable.

# `normalize`

```elixir
@spec normalize(PhoenixKitCatalogue.Web.TableConfig.scope(), map()) :: map()
```

# `save`

```elixir
@spec save(map() | nil, PhoenixKitCatalogue.Web.TableConfig.scope(), map()) ::
  {:ok, map()} | {:error, term()}
```

# `save_global_sort`

```elixir
@spec save_global_sort(
  PhoenixKitCatalogue.Web.TableConfig.scope(),
  String.t(),
  :asc | :desc
) ::
  {:ok, term()} | {:error, term()}
```

# `scope_key`

```elixir
@spec scope_key(PhoenixKitCatalogue.Web.TableConfig.scope()) :: String.t()
```

---

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