Browse Source

Change collection definition properties

collection-component
mohamedsalem401 2 years ago
parent
commit
2ad06d1eb3
  1. 54
      packages/core/src/data_sources/model/data_collection/ComponentDataCollection.ts
  2. 6
      packages/core/src/data_sources/model/data_collection/ComponentDataCollectionVariable.ts
  3. 20
      packages/core/src/data_sources/model/data_collection/DataCollectionVariable.ts
  4. 2
      packages/core/src/data_sources/model/data_collection/constants.ts
  5. 12
      packages/core/src/data_sources/model/data_collection/types.ts
  6. 68
      packages/core/test/specs/data_sources/model/data_collection/ComponentDataCollection.ts
  7. 6
      packages/core/test/specs/data_sources/model/data_collection/ComponentDataCollectionVariable.ts
  8. 88
      packages/core/test/specs/data_sources/model/data_collection/__snapshots__/ComponentDataCollection.ts.snap

54
packages/core/src/data_sources/model/data_collection/ComponentDataCollection.ts

@ -35,8 +35,8 @@ export default class ComponentDataCollection extends Component {
opt, opt,
); );
const collectionDefinition = props[keyCollectionDefinition]; const collectionDef = props[keyCollectionDefinition];
if (!collectionDefinition) { if (!collectionDef) {
em.logError('missing collection definition'); em.logError('missing collection definition');
return cmp; return cmp;
@ -44,10 +44,10 @@ export default class ComponentDataCollection extends Component {
const parentCollectionStateMap = (props[keyCollectionsStateMap] || {}) as DataCollectionStateMap; const parentCollectionStateMap = (props[keyCollectionsStateMap] || {}) as DataCollectionStateMap;
const components: Component[] = getCollectionItems(em, collectionDefinition, parentCollectionStateMap, opt); const components: Component[] = getCollectionItems(em, collectionDef, parentCollectionStateMap, opt);
if (this.hasDynamicDataSource()) { if (this.hasDynamicDataSource()) {
this.watchDataSource(em, collectionDefinition, parentCollectionStateMap, opt); this.watchDataSource(em, collectionDef, parentCollectionStateMap, opt);
} }
cmp.components(components); cmp.components(components);
@ -59,7 +59,7 @@ export default class ComponentDataCollection extends Component {
} }
hasDynamicDataSource() { hasDynamicDataSource() {
const dataSource = this.get(keyCollectionDefinition).config.dataSource; const dataSource = this.get(keyCollectionDefinition).collectionConfig.dataSource;
return typeof dataSource === 'object' && dataSource.type === DataVariableType; return typeof dataSource === 'object' && dataSource.type === DataVariableType;
} }
@ -67,7 +67,7 @@ export default class ComponentDataCollection extends Component {
const json = super.toJSON(opts) as ComponentDataCollectionDefinition; const json = super.toJSON(opts) as ComponentDataCollectionDefinition;
const firstChild = this.getBlockDefinition(); const firstChild = this.getBlockDefinition();
json[keyCollectionDefinition].block = firstChild; json[keyCollectionDefinition].componentDef = firstChild;
delete json.components; delete json.components;
delete json.droppable; delete json.droppable;
@ -83,11 +83,11 @@ export default class ComponentDataCollection extends Component {
private watchDataSource( private watchDataSource(
em: EditorModel, em: EditorModel,
collectionDefinition: DataCollectionDefinition, collectionDef: DataCollectionDefinition,
parentCollectionStateMap: DataCollectionStateMap, parentCollectionStateMap: DataCollectionStateMap,
opt: ComponentOptions, opt: ComponentOptions,
) { ) {
const path = this.get(keyCollectionDefinition).config.dataSource?.path; const path = this.get(keyCollectionDefinition).collectionConfig.dataSource?.path;
const dataVariable = new DataVariable( const dataVariable = new DataVariable(
{ {
type: DataVariableType, type: DataVariableType,
@ -100,7 +100,7 @@ export default class ComponentDataCollection extends Component {
em: em, em: em,
dataVariable, dataVariable,
updateValueFromDataVariable: () => { updateValueFromDataVariable: () => {
const collectionItems = getCollectionItems(em, collectionDefinition, parentCollectionStateMap, opt); const collectionItems = getCollectionItems(em, collectionDef, parentCollectionStateMap, opt);
this.components(collectionItems); this.components(collectionItems);
}, },
}); });
@ -109,33 +109,43 @@ export default class ComponentDataCollection extends Component {
function getCollectionItems( function getCollectionItems(
em: EditorModel, em: EditorModel,
collectionDefinition: DataCollectionDefinition, collectionDef: DataCollectionDefinition,
parentCollectionStateMap: DataCollectionStateMap, parentCollectionStateMap: DataCollectionStateMap,
opt: ComponentOptions, opt: ComponentOptions,
) { ) {
const { collectionName, block, config } = collectionDefinition; const { componentDef, collectionConfig } = collectionDef;
if (!block) { if (!collectionConfig) {
em.logError('The "block" property is required in the collection definition.'); em.logError('The "collectionConfig" property is required in the collection definition.');
return []; return [];
} }
if (!config?.dataSource) { if (!componentDef) {
em.logError('The "config.dataSource" property is required in the collection definition.'); em.logError('The "componentDef" property is required in the collection definition.');
return []; return [];
} }
if (!collectionConfig?.dataSource) {
em.logError('The "collectionConfig.dataSource" property is required in the collection definition.');
return [];
}
const collectionId = collectionConfig.collectionId;
const components: Component[] = []; const components: Component[] = [];
let items: any[] = getDataSourceItems(config.dataSource, em); let items: any[] = getDataSourceItems(collectionConfig.dataSource, em);
const startIndex = Math.max(0, config.startIndex || 0); const startIndex = Math.max(0, collectionConfig.startIndex || 0);
const endIndex = Math.min(items.length - 1, config.endIndex !== undefined ? config.endIndex : Number.MAX_VALUE); const endIndex = Math.min(
items.length - 1,
collectionConfig.endIndex !== undefined ? collectionConfig.endIndex : Number.MAX_VALUE,
);
const totalItems = endIndex - startIndex + 1; const totalItems = endIndex - startIndex + 1;
let blockSymbolMain: Component; let blockSymbolMain: Component;
for (let index = startIndex; index <= endIndex; index++) { for (let index = startIndex; index <= endIndex; index++) {
const item = items[index]; const item = items[index];
const collectionState: DataCollectionState = { const collectionState: DataCollectionState = {
collectionName, collectionId,
currentIndex: index, currentIndex: index,
currentItem: item, currentItem: item,
startIndex: startIndex, startIndex: startIndex,
@ -146,18 +156,18 @@ function getCollectionItems(
const collectionsStateMap: DataCollectionStateMap = { const collectionsStateMap: DataCollectionStateMap = {
...parentCollectionStateMap, ...parentCollectionStateMap,
...(collectionName && { [collectionName]: collectionState }), ...(collectionId && { [collectionId]: collectionState }),
[keyInnerCollectionState]: collectionState, [keyInnerCollectionState]: collectionState,
}; };
if (index === startIndex) { if (index === startIndex) {
// @ts-ignore // @ts-ignore
const type = em.Components.getType(block?.type || 'default'); const type = em.Components.getType(componentDef?.type || 'default');
const model = type.model; const model = type.model;
blockSymbolMain = new model( blockSymbolMain = new model(
{ {
...block, ...componentDef,
[keyCollectionsStateMap]: collectionsStateMap, [keyCollectionsStateMap]: collectionsStateMap,
[keyIsCollectionItem]: true, [keyIsCollectionItem]: true,
draggable: false, draggable: false,

6
packages/core/src/data_sources/model/data_collection/ComponentDataCollectionVariable.ts

@ -13,7 +13,7 @@ export default class ComponentDataCollectionVariable extends Component {
// @ts-ignore // @ts-ignore
...super.defaults, ...super.defaults,
type: CollectionVariableType, type: CollectionVariableType,
collectionName: undefined, collectionId: undefined,
variableType: undefined, variableType: undefined,
path: undefined, path: undefined,
}; };
@ -22,10 +22,10 @@ export default class ComponentDataCollectionVariable extends Component {
constructor(props: DataCollectionVariableDefinition & ComponentProperties, opt: ComponentOptions) { constructor(props: DataCollectionVariableDefinition & ComponentProperties, opt: ComponentOptions) {
super(props, opt); super(props, opt);
const em = opt.em; const em = opt.em;
const { type, variableType, path, collectionName } = props; const { type, variableType, path, collectionId } = props;
this.datacollectionVariable = new DataCollectionVariable( this.datacollectionVariable = new DataCollectionVariable(
{ type, variableType, path, collectionName }, { type, variableType, path, collectionId },
{ {
em, em,
collectionsStateMap: this.get(keyCollectionsStateMap), collectionsStateMap: this.get(keyCollectionsStateMap),

20
packages/core/src/data_sources/model/data_collection/DataCollectionVariable.ts

@ -18,7 +18,7 @@ export default class DataCollectionVariable extends Model<ResolvedDataCollection
defaults(): Partial<ResolvedDataCollectionVariable> { defaults(): Partial<ResolvedDataCollectionVariable> {
return { return {
type: CollectionVariableType, type: CollectionVariableType,
collectionName: undefined, collectionId: undefined,
variableType: undefined, variableType: undefined,
path: undefined, path: undefined,
value: undefined, value: undefined,
@ -95,7 +95,7 @@ export default class DataCollectionVariable extends Model<ResolvedDataCollection
toJSON(options?: any) { toJSON(options?: any) {
const json = super.toJSON(options); const json = super.toJSON(options);
delete json.value; delete json.value;
!json.collectionName && delete json.collectionName; !json.collectionId && delete json.collectionId;
return json; return json;
} }
@ -106,23 +106,23 @@ function resolveCollectionVariable(
collectionsStateMap: DataCollectionStateMap, collectionsStateMap: DataCollectionStateMap,
em: EditorModel, em: EditorModel,
) { ) {
const { collectionName = keyInnerCollectionState, variableType, path } = collectionVariableDefinition; const { collectionId = keyInnerCollectionState, variableType, path } = collectionVariableDefinition;
if (!collectionsStateMap) return; if (!collectionsStateMap) return;
const collectionItem = collectionsStateMap[collectionName]; const collectionItem = collectionsStateMap[collectionId];
if (!collectionItem) { if (!collectionItem) {
em.logError(`Collection not found: ${collectionName}`); em.logError(`Collection not found: ${collectionId}`);
return ''; return '';
} }
if (!variableType) { if (!variableType) {
em.logError(`Missing collection variable type for collection: ${collectionName}`); em.logError(`Missing collection variable type for collection: ${collectionId}`);
return ''; return '';
} }
if (variableType === 'currentItem') { if (variableType === 'currentItem') {
return resolveCurrentItem(collectionItem, path, collectionName, em); return resolveCurrentItem(collectionItem, path, collectionId, em);
} }
return collectionItem[variableType]; return collectionItem[variableType];
@ -131,13 +131,13 @@ function resolveCollectionVariable(
function resolveCurrentItem( function resolveCurrentItem(
collectionItem: DataCollectionState, collectionItem: DataCollectionState,
path: string | undefined, path: string | undefined,
collectionName: string, collectionId: string,
em: EditorModel, em: EditorModel,
) { ) {
const currentItem = collectionItem.currentItem; const currentItem = collectionItem.currentItem;
if (!currentItem) { if (!currentItem) {
em.logError(`Current item is missing for collection: ${collectionName}`); em.logError(`Current item is missing for collection: ${collectionId}`);
return ''; return '';
} }
@ -150,7 +150,7 @@ function resolveCurrentItem(
} }
if (path && !currentItem[path]) { if (path && !currentItem[path]) {
em.logError(`Path not found in current item: ${path} for collection: ${collectionName}`); em.logError(`Path not found in current item: ${path} for collection: ${collectionId}`);
return ''; return '';
} }

2
packages/core/src/data_sources/model/data_collection/constants.ts

@ -1,5 +1,5 @@
export const CollectionComponentType = 'collection-component'; export const CollectionComponentType = 'collection-component';
export const keyCollectionDefinition = 'collectionDefinition'; export const keyCollectionDefinition = 'collectionDef';
export const keyInnerCollectionState = 'innerCollectionState'; export const keyInnerCollectionState = 'innerCollectionState';
export const keyIsCollectionItem = '__is_collection_item'; export const keyIsCollectionItem = '__is_collection_item';
export const CollectionVariableType = 'parent-collection-variable'; export const CollectionVariableType = 'parent-collection-variable';

12
packages/core/src/data_sources/model/data_collection/types.ts

@ -5,6 +5,7 @@ import { DataVariableDefinition } from '../DataVariable';
export type DataCollectionDataSource = any[] | DataVariableDefinition | DataCollectionVariableDefinition; export type DataCollectionDataSource = any[] | DataVariableDefinition | DataCollectionVariableDefinition;
export interface DataCollectionConfig { export interface DataCollectionConfig {
collectionId?: string;
startIndex?: number; startIndex?: number;
endIndex?: number; endIndex?: number;
dataSource: DataCollectionDataSource; dataSource: DataCollectionDataSource;
@ -15,7 +16,7 @@ export enum DataCollectionStateVariableType {
startIndex = 'startIndex', startIndex = 'startIndex',
currentItem = 'currentItem', currentItem = 'currentItem',
endIndex = 'endIndex', endIndex = 'endIndex',
collectionName = 'collectionName', collectionId = 'collectionId',
totalItems = 'totalItems', totalItems = 'totalItems',
remainingItems = 'remainingItems', remainingItems = 'remainingItems',
} }
@ -25,7 +26,7 @@ export interface DataCollectionState {
[DataCollectionStateVariableType.startIndex]: number; [DataCollectionStateVariableType.startIndex]: number;
[DataCollectionStateVariableType.currentItem]: any; [DataCollectionStateVariableType.currentItem]: any;
[DataCollectionStateVariableType.endIndex]: number; [DataCollectionStateVariableType.endIndex]: number;
[DataCollectionStateVariableType.collectionName]?: string; [DataCollectionStateVariableType.collectionId]?: string;
[DataCollectionStateVariableType.totalItems]: number; [DataCollectionStateVariableType.totalItems]: number;
[DataCollectionStateVariableType.remainingItems]: number; [DataCollectionStateVariableType.remainingItems]: number;
} }
@ -40,14 +41,13 @@ export interface ComponentDataCollectionDefinition extends ComponentDefinition {
export interface DataCollectionDefinition { export interface DataCollectionDefinition {
type: typeof CollectionComponentType; type: typeof CollectionComponentType;
collectionName?: string; collectionConfig: DataCollectionConfig;
config: DataCollectionConfig; componentDef: ComponentDefinition;
block: ComponentDefinition;
} }
export type DataCollectionVariableDefinition = { export type DataCollectionVariableDefinition = {
type: typeof CollectionVariableType; type: typeof CollectionVariableType;
variableType: DataCollectionStateVariableType; variableType: DataCollectionStateVariableType;
collectionName?: string; collectionId?: string;
path?: string; path?: string;
}; };

68
packages/core/test/specs/data_sources/model/data_collection/ComponentDataCollection.ts

@ -42,11 +42,11 @@ describe('Collection component', () => {
test('Collection component should be undroppable', () => { test('Collection component should be undroppable', () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
}, },
config: { collectionConfig: {
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -61,11 +61,11 @@ describe('Collection component', () => {
test('Collection items should be undraggable', () => { test('Collection items should be undraggable', () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
}, },
config: { collectionConfig: {
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -82,8 +82,8 @@ describe('Collection component', () => {
test('Collection items should be symbols', () => { test('Collection items should be symbols', () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
components: [ components: [
{ {
@ -91,7 +91,7 @@ describe('Collection component', () => {
}, },
], ],
}, },
config: { collectionConfig: {
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -122,8 +122,8 @@ describe('Collection component', () => {
beforeEach(() => { beforeEach(() => {
cmp = wrapper.components({ cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
components: [ components: [
{ {
@ -146,7 +146,7 @@ describe('Collection component', () => {
path: 'user', path: 'user',
}, },
}, },
config: { collectionConfig: {
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -277,8 +277,8 @@ describe('Collection component', () => {
beforeEach(() => { beforeEach(() => {
cmp = wrapper.components({ cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
components: [ components: [
{ {
@ -300,7 +300,7 @@ describe('Collection component', () => {
}, },
}, },
}, },
config: { collectionConfig: {
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -427,8 +427,8 @@ describe('Collection component', () => {
test('Traits', () => { test('Traits', () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
traits: [ traits: [
{ {
@ -450,7 +450,7 @@ describe('Collection component', () => {
}, },
], ],
}, },
config: { collectionConfig: {
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -524,13 +524,13 @@ describe('Collection component', () => {
const collectionComponentDefinition = { const collectionComponentDefinition = {
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
collectionName: 'my_collection', componentDef: {
block: {
...cmpDefinition, ...cmpDefinition,
components: [cmpDefinition, cmpDefinition], components: [cmpDefinition, cmpDefinition],
}, },
config: { collectionConfig: {
collectionId: 'my_collection',
startIndex: 0, startIndex: 0,
endIndex: 1, endIndex: 1,
dataSource: { dataSource: {
@ -591,8 +591,8 @@ describe('Collection component', () => {
component: { component: {
components: [ components: [
{ {
collectionDefinition: { collectionDef: {
block: { componentDef: {
attributes: { attributes: {
attribute_trait: { attribute_trait: {
path: 'user', path: 'user',
@ -684,8 +684,8 @@ describe('Collection component', () => {
}, },
type: 'default', type: 'default',
}, },
collectionName: 'my_collection', collectionConfig: {
config: { collectionId: 'my_collection',
dataSource: { dataSource: {
path: 'my_data_source_id', path: 'my_data_source_id',
type: DataVariableType, type: DataVariableType,
@ -761,8 +761,8 @@ describe('Collection component', () => {
test('Collection with start and end indexes', () => { test('Collection with start and end indexes', () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
name: { name: {
type: CollectionVariableType, type: CollectionVariableType,
@ -770,7 +770,7 @@ describe('Collection component', () => {
path: 'user', path: 'user',
}, },
}, },
config: { collectionConfig: {
startIndex: 1, startIndex: 1,
endIndex: 2, endIndex: 2,
dataSource: { dataSource: {
@ -796,7 +796,7 @@ describe('Collection component', () => {
{ variableType: DataCollectionStateVariableType.startIndex, expectedValues: [0, 0, 0] }, { variableType: DataCollectionStateVariableType.startIndex, expectedValues: [0, 0, 0] },
{ variableType: DataCollectionStateVariableType.endIndex, expectedValues: [2, 2, 2] }, { variableType: DataCollectionStateVariableType.endIndex, expectedValues: [2, 2, 2] },
{ {
variableType: DataCollectionStateVariableType.collectionName, variableType: DataCollectionStateVariableType.collectionId,
expectedValues: ['my_collection', 'my_collection', 'my_collection'], expectedValues: ['my_collection', 'my_collection', 'my_collection'],
}, },
{ variableType: DataCollectionStateVariableType.totalItems, expectedValues: [3, 3, 3] }, { variableType: DataCollectionStateVariableType.totalItems, expectedValues: [3, 3, 3] },
@ -807,9 +807,8 @@ describe('Collection component', () => {
test(`Variable type: ${variableType}`, () => { test(`Variable type: ${variableType}`, () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
collectionName: 'my_collection', componentDef: {
block: {
type: 'default', type: 'default',
name: { name: {
type: CollectionVariableType, type: CollectionVariableType,
@ -839,7 +838,8 @@ describe('Collection component', () => {
}, },
], ],
}, },
config: { collectionConfig: {
collectionId: 'my_collection',
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',

6
packages/core/test/specs/data_sources/model/data_collection/ComponentDataCollectionVariable.ts

@ -40,8 +40,8 @@ describe('Collection component', () => {
test('Collection variable components', async () => { test('Collection variable components', async () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDef: {
block: { componentDef: {
type: 'default', type: 'default',
components: [ components: [
{ {
@ -51,7 +51,7 @@ describe('Collection component', () => {
}, },
], ],
}, },
config: { collectionConfig: {
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',

88
packages/core/test/specs/data_sources/model/data_collection/__snapshots__/ComponentDataCollection.ts.snap

@ -2,8 +2,17 @@
exports[`Collection component Serialization Saving: Collection with grandchildren 1`] = ` exports[`Collection component Serialization Saving: Collection with grandchildren 1`] = `
{ {
"collectionDefinition": { "collectionDef": {
"block": { "collectionConfig": {
"collectionId": "my_collection",
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
"componentDef": {
"attributes": { "attributes": {
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
@ -105,15 +114,6 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
}, },
"type": "default", "type": "default",
}, },
"collectionName": "my_collection",
"config": {
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
}, },
"type": "collection-component", "type": "collection-component",
} }
@ -121,8 +121,17 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
exports[`Collection component Serialization Saving: Collection with no grandchildren 1`] = ` exports[`Collection component Serialization Saving: Collection with no grandchildren 1`] = `
{ {
"collectionDefinition": { "collectionDef": {
"block": { "collectionConfig": {
"collectionId": "my_collection",
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
"componentDef": {
"attributes": { "attributes": {
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
@ -214,15 +223,6 @@ exports[`Collection component Serialization Saving: Collection with no grandchil
}, },
"type": "default", "type": "default",
}, },
"collectionName": "my_collection",
"config": {
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
}, },
"type": "collection-component", "type": "collection-component",
} }
@ -230,8 +230,17 @@ exports[`Collection component Serialization Saving: Collection with no grandchil
exports[`Collection component Serialization Serializion with Collection Variables to JSON: Collection with grandchildren 1`] = ` exports[`Collection component Serialization Serializion with Collection Variables to JSON: Collection with grandchildren 1`] = `
{ {
"collectionDefinition": { "collectionDef": {
"block": { "collectionConfig": {
"collectionId": "my_collection",
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
"componentDef": {
"attributes": { "attributes": {
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
@ -333,15 +342,6 @@ exports[`Collection component Serialization Serializion with Collection Variable
}, },
"type": "default", "type": "default",
}, },
"collectionName": "my_collection",
"config": {
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
}, },
"type": "collection-component", "type": "collection-component",
} }
@ -349,8 +349,17 @@ exports[`Collection component Serialization Serializion with Collection Variable
exports[`Collection component Serialization Serializion with Collection Variables to JSON: Collection with no grandchildren 1`] = ` exports[`Collection component Serialization Serializion with Collection Variables to JSON: Collection with no grandchildren 1`] = `
{ {
"collectionDefinition": { "collectionDef": {
"block": { "collectionConfig": {
"collectionId": "my_collection",
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
"componentDef": {
"attributes": { "attributes": {
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
@ -442,15 +451,6 @@ exports[`Collection component Serialization Serializion with Collection Variable
}, },
"type": "default", "type": "default",
}, },
"collectionName": "my_collection",
"config": {
"dataSource": {
"path": "my_data_source_id",
"type": "data-variable",
},
"endIndex": 1,
"startIndex": 0,
},
}, },
"type": "collection-component", "type": "collection-component",
} }

Loading…
Cancel
Save