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 authored Jun 2, 2020
1 parent 3cd167f commit 19e48fb
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 @@ -62,8 +62,8 @@ def page_hash(page, has_children, level, folded)
external_urlname: page.definition['redirects_to_external'] ? page.external_urlname : nil,
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 19e48fb

Please sign in to comment.