MishkaCmsMigrationWeb.Live.Admin.Dashboard.Item.Tree (Mishka CMS Migration v0.0.1)

Copy Markdown View Source

The Items table's Map view (MishkaCmsMigration.MigrationItem's switchable_templates): a Gervaz table template that draws the items as the source nests them, for deciding where each part of a site goes before it is imported. The List view is the stock MishkaGervaz.Table.Templates.Table, and the table's template switcher moves between them.

Each kind is a section, in the order the sources walk the kinds, its items a tree by their source_parent, siblings by title: an item under the one the source puts it under, indented, and a chevron on an item with children that folds them away and back (Phoenix.LiveView.JS). An item whose parent the table has not loaded, or that sits under none, is at the top of its kind, so a kind that does not nest, such as the tags, is a flat list, and an item in a loop of parents is drawn once. Each row shows its checkbox, title and source id, its Plan (MishkaCmsMigration.MigrationItem.plan_cell/1, which names the record an item is mapped to), and its row actions: Dry run this item and Import this item, Map to… for a category or a tag, Leave out and Bring back.

The tree is drawn from the rows the table has loaded (keep_loaded_records), as a LiveView stream holds no nesting; Load more adds the next page to it. An item whose parent the table has not loaded, such as one the filters keep out, is drawn under its parents all the same, from what is read of the items above it with its page (MishkaCmsMigration.MigrationItem's :ancestors): each of them is a lighter node (data-ghost), with where it stands (MishkaCmsMigration.MigrationItem.standing/1) and its row actions, and none is picked with the checkboxes; one the source does not list says Not in the source. An item that waits for its parent says so under its title (item-tree-waits, MishkaCmsMigration.MigrationItem.waits_for_parent/1). The filters, the bulk actions, the switcher, the states and the pagination are Gervaz's own (MishkaGervaz.Table.Templates.Shared).

Every part carries a data-role (item-tree, item-tree-kind with data-kind, item-tree-node with data-item-id, data-source-id and data-parent, item-tree-children, item-tree-fold), so a test reads the tree without reading its markup.

Summary

Functions

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 item of the tree, @node ({item, its children's nodes}), and the items under it, drawn folded open.

render_loading(assigns)

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

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.