From 19e48fba238bc464ceecf317b64344c7e6788fb5 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 2 Jun 2020 23:45:26 +0200 Subject: [PATCH] Use depth for page tree serializer root_or_leaf (#1864) 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. --- app/serializers/alchemy/page_tree_serializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/serializers/alchemy/page_tree_serializer.rb b/app/serializers/alchemy/page_tree_serializer.rb index eadaf20500..03fd2c01cc 100644 --- a/app/serializers/alchemy/page_tree_serializer.rb +++ b/app/serializers/alchemy/page_tree_serializer.rb @@ -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: [] }