Skip to content

Commit

Permalink
Use depth for page tree serializer root_or_leaf (#1864)
Browse files Browse the repository at this point in the history
Depth is a cached attribute on the page that does not need calculation and will always be correct even if the root page has been removed.

This commit helps to migrate to Alchemy 5 without making further changes to the page tree serializer. Without that change page trees that already have been migrated to "root-page-less" Alchemy 5 will have page toggle switches disappear in the first level.
  • Loading branch information
tvdeyen committed Jun 2, 2020
1 parent 1ac2918 commit 0a5d386
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/serializers/alchemy/page_tree_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def page_hash(page, has_children, level, folded)
urlname: page.urlname,
url_path: page.url_path,
level: level,
root: level == 1,
root_or_leaf: level == 1 || !has_children,
root: page.depth == 1,
root_or_leaf: page.depth == 1 || !has_children,
children: [],
}

Expand Down

0 comments on commit 0a5d386

Please sign in to comment.