Browse Source

refactor componentCollectionKey

collection-component
mohamedsalem401 2 years ago
parent
commit
72539f1341
  1. 3
      packages/core/src/data_sources/model/collection_component/CollectionComponent.ts
  2. 9
      packages/core/src/dom_components/model/Component.ts

3
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;
});

9
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<Component> { }
@ -266,8 +267,8 @@ export default class Component extends StyleableModel<ComponentProperties> {
props['components']?.map(component => {
return {
...component,
collectionsItems: {
...props.collectionsItems
[componentCollectionKey]: {
...props.componentCollectionKey
}
}
})
@ -275,8 +276,8 @@ export default class Component extends StyleableModel<ComponentProperties> {
props['components'] = {
...props['components'],
// @ts-ignore
collectionsItems: {
...props.collectionsItems
[componentCollectionKey]: {
...props.componentCollectionKey
}
}
}

Loading…
Cancel
Save