From 72539f13415ba98294f72e18178a719f49128b91 Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Thu, 19 Dec 2024 21:24:48 +0200 Subject: [PATCH] refactor componentCollectionKey --- .../model/collection_component/CollectionComponent.ts | 3 ++- packages/core/src/dom_components/model/Component.ts | 9 +++++---- 2 files changed, 7 insertions(+), 5 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 c2b6d5e5e..9a180ad30 100644 --- a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts +++ b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts @@ -39,6 +39,7 @@ interface CollectionDefinition { config: CollectionConfig; // Loop configuration details block: ComponentDefinition; // Component definition for each iteration } +export const componentCollectionKey = 'collectionsItems'; export default class CollectionComponent extends Component { constructor(props: CollectionDefinition & ComponentProperties, opt: ComponentOptions) { @@ -91,7 +92,7 @@ export default class CollectionComponent extends Component { } let components = resolveBlockValues(allCollectionItems, block); - components['collectionsItems'] = allCollectionItems; + components[componentCollectionKey] = allCollectionItems; return components; }); diff --git a/packages/core/src/dom_components/model/Component.ts b/packages/core/src/dom_components/model/Component.ts index 35b22ebec..7cbd25297 100644 --- a/packages/core/src/dom_components/model/Component.ts +++ b/packages/core/src/dom_components/model/Component.ts @@ -55,6 +55,7 @@ import TraitDataVariable from '../../data_sources/model/TraitDataVariable'; import { ConditionalVariableType, DataCondition } from '../../data_sources/model/conditional_variables/DataCondition'; import { isDynamicValue, isDynamicValueDefinition } from '../../data_sources/model/utils'; import { DynamicValueDefinition } from '../../data_sources/types'; +import { componentCollectionKey } from '../../data_sources/model/collection_component/CollectionComponent'; export interface IComponent extends ExtractMethods { } @@ -266,8 +267,8 @@ export default class Component extends StyleableModel { props['components']?.map(component => { return { ...component, - collectionsItems: { - ...props.collectionsItems + [componentCollectionKey]: { + ...props.componentCollectionKey } } }) @@ -275,8 +276,8 @@ export default class Component extends StyleableModel { props['components'] = { ...props['components'], // @ts-ignore - collectionsItems: { - ...props.collectionsItems + [componentCollectionKey]: { + ...props.componentCollectionKey } } }