Files
personal-hub/90-dashboards/By-Context.md
T
Marcel Arndt a2ad5f5c6d import vault
2026-07-16 14:04:45 +02:00

1.0 KiB

By Context

All assigned entities (parent set), grouped by their root context — the topmost ancestor reached by walking the parent chain.

const ALL = dv.pages('""').where(p =>
  p.parent && !p.file.path.startsWith("_templates/")
);

function rootContext(page, depth = 0) {
  if (depth > 16) return "(cycle)";
  if (!page.parent) return page.file.name;
  const link = page.parent;
  const path = (link && link.path) || (typeof link === "string" ? link : null);
  if (!path) return "(unresolved)";
  const parent = dv.page(path);
  if (!parent) return path;
  if (!parent.parent) return parent.file.name;
  return rootContext(parent, depth + 1);
}

const groups = {};
for (const p of ALL) {
  const ctx = rootContext(p);
  (groups[ctx] = groups[ctx] || []).push(p);
}

for (const ctx of Object.keys(groups).sort()) {
  dv.header(2, ctx);
  dv.table(
    ["Entity", "Direct parent", "Status"],
    groups[ctx]
      .sort((a, b) => (a.file.name > b.file.name ? 1 : -1))
      .map(p => [p.file.link, p.parent, p.status ?? ""])
  );
}