From a1fea6e371198c746c3fe5948495af1a34e2f96c Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Wed, 25 Dec 2024 11:36:28 +0200 Subject: [PATCH] Refactor collection keys --- .../collection_component/CollectionComponent.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts index 39cbd322b..7348e1f02 100644 --- a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts +++ b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts @@ -8,9 +8,11 @@ import DataSource from '../DataSource'; import { ObjectAny } from '../../../common'; import EditorModel from '../../../editor/model/Editor'; -export const CollectionVariableType = 'collection-component'; +export const CollectionComponentType = 'collection-component'; +export const CollectionVariableType = 'parent-collection-variable'; + type CollectionVariable = { - type: 'parent-collection-variable'; + type: typeof CollectionVariableType; variable_type: keyof CollectionState; collection_name?: string; path?: string; @@ -39,7 +41,7 @@ type CollectionsStateMap = { }; type CollectionDefinition = { - type: typeof CollectionVariableType; + type: typeof CollectionComponentType; collection_name?: string; config: CollectionConfig; block: ComponentDefinition; @@ -99,7 +101,7 @@ export default class CollectionComponent extends Component { const conditionalCmptDef = { ...props, - type: CollectionVariableType, + type: CollectionComponentType, components: components, dropbbable: false, }; @@ -108,7 +110,7 @@ export default class CollectionComponent extends Component { } static isComponent(el: HTMLElement) { - return toLowerCase(el.tagName) === CollectionVariableType; + return toLowerCase(el.tagName) === CollectionComponentType; } } @@ -186,11 +188,11 @@ function resolveBlockValues(collectionsStateMap: CollectionsStateMap, block: Obj let hasCollectionVariable = false; if (typeof blockValue === 'object') { - const isCollectionVariable = blockValue.type === 'parent-collection-variable'; + const isCollectionVariable = blockValue.type === CollectionVariableType; if (isCollectionVariable) { const { variable_type, - collection_name = 'innerMostCollectionItem', + collection_name = innerCollectionStateKey, path = '', } = blockValue as CollectionVariable; const collectionItem = collectionsStateMap[collection_name];