From ecc649180f7bfb56ed459b3395ceb9c48ea3c12b Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 2 Apr 2020 06:29:31 +0100 Subject: [PATCH] better naming of default child view --- packages/builder/src/builderStore/store/backend.js | 5 ++++- packages/core/src/templateApi/hierarchy.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 65f012e34c..9f6eb25d63 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -198,7 +198,10 @@ export const saveCurrentNode = store => () => { const defaultIndex = templateApi(state.hierarchy).getNewIndexTemplate( cloned.parent() ) - defaultIndex.name = `all_${cloned.name}s` + defaultIndex.name = hierarchyFunctions.isTopLevelIndex(cloned) + ? `all_${cloned.name}s` + : `${cloned.parent().name}_${cloned.name}s` + defaultIndex.allowedRecordNodeIds = [cloned.nodeId] } diff --git a/packages/core/src/templateApi/hierarchy.js b/packages/core/src/templateApi/hierarchy.js index 6136a7c38b..25e5162ff0 100644 --- a/packages/core/src/templateApi/hierarchy.js +++ b/packages/core/src/templateApi/hierarchy.js @@ -279,4 +279,6 @@ export default { fieldReversesReferenceToNode, fieldReversesReferenceToIndex, getFlattenedHierarchy, + isTopLevelIndex, + isTopLevelRecord, }