Browse Source

Cleanup collectionStateMap

pull/6359/head
mohamedsalem401 1 year ago
parent
commit
8c734e2f74
  1. 5
      packages/core/src/data_sources/model/collection_component/CollectionComponent.ts
  2. 19
      packages/core/src/dom_components/model/Component.ts

5
packages/core/src/data_sources/model/collection_component/CollectionComponent.ts

@ -48,7 +48,7 @@ type CollectionDefinition = {
}; };
export const collectionDefinitionKey = 'collectionDefinition'; export const collectionDefinitionKey = 'collectionDefinition';
export const collectionsStateKey = 'collectionsItems'; export const collectionsStateMapKey = 'collectionsItems';
export const innerCollectionStateKey = 'innerCollectionState'; export const innerCollectionStateKey = 'innerCollectionState';
export default class CollectionComponent extends Component { export default class CollectionComponent extends Component {
@ -83,7 +83,7 @@ export default class CollectionComponent extends Component {
}; };
const collectionsStateMap: CollectionsStateMap = { const collectionsStateMap: CollectionsStateMap = {
...props[collectionDefinitionKey], ...props[collectionsStateMapKey],
...(collection_name && { [collection_name]: collectionState }), ...(collection_name && { [collection_name]: collectionState }),
[innerCollectionStateKey]: collectionState, [innerCollectionStateKey]: collectionState,
}; };
@ -171,6 +171,7 @@ function resolveComponent(
const componentDefinition: ComponentDefinition = { const componentDefinition: ComponentDefinition = {
...componentJSON, ...componentJSON,
components: children, components: children,
[collectionsStateMapKey]: collectionsStateMap
}; };
return componentDefinition; return componentDefinition;

19
packages/core/src/dom_components/model/Component.ts

@ -262,25 +262,6 @@ export default class Component extends StyleableModel<ComponentProperties> {
collection!: Components; collection!: Components;
constructor(props: ComponentProperties = {}, opt: ComponentOptions) { 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); super(props, opt);
bindAll(this, '__upSymbProps', '__upSymbCls', '__upSymbComps'); bindAll(this, '__upSymbProps', '__upSymbCls', '__upSymbComps');
const em = opt.em; const em = opt.em;

Loading…
Cancel
Save