PhoenixKitCatalogue.Web.ViewConfig (PhoenixKitCatalogue v0.19.1)

Copy Markdown View Source

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.

Summary

Functions

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.

Functions

defaults(scope)

global_sort?(scope)

load(user, scope)

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

load_global_sort(scope)

@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(scope, raw)

save(user, scope, cfg)

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

save_global_sort(scope, sort_by, sort_dir)

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

scope_key(scope)