MishkaDocumentWeb.Templates.DocumentSection (Mishka Document v0.0.1)

Copy Markdown View Source

The sections list: full-width cards beside a rail of workspace panels.

Declared only by MishkaDocument.Section, and it reads that record directly rather than by column position — a card is a specific shape (a breadcrumb of chips, a title over its slug, a preview of the content, a meta line and two review badges) that a generic position mapping cannot describe. The resource's columns stay the field-selection contract and the sort menu's vocabulary.

The rail

Whatever the page hands in through :rail — Software Info, Site Information, Maintainers, Recent Activity — is laid out by this template rather than beside it, which is the only way its position can follow the viewport. The four class strings come from MishkaGervaz.Table.Templates.Shared.rail_class/2, so switching to the plain table keeps the rail in the same place instead of stacking it on top of the records.

The expanded panel

:expand here is server-rendered: the Comment-style toggle pushes expand_row, the page answers by rendering its own Notes / Recent Activity panel and pushing it back as expanded_html, and this template only frames it. That is why state.expanded_data carries HTML rather than a payload — see MishkaDocumentWeb.Live.Admin.Dashboard.Section.Index.render_expanded_section/2.

Features

  • :filter - the toolbar: Add Section, search, the archive switch, an Advanced panel, the view switch
  • :select - per-card selection for bulk operations, with a Select all row over the list
  • :bulk_actions - bulk actions on the selected cards
  • :paginate - the page-size picker and numbered pages under the list
  • :expand - the Advanced Details panel

The furniture around the cards is MishkaCmsCoreWeb.Templates.CardChrome, which MishkaDocumentWeb.Templates.IssueCard draws from too. Pairs with MishkaCmsCoreWeb.UIAdapters.Admin, which draws the archive switch, the view switch and the row actions.

Summary

Functions

One aggregate or calculation off the record, or 0 when the viewer cannot see it.

The chips between "Documentation" and the section's own title — its ancestors, nearest last.

How many drafts of this section are still waiting on a review — content and technical together.

The one-line taste of the section's content the card shows: its text, without its markup (MishkaDocument.ContentText).

One section card.

The colours a review-status badge wears, falling back to :pending — the attribute's default.

The words a review-status badge reads, in the viewer's language.

The version a section was last changed in, falling back to the attribute's own default.

Functions

count(record, key)

@spec count(map(), atom()) :: non_neg_integer()

One aggregate or calculation off the record, or 0 when the viewer cannot see it.

crumbs(record)

@spec crumbs(map()) :: [String.t()]

The chips between "Documentation" and the section's own title — its ancestors, nearest last.

breadcrumb_path is a field-policy gated calculation, so it arrives as %Ash.NotLoaded{} for a viewer who cannot see it; that reads as a section with no ancestors rather than taking the card down.

pending_drafts(record)

@spec pending_drafts(map()) :: non_neg_integer()

How many drafts of this section are still waiting on a review — content and technical together.

Both are aggregates behind the same field policy as the calculations, so either can arrive unloaded.

preview(record)

@spec preview(map()) :: String.t() | nil

The one-line taste of the section's content the card shows: its text, without its markup (MishkaDocument.ContentText).

Kept to a single line by the design, so it is cut at a line's length and left for CSS to ellipsise.

render_bulk_actions(assigns)

Callback implementation for MishkaGervaz.Table.Behaviours.Template.render_bulk_actions/1.

render_empty(assigns)

Callback implementation for MishkaGervaz.Table.Behaviours.Template.render_empty/1.

render_error(assigns)

Callback implementation for MishkaGervaz.Table.Behaviours.Template.render_error/1.

render_filters(assigns)

Callback implementation for MishkaGervaz.Table.Behaviours.Template.render_filters/1.

render_header(assigns)

Callback implementation for MishkaGervaz.Table.Behaviours.Template.render_header/1.

render_item(assigns)

One section card.

On a narrow screen the row rewraps rather than shrinking: the checkbox and the action squares take the first line on their own, the chips follow on the second, and the title, preview and meta run full width underneath. Squeezing all three columns onto a phone is what pushed the last action square off the card.

render_pagination(assigns)

Callback implementation for MishkaGervaz.Table.Behaviours.Template.render_pagination/1.

render_template_switcher(assigns)

Callback implementation for MishkaGervaz.Table.Behaviours.Template.render_template_switcher/1.

review(status)

@spec review(atom()) :: String.t()

The colours a review-status badge wears, falling back to :pending — the attribute's default.

review_label(status)

@spec review_label(atom()) :: String.t()

The words a review-status badge reads, in the viewer's language.

version(record)

@spec version(map()) :: String.t()

The version a section was last changed in, falling back to the attribute's own default.