MishkaDocument.WorkspaceScope (Mishka Document v0.0.1)

Copy Markdown View Source

Which workspaces the admin list shows: one row per document, not one per translation.

The rule and the reasoning are MishkaCmsCore.LanguageEditions', which every translatable admin list shares. What is workspace-specific is what an edition chip reads: a variant is itself a workspace, so its progress lives on its own health_metrics, and that has to be asked for through the variant relationship — which the table's preload DSL cannot express, since it takes a name rather than a nested load.

See MishkaDocument.Workspace, which declares both sibling relationships, and MishkaDocumentWeb.Templates.DocumentCard, which draws the chips.

Summary

Functions

Loads how far along each of a workspace's sibling editions is, so a chip can read FA · 76%.

Narrows the list to master editions while it is collapsed — see MishkaCmsCore.LanguageEditions.collapsed?/1.

Whether the table is currently showing search results.

Whether a table action is drawn: the table shows status records (:active or :archived) and its viewer holds permission. For a Gervaz visible function.

Functions

load_edition_progress(query, state)

@spec load_edition_progress(Ash.Query.t(), map()) :: Ash.Query.t()

Loads how far along each of a workspace's sibling editions is, so a chip can read FA · 76%.

scope_to_masters(query, state)

@spec scope_to_masters(Ash.Query.t(), map()) :: Ash.Query.t()

Narrows the list to master editions while it is collapsed — see MishkaCmsCore.LanguageEditions.collapsed?/1.

The on_load contract is fn query, state -> query.

searching?(state)

@spec searching?(map()) :: boolean()

Whether the table is currently showing search results.

shown?(arg1, status, permission)

@spec shown?(map(), :active | :archived, String.t()) :: boolean()

Whether a table action is drawn: the table shows status records (:active or :archived) and its viewer holds permission. For a Gervaz visible function.

visible fn _record, state ->
  MishkaDocument.WorkspaceScope.shown?(state, :active, "admin:dashboard:document:workspace")
end