From 8c734e2f74d9f876895d1fb084eaa6149fd26a82 Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Wed, 25 Dec 2024 11:43:11 +0200 Subject: [PATCH] Cleanup collectionStateMap --- .../CollectionComponent.ts | 5 +++-- .../src/dom_components/model/Component.ts | 19 ------------------- 2 files changed, 3 insertions(+), 21 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 7348e1f02..1233dac52 100644 --- a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts +++ b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts @@ -48,7 +48,7 @@ type CollectionDefinition = { }; export const collectionDefinitionKey = 'collectionDefinition'; -export const collectionsStateKey = 'collectionsItems'; +export const collectionsStateMapKey = 'collectionsItems'; export const innerCollectionStateKey = 'innerCollectionState'; export default class CollectionComponent extends Component { @@ -83,7 +83,7 @@ export default class CollectionComponent extends Component { }; const collectionsStateMap: CollectionsStateMap = { - ...props[collectionDefinitionKey], + ...props[collectionsStateMapKey], ...(collection_name && { [collection_name]: collectionState }), [innerCollectionStateKey]: collectionState, }; @@ -171,6 +171,7 @@ function resolveComponent( const componentDefinition: ComponentDefinition = { ...componentJSON, components: children, + [collectionsStateMapKey]: collectionsStateMap }; return componentDefinition; diff --git a/packages/core/src/dom_components/model/Component.ts b/packages/core/src/dom_components/model/Component.ts index 42986ffa2..fe93d6931 100644 --- a/packages/core/src/dom_components/model/Component.ts +++ b/packages/core/src/dom_components/model/Component.ts @@ -262,25 +262,6 @@ export default class Component extends StyleableModel { collection!: Components; constructor(props: ComponentProperties = {}, opt: ComponentOptions) { - if (Array.isArray(props['components'])) { - props['components']?.map((component) => { - return { - ...component, - collectionsItems: { - ...props.componentCollectionKey, - }, - }; - }); - } else if (typeof props['components'] === 'object') { - props['components'] = { - ...props['components'], - // @ts-ignore - collectionsItems: { - ...props.componentCollectionKey, - }, - }; - } - super(props, opt); bindAll(this, '__upSymbProps', '__upSymbCls', '__upSymbComps'); const em = opt.em;