Browse Source

Fix collection items traits

pull/6359/head
mohamedsalem401 1 year ago
parent
commit
fcc8c45e8c
  1. 2
      packages/core/src/data_sources/model/collection_component/CollectionComponent.ts
  2. 5
      packages/core/src/dom_components/model/Component.ts
  3. 4
      packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts
  4. 3
      packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts
  5. 6
      packages/core/test/specs/data_sources/model/collection_component/__snapshots__/CollectionComponent.ts.snap

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

@ -140,7 +140,7 @@ function getCollectionItems(
[keyCollectionsStateMap]: collectionsStateMap,
},
opt,
).clone({ symbol: true });
);
blockSymbolMain!.setSymbolOverride([keyCollectionsStateMap]);
}
blockSymbolMain!.set(keyCollectionsStateMap, collectionsStateMap);

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

@ -966,7 +966,7 @@ export default class Component extends StyleableModel<ComponentProperties> {
const value = trait.getInitValue();
if (trait.changeProp) {
this.set(name, value);
!this.get(name) && this.set(name, value);
} else {
if (name && value) attrs[name] = value;
}
@ -1319,7 +1319,8 @@ export default class Component extends StyleableModel<ComponentProperties> {
clone(opt: { symbol?: boolean; symbolInv?: boolean } = {}): this {
const em = this.em;
const attr = {
...this.componentDVListener.getPropsDefsOrValues(this.attributes),
...this.attributes,
...this.componentDVListener.getDynamicPropsDefs(),
};
const opts = { ...this.opt };
const id = this.getId();

4
packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts

@ -90,10 +90,6 @@ export class ComponentDynamicValueWatcher {
return this.attributeWatcher.getSerializableValues(attributes);
}
getPropsDefsOrValues(props: ObjectAny) {
return this.propertyWatcher.getSerializableValues(props);
}
destroy() {
this.propertyWatcher.removeListeners();
this.attributeWatcher.removeListeners();

3
packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts

@ -167,8 +167,7 @@ describe('Collection component', () => {
expect(firstChild.get('property_trait')).toBe('user1');
expect(secondChild.getAttributes()['attribute_trait']).toBe('user2');
// TODO: Fix overrding traits
// expect(secondChild.get('property_trait')).toBe('user2');
expect(secondChild.get('property_trait')).toBe('user2');
});
});

6
packages/core/test/specs/data_sources/model/collection_component/__snapshots__/CollectionComponent.ts.snap

@ -22,7 +22,11 @@ exports[`Collection component Stringfication Collection with dynamic datasource
"type": "parent-collection-variable",
"variable_type": "current_item",
},
"property_trait": "user1",
"property_trait": {
"path": "user",
"type": "parent-collection-variable",
"variable_type": "current_item",
},
"type": "default",
},
"collection_name": "my_collection",

Loading…
Cancel
Save