Browse Source

Change collection component definition options to camel case

collection-component
mohamed yahia 2 years ago
parent
commit
0167fce543
  1. 2
      README.md
  2. 33
      packages/core/src/data_sources/model/collection_component/CollectionComponent.ts
  3. 24
      packages/core/src/data_sources/model/collection_component/CollectionVariable.ts
  4. 34
      packages/core/src/data_sources/model/collection_component/types.ts
  5. 106
      packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts
  6. 148
      packages/core/test/specs/data_sources/model/collection_component/__snapshots__/CollectionComponent.ts.snap
  7. 4
      packages/core/test/specs/dom_components/model/ComponentTypes.ts

2
README.md

@ -1 +1 @@
./packages/core/README.md ./packages/core/README.md

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

@ -1,7 +1,7 @@
import DataVariable, { DataVariableType } from './../DataVariable'; import DataVariable, { DataVariableType } from './../DataVariable';
import { isArray } from 'underscore'; import { isArray } from 'underscore';
import Component, { keySymbol, keySymbolOvrd, keySymbols } from '../../../dom_components/model/Component'; import Component from '../../../dom_components/model/Component';
import { ComponentDefinition, ComponentOptions, ComponentProperties } from '../../../dom_components/model/types'; import { ComponentOptions } from '../../../dom_components/model/types';
import { toLowerCase } from '../../../utils/mixins'; import { toLowerCase } from '../../../utils/mixins';
import DataSource from '../DataSource'; import DataSource from '../DataSource';
import { ObjectAny } from '../../../common'; import { ObjectAny } from '../../../common';
@ -10,7 +10,6 @@ import { keyCollectionsStateMap } from '../../../dom_components/model/Component'
import { CollectionComponentDefinition, CollectionDefinition, CollectionState, CollectionsStateMap } from './types'; import { CollectionComponentDefinition, CollectionDefinition, CollectionState, CollectionsStateMap } from './types';
import { keyCollectionDefinition, keyInnerCollectionState, CollectionComponentType } from './constants'; import { keyCollectionDefinition, keyInnerCollectionState, CollectionComponentType } from './constants';
import DynamicVariableListenerManager from '../DataVariableListenerManager'; import DynamicVariableListenerManager from '../DataVariableListenerManager';
import Components from '../../../dom_components/model/Components';
export default class CollectionComponent extends Component { export default class CollectionComponent extends Component {
constructor(props: CollectionComponentDefinition, opt: ComponentOptions) { constructor(props: CollectionComponentDefinition, opt: ComponentOptions) {
@ -103,7 +102,7 @@ function getCollectionItems(
parentCollectionStateMap: CollectionsStateMap, parentCollectionStateMap: CollectionsStateMap,
opt: ComponentOptions, opt: ComponentOptions,
) { ) {
const { collection_name, block, config } = collectionDefinition; const { collectionName, block, config } = collectionDefinition;
if (!block) { if (!block) {
em.logError('The "block" property is required in the collection definition.'); em.logError('The "block" property is required in the collection definition.');
return []; return [];
@ -117,30 +116,30 @@ function getCollectionItems(
const components: Component[] = []; const components: Component[] = [];
let items: any[] = getDataSourceItems(config.dataSource, em); let items: any[] = getDataSourceItems(config.dataSource, em);
const start_index = Math.max(0, config.start_index || 0); const startIndex = Math.max(0, config.startIndex || 0);
const end_index = Math.min(items.length - 1, config.end_index !== undefined ? config.end_index : Number.MAX_VALUE); const endIndex = Math.min(items.length - 1, config.endIndex !== undefined ? config.endIndex : Number.MAX_VALUE);
const total_items = end_index - start_index + 1; const totalItems = endIndex - startIndex + 1;
let blockSymbolMain: Component; let blockSymbolMain: Component;
for (let index = start_index; index <= end_index; index++) { for (let index = startIndex; index <= endIndex; index++) {
const item = items[index]; const item = items[index];
const collectionState: CollectionState = { const collectionState: CollectionState = {
collection_name, collectionName,
current_index: index, currentIndex: index,
current_item: item, currentItem: item,
start_index: start_index, startIndex: startIndex,
end_index: end_index, endIndex: endIndex,
total_items: total_items, totalItems: totalItems,
remaining_items: total_items - (index + 1), remainingItems: totalItems - (index + 1),
}; };
const collectionsStateMap: CollectionsStateMap = { const collectionsStateMap: CollectionsStateMap = {
...parentCollectionStateMap, ...parentCollectionStateMap,
...(collection_name && { [collection_name]: collectionState }), ...(collectionName && { [collectionName]: collectionState }),
[keyInnerCollectionState]: collectionState, [keyInnerCollectionState]: collectionState,
}; };
if (index === start_index) { if (index === startIndex) {
// @ts-ignore // @ts-ignore
const type = em.Components.getType(block?.type || 'default'); const type = em.Components.getType(block?.type || 'default');
const model = type.model; const model = type.model;

24
packages/core/src/data_sources/model/collection_component/CollectionVariable.ts

@ -63,36 +63,36 @@ function resolveCollectionVariable(
collectionsStateMap: CollectionsStateMap, collectionsStateMap: CollectionsStateMap,
em: EditorModel, em: EditorModel,
) { ) {
const { collection_name = keyInnerCollectionState, variable_type, path } = collectionVariableDefinition; const { collectionName = keyInnerCollectionState, variableType, path } = collectionVariableDefinition;
const collectionItem = collectionsStateMap[collection_name]; const collectionItem = collectionsStateMap[collectionName];
if (!collectionItem) { if (!collectionItem) {
em.logError(`Collection not found: ${collection_name}`); em.logError(`Collection not found: ${collectionName}`);
return ''; return '';
} }
if (!variable_type) { if (!variableType) {
em.logError(`Missing collection variable type for collection: ${collection_name}`); em.logError(`Missing collection variable type for collection: ${collectionName}`);
return ''; return '';
} }
if (variable_type === 'current_item') { if (variableType === 'currentItem') {
return resolveCurrentItem(collectionItem, path, collection_name, em); return resolveCurrentItem(collectionItem, path, collectionName, em);
} }
return collectionItem[variable_type]; return collectionItem[variableType];
} }
function resolveCurrentItem( function resolveCurrentItem(
collectionItem: CollectionState, collectionItem: CollectionState,
path: string | undefined, path: string | undefined,
collection_name: string, collectionName: string,
em: EditorModel, em: EditorModel,
) { ) {
const currentItem = collectionItem.current_item; const currentItem = collectionItem.currentItem;
if (!currentItem) { if (!currentItem) {
em.logError(`Current item is missing for collection: ${collection_name}`); em.logError(`Current item is missing for collection: ${collectionName}`);
return ''; return '';
} }
@ -105,7 +105,7 @@ function resolveCurrentItem(
} }
if (path && !currentItem[path]) { if (path && !currentItem[path]) {
em.logError(`Path not found in current item: ${path} for collection: ${collection_name}`); em.logError(`Path not found in current item: ${path} for collection: ${collectionName}`);
return ''; return '';
} }

34
packages/core/src/data_sources/model/collection_component/types.ts

@ -6,29 +6,29 @@ import { DataVariableDefinition } from '../DataVariable';
type CollectionDataSource = any[] | DataVariableDefinition | CollectionVariableDefinition; type CollectionDataSource = any[] | DataVariableDefinition | CollectionVariableDefinition;
type CollectionConfig = { type CollectionConfig = {
start_index?: number; startIndex?: number;
end_index?: number; endIndex?: number;
dataSource: CollectionDataSource; dataSource: CollectionDataSource;
}; };
export enum CollectionStateVariableType { export enum CollectionStateVariableType {
current_index = 'current_index', currentIndex = 'currentIndex',
start_index = 'start_index', startIndex = 'startIndex',
current_item = 'current_item', currentItem = 'currentItem',
end_index = 'end_index', endIndex = 'endIndex',
collection_name = 'collection_name', collectionName = 'collectionName',
total_items = 'total_items', totalItems = 'totalItems',
remaining_items = 'remaining_items', remainingItems = 'remainingItems',
} }
export type CollectionState = { export type CollectionState = {
[CollectionStateVariableType.current_index]: number; [CollectionStateVariableType.currentIndex]: number;
[CollectionStateVariableType.start_index]: number; [CollectionStateVariableType.startIndex]: number;
[CollectionStateVariableType.current_item]: any; [CollectionStateVariableType.currentItem]: any;
[CollectionStateVariableType.end_index]: number; [CollectionStateVariableType.endIndex]: number;
[CollectionStateVariableType.collection_name]?: string; [CollectionStateVariableType.collectionName]?: string;
[CollectionStateVariableType.total_items]: number; [CollectionStateVariableType.totalItems]: number;
[CollectionStateVariableType.remaining_items]: number; [CollectionStateVariableType.remainingItems]: number;
}; };
export type CollectionsStateMap = { export type CollectionsStateMap = {
@ -41,7 +41,7 @@ export type CollectionComponentDefinition = {
export type CollectionDefinition = { export type CollectionDefinition = {
type: typeof CollectionComponentType; type: typeof CollectionComponentType;
collection_name?: string; collectionName?: string;
config: CollectionConfig; config: CollectionConfig;
block: ComponentDefinition; block: ComponentDefinition;
}; };

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

@ -130,19 +130,19 @@ describe('Collection component', () => {
type: 'default', type: 'default',
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
], ],
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
custom_property: { custom_property: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -205,7 +205,7 @@ describe('Collection component', () => {
firstChild.set('content', { firstChild.set('content', {
// @ts-ignore // @ts-ignore
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'age', path: 'age',
}); });
expect(firstChild.get('content')).toBe('12'); expect(firstChild.get('content')).toBe('12');
@ -223,7 +223,7 @@ describe('Collection component', () => {
firstGrandchild.set('content', { firstGrandchild.set('content', {
// @ts-ignore // @ts-ignore
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'age', path: 'age',
}); });
expect(firstGrandchild.get('content')).toBe('new_value_12'); expect(firstGrandchild.get('content')).toBe('new_value_12');
@ -286,7 +286,7 @@ describe('Collection component', () => {
attributes: { attributes: {
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -295,7 +295,7 @@ describe('Collection component', () => {
attributes: { attributes: {
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -356,7 +356,7 @@ describe('Collection component', () => {
content: { content: {
// @ts-ignore // @ts-ignore
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'age', path: 'age',
}, },
}); });
@ -376,7 +376,7 @@ describe('Collection component', () => {
content: { content: {
// @ts-ignore // @ts-ignore
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'age', path: 'age',
}, },
}); });
@ -435,7 +435,7 @@ describe('Collection component', () => {
name: 'attribute_trait', name: 'attribute_trait',
value: { value: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -444,7 +444,7 @@ describe('Collection component', () => {
changeProp: true, changeProp: true,
value: { value: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -486,18 +486,18 @@ describe('Collection component', () => {
type: 'default', type: 'default',
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
custom_prop: { custom_prop: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_index, variableType: CollectionStateVariableType.currentIndex,
path: 'user', path: 'user',
}, },
attributes: { attributes: {
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -506,7 +506,7 @@ describe('Collection component', () => {
name: 'attribute_trait', name: 'attribute_trait',
value: { value: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -515,7 +515,7 @@ describe('Collection component', () => {
changeProp: true, changeProp: true,
value: { value: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
@ -525,14 +525,14 @@ describe('Collection component', () => {
const collectionComponentDefinition = { const collectionComponentDefinition = {
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDefinition: {
collection_name: 'my_collection', collectionName: 'my_collection',
block: { block: {
...cmpDefinition, ...cmpDefinition,
components: [cmpDefinition, cmpDefinition], components: [cmpDefinition, cmpDefinition],
}, },
config: { config: {
start_index: 0, startIndex: 0,
end_index: 1, endIndex: 1,
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -552,7 +552,7 @@ describe('Collection component', () => {
type: 'default', type: 'default',
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_index, variableType: CollectionStateVariableType.currentIndex,
path: 'user', path: 'user',
}, },
}; };
@ -573,7 +573,7 @@ describe('Collection component', () => {
type: 'default', type: 'default',
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_index, variableType: CollectionStateVariableType.currentIndex,
path: 'user', path: 'user',
}, },
}; };
@ -597,12 +597,12 @@ describe('Collection component', () => {
attribute_trait: { attribute_trait: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
content: { content: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
}, },
components: [ components: [
@ -611,28 +611,28 @@ describe('Collection component', () => {
attribute_trait: { attribute_trait: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
content: { content: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
}, },
content: { content: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
custom_prop: { custom_prop: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: 'current_index', variableType: 'currentIndex',
}, },
property_trait: { property_trait: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
type: 'default', type: 'default',
}, },
@ -641,28 +641,28 @@ describe('Collection component', () => {
attribute_trait: { attribute_trait: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
content: { content: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
}, },
content: { content: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
custom_prop: { custom_prop: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: 'current_index', variableType: 'currentIndex',
}, },
property_trait: { property_trait: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
type: 'default', type: 'default',
}, },
@ -670,28 +670,28 @@ describe('Collection component', () => {
content: { content: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
custom_prop: { custom_prop: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: 'current_index', variableType: 'currentIndex',
}, },
property_trait: { property_trait: {
path: 'user', path: 'user',
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
}, },
type: 'default', type: 'default',
}, },
collection_name: 'my_collection', collectionName: 'my_collection',
config: { config: {
dataSource: { dataSource: {
path: 'my_data_source_id', path: 'my_data_source_id',
type: DataVariableType, type: DataVariableType,
}, },
end_index: 1, endIndex: 1,
start_index: 0, startIndex: 0,
}, },
}, },
type: 'collection-component', type: 'collection-component',
@ -766,13 +766,13 @@ describe('Collection component', () => {
type: 'default', type: 'default',
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: CollectionStateVariableType.current_item, variableType: CollectionStateVariableType.currentItem,
path: 'user', path: 'user',
}, },
}, },
config: { config: {
start_index: 1, startIndex: 1,
end_index: 2, endIndex: 2,
dataSource: { dataSource: {
type: DataVariableType, type: DataVariableType,
path: 'my_data_source_id', path: 'my_data_source_id',
@ -792,15 +792,15 @@ describe('Collection component', () => {
describe('Diffirent Collection variable types', () => { describe('Diffirent Collection variable types', () => {
const stateVariableTests = [ const stateVariableTests = [
{ variableType: CollectionStateVariableType.current_index, expectedValues: [0, 1, 2] }, { variableType: CollectionStateVariableType.currentIndex, expectedValues: [0, 1, 2] },
{ variableType: CollectionStateVariableType.start_index, expectedValues: [0, 0, 0] }, { variableType: CollectionStateVariableType.startIndex, expectedValues: [0, 0, 0] },
{ variableType: CollectionStateVariableType.end_index, expectedValues: [2, 2, 2] }, { variableType: CollectionStateVariableType.endIndex, expectedValues: [2, 2, 2] },
{ {
variableType: CollectionStateVariableType.collection_name, variableType: CollectionStateVariableType.collectionName,
expectedValues: ['my_collection', 'my_collection', 'my_collection'], expectedValues: ['my_collection', 'my_collection', 'my_collection'],
}, },
{ variableType: CollectionStateVariableType.total_items, expectedValues: [3, 3, 3] }, { variableType: CollectionStateVariableType.totalItems, expectedValues: [3, 3, 3] },
{ variableType: CollectionStateVariableType.remaining_items, expectedValues: [2, 1, 0] }, { variableType: CollectionStateVariableType.remainingItems, expectedValues: [2, 1, 0] },
]; ];
stateVariableTests.forEach(({ variableType, expectedValues }) => { stateVariableTests.forEach(({ variableType, expectedValues }) => {
@ -808,17 +808,17 @@ describe('Collection component', () => {
const cmp = wrapper.components({ const cmp = wrapper.components({
type: CollectionComponentType, type: CollectionComponentType,
collectionDefinition: { collectionDefinition: {
collection_name: 'my_collection', collectionName: 'my_collection',
block: { block: {
type: 'default', type: 'default',
content: { content: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: variableType, variableType: variableType,
}, },
attributes: { attributes: {
custom_attribute: { custom_attribute: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: variableType, variableType: variableType,
}, },
}, },
traits: [ traits: [
@ -826,7 +826,7 @@ describe('Collection component', () => {
name: 'attribute_trait', name: 'attribute_trait',
value: { value: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: variableType, variableType: variableType,
}, },
}, },
{ {
@ -834,7 +834,7 @@ describe('Collection component', () => {
changeProp: true, changeProp: true,
value: { value: {
type: CollectionVariableType, type: CollectionVariableType,
variable_type: variableType, variableType: variableType,
}, },
}, },
], ],

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

@ -8,12 +8,12 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"components": [ "components": [
@ -22,12 +22,12 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"components": [ "components": [
@ -35,7 +35,7 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"type": "default", "type": "default",
}, },
@ -43,17 +43,17 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -62,28 +62,28 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -91,28 +91,28 @@ exports[`Collection component Serialization Saving: Collection with grandchildre
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
"collection_name": "my_collection", "collectionName": "my_collection",
"config": { "config": {
"dataSource": { "dataSource": {
"path": "my_data_source_id", "path": "my_data_source_id",
"type": "data-variable", "type": "data-variable",
}, },
"end_index": 1, "endIndex": 1,
"start_index": 0, "startIndex": 0,
}, },
}, },
"type": "collection-component", "type": "collection-component",
@ -127,12 +127,12 @@ exports[`Collection component Serialization Saving: Collection with no grandchil
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"components": [ "components": [
@ -141,28 +141,28 @@ exports[`Collection component Serialization Saving: Collection with no grandchil
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -171,28 +171,28 @@ exports[`Collection component Serialization Saving: Collection with no grandchil
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -200,28 +200,28 @@ exports[`Collection component Serialization Saving: Collection with no grandchil
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
"collection_name": "my_collection", "collectionName": "my_collection",
"config": { "config": {
"dataSource": { "dataSource": {
"path": "my_data_source_id", "path": "my_data_source_id",
"type": "data-variable", "type": "data-variable",
}, },
"end_index": 1, "endIndex": 1,
"start_index": 0, "startIndex": 0,
}, },
}, },
"type": "collection-component", "type": "collection-component",
@ -236,12 +236,12 @@ exports[`Collection component Serialization Serializion with Collection Variable
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"components": [ "components": [
@ -250,12 +250,12 @@ exports[`Collection component Serialization Serializion with Collection Variable
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"components": [ "components": [
@ -263,7 +263,7 @@ exports[`Collection component Serialization Serializion with Collection Variable
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"type": "default", "type": "default",
}, },
@ -271,17 +271,17 @@ exports[`Collection component Serialization Serializion with Collection Variable
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -290,28 +290,28 @@ exports[`Collection component Serialization Serializion with Collection Variable
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -319,28 +319,28 @@ exports[`Collection component Serialization Serializion with Collection Variable
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
"collection_name": "my_collection", "collectionName": "my_collection",
"config": { "config": {
"dataSource": { "dataSource": {
"path": "my_data_source_id", "path": "my_data_source_id",
"type": "data-variable", "type": "data-variable",
}, },
"end_index": 1, "endIndex": 1,
"start_index": 0, "startIndex": 0,
}, },
}, },
"type": "collection-component", "type": "collection-component",
@ -355,12 +355,12 @@ exports[`Collection component Serialization Serializion with Collection Variable
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"components": [ "components": [
@ -369,28 +369,28 @@ exports[`Collection component Serialization Serializion with Collection Variable
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -399,28 +399,28 @@ exports[`Collection component Serialization Serializion with Collection Variable
"attribute_trait": { "attribute_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
}, },
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
@ -428,28 +428,28 @@ exports[`Collection component Serialization Serializion with Collection Variable
"content": { "content": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"custom_prop": { "custom_prop": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_index", "variableType": "currentIndex",
}, },
"property_trait": { "property_trait": {
"path": "user", "path": "user",
"type": "parent-collection-variable", "type": "parent-collection-variable",
"variable_type": "current_item", "variableType": "currentItem",
}, },
"type": "default", "type": "default",
}, },
"collection_name": "my_collection", "collectionName": "my_collection",
"config": { "config": {
"dataSource": { "dataSource": {
"path": "my_data_source_id", "path": "my_data_source_id",
"type": "data-variable", "type": "data-variable",
}, },
"end_index": 1, "endIndex": 1,
"start_index": 0, "startIndex": 0,
}, },
}, },
"type": "collection-component", "type": "collection-component",

4
packages/core/test/specs/dom_components/model/ComponentTypes.ts

@ -101,7 +101,7 @@ describe('Component Types', () => {
export type CollectionVariableDefinition = { export type CollectionVariableDefinition = {
type: typeof CollectionVariableType; type: typeof CollectionVariableType;
variable_type: CollectionStateVariableType; variableType: CollectionStateVariableType;
collection_name?: string; collectionName?: string;
path?: string; path?: string;
}; };

Loading…
Cancel
Save