From 68707db63461fcfc63a37129266046389c62381e Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Wed, 15 Jan 2025 16:34:03 +0200 Subject: [PATCH] Rename collection to DataCollection --- .../model/DataVariableListenerManager.ts | 4 +- .../CollectionComponentView.ts | 4 - .../model/collection_component/types.ts | 48 ------------ .../CollectionVariable.ts | 20 ++--- .../ComponentDataCollection.ts} | 33 ++++---- .../ComponentDataCollectionView.ts | 4 + .../constants.ts | 0 .../model/data_collection/types.ts | 53 +++++++++++++ packages/core/src/data_sources/model/utils.ts | 12 +-- packages/core/src/data_sources/types.ts | 6 +- packages/core/src/dom_components/index.ts | 10 +-- .../src/dom_components/model/Component.ts | 8 +- .../model/ComponentDynamicValueWatcher.ts | 8 +- .../model/DynamicValueWatcher.ts | 10 +-- .../src/dom_components/model/SymbolUtils.ts | 2 +- .../core/src/dom_components/model/types.ts | 2 +- .../ComponentDataCollection.ts} | 78 +++++++++---------- .../ComponentDataCollection.ts.snap} | 0 .../dom_components/model/ComponentTypes.ts | 9 --- 19 files changed, 156 insertions(+), 155 deletions(-) delete mode 100644 packages/core/src/data_sources/model/collection_component/CollectionComponentView.ts delete mode 100644 packages/core/src/data_sources/model/collection_component/types.ts rename packages/core/src/data_sources/model/{collection_component => data_collection}/CollectionVariable.ts (81%) rename packages/core/src/data_sources/model/{collection_component/CollectionComponent.ts => data_collection/ComponentDataCollection.ts} (86%) create mode 100644 packages/core/src/data_sources/model/data_collection/ComponentDataCollectionView.ts rename packages/core/src/data_sources/model/{collection_component => data_collection}/constants.ts (100%) create mode 100644 packages/core/src/data_sources/model/data_collection/types.ts rename packages/core/test/specs/data_sources/model/{collection_component/CollectionComponent.ts => data_collection/ComponentDataCollection.ts} (90%) rename packages/core/test/specs/data_sources/model/{collection_component/__snapshots__/CollectionComponent.ts.snap => data_collection/__snapshots__/ComponentDataCollection.ts.snap} (100%) diff --git a/packages/core/src/data_sources/model/DataVariableListenerManager.ts b/packages/core/src/data_sources/model/DataVariableListenerManager.ts index a43ef0b63..e090e962b 100644 --- a/packages/core/src/data_sources/model/DataVariableListenerManager.ts +++ b/packages/core/src/data_sources/model/DataVariableListenerManager.ts @@ -6,8 +6,8 @@ import DataVariable, { DataVariableType } from './DataVariable'; import { DynamicValue } from '../types'; import { DataCondition, ConditionalVariableType } from './conditional_variables/DataCondition'; import ComponentDataVariable from './ComponentDataVariable'; -import { CollectionVariableType } from './collection_component/constants'; -import CollectionVariable from './collection_component/CollectionVariable'; +import { CollectionVariableType } from './data_collection/constants'; +import CollectionVariable from './data_collection/CollectionVariable'; export interface DynamicVariableListenerManagerOptions { em: EditorModel; diff --git a/packages/core/src/data_sources/model/collection_component/CollectionComponentView.ts b/packages/core/src/data_sources/model/collection_component/CollectionComponentView.ts deleted file mode 100644 index 19a8fdce6..000000000 --- a/packages/core/src/data_sources/model/collection_component/CollectionComponentView.ts +++ /dev/null @@ -1,4 +0,0 @@ -import ComponentView from '../../../dom_components/view/ComponentView'; -import CollectionComponent from './CollectionComponent'; - -export default class CollectionComponentView extends ComponentView {} diff --git a/packages/core/src/data_sources/model/collection_component/types.ts b/packages/core/src/data_sources/model/collection_component/types.ts deleted file mode 100644 index f051590da..000000000 --- a/packages/core/src/data_sources/model/collection_component/types.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { CollectionComponentType, keyCollectionDefinition } from './constants'; - -import { ComponentDefinition } from '../../../dom_components/model/types'; -import { CollectionVariableDefinition } from '../../../../test/specs/dom_components/model/ComponentTypes'; -import { DataVariableDefinition } from '../DataVariable'; - -export type CollectionDataSource = any[] | DataVariableDefinition | CollectionVariableDefinition; - -export interface CollectionConfig { - startIndex?: number; - endIndex?: number; - dataSource: CollectionDataSource; -} - -export enum CollectionStateVariableType { - currentIndex = 'currentIndex', - startIndex = 'startIndex', - currentItem = 'currentItem', - endIndex = 'endIndex', - collectionName = 'collectionName', - totalItems = 'totalItems', - remainingItems = 'remainingItems', -} - -export interface CollectionState { - [CollectionStateVariableType.currentIndex]: number; - [CollectionStateVariableType.startIndex]: number; - [CollectionStateVariableType.currentItem]: any; - [CollectionStateVariableType.endIndex]: number; - [CollectionStateVariableType.collectionName]?: string; - [CollectionStateVariableType.totalItems]: number; - [CollectionStateVariableType.remainingItems]: number; -} - -export interface CollectionsStateMap { - [key: string]: CollectionState; -} - -export interface CollectionComponentDefinition extends ComponentDefinition { - [keyCollectionDefinition]: CollectionDefinition; -} - -export interface CollectionDefinition { - type: typeof CollectionComponentType; - collectionName?: string; - config: CollectionConfig; - block: ComponentDefinition; -} diff --git a/packages/core/src/data_sources/model/collection_component/CollectionVariable.ts b/packages/core/src/data_sources/model/data_collection/CollectionVariable.ts similarity index 81% rename from packages/core/src/data_sources/model/collection_component/CollectionVariable.ts rename to packages/core/src/data_sources/model/data_collection/CollectionVariable.ts index 9e241fc39..38dc6d429 100644 --- a/packages/core/src/data_sources/model/collection_component/CollectionVariable.ts +++ b/packages/core/src/data_sources/model/data_collection/CollectionVariable.ts @@ -1,20 +1,20 @@ -import { CollectionVariableDefinition } from '../../../../test/specs/dom_components/model/ComponentTypes'; +import { DataCollectionVariableDefinition } from './types'; import { Model } from '../../../common'; import EditorModel from '../../../editor/model/Editor'; import DataVariable, { DataVariableType } from '../DataVariable'; import { keyInnerCollectionState } from './constants'; -import { CollectionState, CollectionsStateMap } from './types'; +import { DataCollectionState, DataCollectionStateMap } from './types'; -export default class CollectionVariable extends Model { +export default class CollectionVariable extends Model { em: EditorModel; - collectionsStateMap: CollectionsStateMap; + collectionsStateMap: DataCollectionStateMap; dataVariable?: DataVariable; constructor( - attrs: CollectionVariableDefinition, + attrs: DataCollectionVariableDefinition, options: { em: EditorModel; - collectionsStateMap: CollectionsStateMap; + collectionsStateMap: DataCollectionStateMap; }, ) { super(attrs, options); @@ -39,7 +39,7 @@ export default class CollectionVariable extends Model { cmp.set(keyIsCollectionItem, true); cmp.set(keyCollectionsStateMap, collectionsStateMap); diff --git a/packages/core/src/data_sources/model/data_collection/ComponentDataCollectionView.ts b/packages/core/src/data_sources/model/data_collection/ComponentDataCollectionView.ts new file mode 100644 index 000000000..9b3f88a84 --- /dev/null +++ b/packages/core/src/data_sources/model/data_collection/ComponentDataCollectionView.ts @@ -0,0 +1,4 @@ +import ComponentView from '../../../dom_components/view/ComponentView'; +import ComponentDataCollection from './ComponentDataCollection'; + +export default class ComponentDataCollectionView extends ComponentView {} diff --git a/packages/core/src/data_sources/model/collection_component/constants.ts b/packages/core/src/data_sources/model/data_collection/constants.ts similarity index 100% rename from packages/core/src/data_sources/model/collection_component/constants.ts rename to packages/core/src/data_sources/model/data_collection/constants.ts diff --git a/packages/core/src/data_sources/model/data_collection/types.ts b/packages/core/src/data_sources/model/data_collection/types.ts new file mode 100644 index 000000000..50d118618 --- /dev/null +++ b/packages/core/src/data_sources/model/data_collection/types.ts @@ -0,0 +1,53 @@ +import { CollectionComponentType, CollectionVariableType, keyCollectionDefinition } from './constants'; +import { ComponentDefinition } from '../../../dom_components/model/types'; +import { DataVariableDefinition } from '../DataVariable'; + +export type DataCollectionDataSource = any[] | DataVariableDefinition | DataCollectionVariableDefinition; + +export interface DataCollectionConfig { + startIndex?: number; + endIndex?: number; + dataSource: DataCollectionDataSource; +} + +export enum DataCollectionStateVariableType { + currentIndex = 'currentIndex', + startIndex = 'startIndex', + currentItem = 'currentItem', + endIndex = 'endIndex', + collectionName = 'collectionName', + totalItems = 'totalItems', + remainingItems = 'remainingItems', +} + +export interface DataCollectionState { + [DataCollectionStateVariableType.currentIndex]: number; + [DataCollectionStateVariableType.startIndex]: number; + [DataCollectionStateVariableType.currentItem]: any; + [DataCollectionStateVariableType.endIndex]: number; + [DataCollectionStateVariableType.collectionName]?: string; + [DataCollectionStateVariableType.totalItems]: number; + [DataCollectionStateVariableType.remainingItems]: number; +} + +export interface DataCollectionStateMap { + [key: string]: DataCollectionState; +} + +export interface ComponentDataCollectionDefinition extends ComponentDefinition { + [keyCollectionDefinition]: DataCollectionDefinition; +} + +export interface DataCollectionDefinition { + type: typeof CollectionComponentType; + collectionName?: string; + config: DataCollectionConfig; + block: ComponentDefinition; +} + +export type DataCollectionVariableDefinition = { + type: typeof CollectionVariableType; + variableType: DataCollectionStateVariableType; + collectionName?: string; + path?: string; +}; diff --git a/packages/core/src/data_sources/model/utils.ts b/packages/core/src/data_sources/model/utils.ts index 71322c160..0f1d216fa 100644 --- a/packages/core/src/data_sources/model/utils.ts +++ b/packages/core/src/data_sources/model/utils.ts @@ -1,9 +1,9 @@ import EditorModel from '../../editor/model/Editor'; import { DynamicValue, DynamicValueDefinition } from '../types'; -import { CollectionsStateMap } from './collection_component/types'; -import CollectionVariable from './collection_component/CollectionVariable'; -import { CollectionVariableDefinition } from '../../../test/specs/dom_components/model/ComponentTypes'; -import { CollectionVariableType } from './collection_component/constants'; +import { DataCollectionStateMap } from './data_collection/types'; +import CollectionVariable from './data_collection/CollectionVariable'; +import { DataCollectionVariableDefinition } from './data_collection/types'; +import { CollectionVariableType } from './data_collection/constants'; import { ConditionalVariableType, DataCondition } from './conditional_variables/DataCondition'; import DataVariable, { DataVariableType } from './DataVariable'; @@ -34,7 +34,7 @@ export function getDynamicValueInstance( valueDefinition: DynamicValueDefinition, options: { em: EditorModel; - collectionsStateMap?: CollectionsStateMap; + collectionsStateMap?: DataCollectionStateMap; }, ): DynamicValue { const { em } = options; @@ -66,7 +66,7 @@ export function evaluateDynamicValueDefinition( valueDefinition: DynamicValueDefinition, options: { em: EditorModel; - collectionsStateMap?: CollectionsStateMap; + collectionsStateMap?: DataCollectionStateMap; }, ) { const dynamicVariable = getDynamicValueInstance(valueDefinition, options); diff --git a/packages/core/src/data_sources/types.ts b/packages/core/src/data_sources/types.ts index f40bf729a..33626e8c3 100644 --- a/packages/core/src/data_sources/types.ts +++ b/packages/core/src/data_sources/types.ts @@ -1,6 +1,6 @@ import { ObjectAny } from '../common'; -import CollectionVariable from './model/collection_component/CollectionVariable'; -import { CollectionVariableDefinition } from '../../test/specs/dom_components/model/ComponentTypes'; +import CollectionVariable from './model/data_collection/CollectionVariable'; +import { DataCollectionVariableDefinition } from './model/data_collection/types'; import ComponentDataVariable from './model/ComponentDataVariable'; import DataRecord from './model/DataRecord'; import DataRecords from './model/DataRecords'; @@ -11,7 +11,7 @@ export type DynamicValue = DataVariable | ComponentDataVariable | DataCondition export type DynamicValueDefinition = | DataVariableDefinition | ConditionalVariableDefinition - | CollectionVariableDefinition; + | DataCollectionVariableDefinition; export interface DataRecordProps extends ObjectAny { /** * Record id. diff --git a/packages/core/src/dom_components/index.ts b/packages/core/src/dom_components/index.ts index 7daac11c5..0f4cfeaee 100644 --- a/packages/core/src/dom_components/index.ts +++ b/packages/core/src/dom_components/index.ts @@ -128,9 +128,9 @@ import { DataVariableType } from '../data_sources/model/DataVariable'; import { ConditionalVariableType } from '../data_sources/model/conditional_variables/DataCondition'; import ComponentConditionalVariable from '../data_sources/model/conditional_variables/ConditionalComponent'; import ConditionalComponentView from '../data_sources/view/ComponentDynamicView'; -import CollectionComponent from '../data_sources/model/collection_component/CollectionComponent'; -import CollectionComponentView from '../data_sources/model/collection_component/CollectionComponentView'; -import { CollectionComponentType } from '../data_sources/model/collection_component/constants'; +import ComponentDataCollection from '../data_sources/model/data_collection/ComponentDataCollection'; +import ComponentDataCollectionView from '../data_sources/model/data_collection/ComponentDataCollectionView'; +import { CollectionComponentType } from '../data_sources/model/data_collection/constants'; export type ComponentEvent = | 'component:create' @@ -198,8 +198,8 @@ export default class ComponentManager extends ItemManagerModule {} export interface SetAttrOptions extends SetOptions, UpdateStyleOptions, DynamicWatchersOptions {} @@ -349,7 +349,7 @@ export default class Component extends StyleableModel { } } - getCollectionStateMap(): CollectionsStateMap { + getCollectionStateMap(): DataCollectionStateMap { const collectionStateMapProp = this.get(keyCollectionsStateMap); if (collectionStateMapProp) { return collectionStateMapProp; @@ -2012,7 +2012,7 @@ export default class Component extends StyleableModel { selector && selector.set({ name: id, label: id }); } - private handleCollectionsMapStateChange(m: any, v: CollectionsStateMap, opts = {}) { + private handleCollectionsMapStateChange(m: any, v: DataCollectionStateMap, opts = {}) { this.componentDVListener.updateCollectionStateMap(v); this.components()?.forEach((child) => { child.set?.(keyCollectionsStateMap, v); diff --git a/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts b/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts index 384e09553..02464764e 100644 --- a/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts +++ b/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts @@ -1,6 +1,6 @@ import { Model, ObjectAny } from '../../common'; -import { CollectionVariableType, keyIsCollectionItem } from '../../data_sources/model/collection_component/constants'; -import { CollectionsStateMap } from '../../data_sources/model/collection_component/types'; +import { CollectionVariableType, keyIsCollectionItem } from '../../data_sources/model/data_collection/constants'; +import { DataCollectionStateMap } from '../../data_sources/model/data_collection/types'; import EditorModel from '../../editor/model/Editor'; import Component, { keyCollectionsStateMap } from './Component'; import { DynamicWatchersOptions } from './DynamicValueWatcher'; @@ -15,7 +15,7 @@ export class ComponentDynamicValueWatcher extends Model { private component: Component | undefined, options: { em: EditorModel; - collectionsStateMap?: CollectionsStateMap; + collectionsStateMap?: DataCollectionStateMap; }, ) { super(component, options); @@ -44,7 +44,7 @@ export class ComponentDynamicValueWatcher extends Model { this.updateSymbolOverride(); } - updateCollectionStateMap(collectionsStateMap: CollectionsStateMap) { + updateCollectionStateMap(collectionsStateMap: DataCollectionStateMap) { this.propertyWatcher.updateCollectionStateMap(collectionsStateMap); this.attributeWatcher.updateCollectionStateMap(collectionsStateMap); } diff --git a/packages/core/src/dom_components/model/DynamicValueWatcher.ts b/packages/core/src/dom_components/model/DynamicValueWatcher.ts index 3667ccc1e..a14737b3b 100644 --- a/packages/core/src/dom_components/model/DynamicValueWatcher.ts +++ b/packages/core/src/dom_components/model/DynamicValueWatcher.ts @@ -1,11 +1,11 @@ import { DynamicValueDefinition } from './../../data_sources/types'; -import { CollectionsStateMap } from '../../data_sources/model/collection_component/types'; +import { DataCollectionStateMap } from '../../data_sources/model/data_collection/types'; import { Model, ObjectAny } from '../../common'; import DynamicVariableListenerManager from '../../data_sources/model/DataVariableListenerManager'; import { evaluateDynamicValueDefinition, isDynamicValueDefinition } from '../../data_sources/model/utils'; import EditorModel from '../../editor/model/Editor'; import Component from './Component'; -import { CollectionVariableType } from '../../data_sources/model/collection_component/constants'; +import { CollectionVariableType } from '../../data_sources/model/data_collection/constants'; import { ModelDestroyOptions } from 'backbone'; export interface DynamicWatchersOptions { @@ -18,13 +18,13 @@ type UpdateFn = (component: Component | undefined, key: string, value: any) => v export class DynamicValueWatcher extends Model<{ component: Component | undefined; updateFn: UpdateFn }> { private dynamicVariableListeners: { [key: string]: DynamicVariableListenerManager } = {}; private em: EditorModel; - private collectionsStateMap?: CollectionsStateMap; + private collectionsStateMap?: DataCollectionStateMap; constructor( private component: Component | undefined, private updateFn: UpdateFn, options: { em: EditorModel; - collectionsStateMap?: CollectionsStateMap; + collectionsStateMap?: DataCollectionStateMap; }, ) { super({ component, updateFn }, options); @@ -36,7 +36,7 @@ export class DynamicValueWatcher extends Model<{ component: Component | undefine this.component = component; } - updateCollectionStateMap(collectionsStateMap: CollectionsStateMap) { + updateCollectionStateMap(collectionsStateMap: DataCollectionStateMap) { this.collectionsStateMap = collectionsStateMap; const collectionVariablesKeys = this.getDynamicValuesOfType(CollectionVariableType); diff --git a/packages/core/src/dom_components/model/SymbolUtils.ts b/packages/core/src/dom_components/model/SymbolUtils.ts index e57abd5f2..94e4affd6 100644 --- a/packages/core/src/dom_components/model/SymbolUtils.ts +++ b/packages/core/src/dom_components/model/SymbolUtils.ts @@ -3,7 +3,7 @@ import Component, { keySymbol, keySymbolOvrd, keySymbols } from './Component'; import { SymbolToUpOptions } from './types'; import { isEmptyObj } from '../../utils/mixins'; import Components from './Components'; -import { CollectionVariableType } from '../../data_sources/model/collection_component/constants'; +import { CollectionVariableType } from '../../data_sources/model/data_collection/constants'; export const isSymbolMain = (cmp: Component) => isArray(cmp.get(keySymbols)); diff --git a/packages/core/src/dom_components/model/types.ts b/packages/core/src/dom_components/model/types.ts index c36911b92..0c9cfa237 100644 --- a/packages/core/src/dom_components/model/types.ts +++ b/packages/core/src/dom_components/model/types.ts @@ -12,7 +12,7 @@ import Component from './Component'; import Components from './Components'; import { ToolbarButtonProps } from './ToolbarButton'; import { ParseNodeOptions } from '../../parser/config/config'; -import { CollectionsStateMap } from '../../data_sources/model/collection_component/types'; +import { DataCollectionStateMap } from '../../data_sources/model/data_collection/types'; export type DragMode = 'translate' | 'absolute' | ''; diff --git a/packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts b/packages/core/test/specs/data_sources/model/data_collection/ComponentDataCollection.ts similarity index 90% rename from packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts rename to packages/core/test/specs/data_sources/model/data_collection/ComponentDataCollection.ts index 36756565a..7a6a4a72e 100644 --- a/packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts +++ b/packages/core/test/specs/data_sources/model/data_collection/ComponentDataCollection.ts @@ -3,8 +3,8 @@ import { DataVariableType } from '../../../../../src/data_sources/model/DataVari import { CollectionComponentType, CollectionVariableType, -} from '../../../../../src/data_sources/model/collection_component/constants'; -import { CollectionStateVariableType } from '../../../../../src/data_sources/model/collection_component/types'; +} from '../../../../../src/data_sources/model/data_collection/constants'; +import { DataCollectionStateVariableType } from '../../../../../src/data_sources/model/data_collection/types'; import EditorModel from '../../../../../src/editor/model/Editor'; import { filterObjectForSnapshot, setupTestEditor } from '../../../../common'; import { getSymbolMain } from '../../../../../src/dom_components/model/SymbolUtils'; @@ -130,19 +130,19 @@ describe('Collection component', () => { type: 'default', name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, ], name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, custom_property: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -205,7 +205,7 @@ describe('Collection component', () => { firstChild.set('name', { // @ts-ignore type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'age', }); expect(firstChild.get('name')).toBe('12'); @@ -223,7 +223,7 @@ describe('Collection component', () => { firstGrandchild.set('name', { // @ts-ignore type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'age', }); expect(firstGrandchild.get('name')).toBe('new_value_12'); @@ -286,7 +286,7 @@ describe('Collection component', () => { attributes: { name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -295,7 +295,7 @@ describe('Collection component', () => { attributes: { name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -356,7 +356,7 @@ describe('Collection component', () => { name: { // @ts-ignore type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'age', }, }); @@ -376,7 +376,7 @@ describe('Collection component', () => { name: { // @ts-ignore type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'age', }, }); @@ -435,7 +435,7 @@ describe('Collection component', () => { name: 'attribute_trait', value: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -444,7 +444,7 @@ describe('Collection component', () => { changeProp: true, value: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -486,18 +486,18 @@ describe('Collection component', () => { type: 'default', name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, custom_prop: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentIndex, + variableType: DataCollectionStateVariableType.currentIndex, path: 'user', }, attributes: { name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -506,7 +506,7 @@ describe('Collection component', () => { name: 'attribute_trait', value: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -515,7 +515,7 @@ describe('Collection component', () => { changeProp: true, value: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -552,7 +552,7 @@ describe('Collection component', () => { type: 'default', name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentIndex, + variableType: DataCollectionStateVariableType.currentIndex, path: 'user', }, }; @@ -573,7 +573,7 @@ describe('Collection component', () => { type: 'default', name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentIndex, + variableType: DataCollectionStateVariableType.currentIndex, path: 'user', }, }; @@ -597,12 +597,12 @@ describe('Collection component', () => { attribute_trait: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, name: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, }, components: [ @@ -611,18 +611,18 @@ describe('Collection component', () => { attribute_trait: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, name: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, }, name: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, custom_prop: { path: 'user', @@ -632,7 +632,7 @@ describe('Collection component', () => { property_trait: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, type: 'default', }, @@ -641,18 +641,18 @@ describe('Collection component', () => { attribute_trait: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, name: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, }, name: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, custom_prop: { path: 'user', @@ -662,7 +662,7 @@ describe('Collection component', () => { property_trait: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, type: 'default', }, @@ -670,7 +670,7 @@ describe('Collection component', () => { name: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, custom_prop: { path: 'user', @@ -680,7 +680,7 @@ describe('Collection component', () => { property_trait: { path: 'user', type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, }, type: 'default', }, @@ -766,7 +766,7 @@ describe('Collection component', () => { type: 'default', name: { type: CollectionVariableType, - variableType: CollectionStateVariableType.currentItem, + variableType: DataCollectionStateVariableType.currentItem, path: 'user', }, }, @@ -792,15 +792,15 @@ describe('Collection component', () => { describe('Diffirent Collection variable types', () => { const stateVariableTests = [ - { variableType: CollectionStateVariableType.currentIndex, expectedValues: [0, 1, 2] }, - { variableType: CollectionStateVariableType.startIndex, expectedValues: [0, 0, 0] }, - { variableType: CollectionStateVariableType.endIndex, expectedValues: [2, 2, 2] }, + { variableType: DataCollectionStateVariableType.currentIndex, expectedValues: [0, 1, 2] }, + { variableType: DataCollectionStateVariableType.startIndex, expectedValues: [0, 0, 0] }, + { variableType: DataCollectionStateVariableType.endIndex, expectedValues: [2, 2, 2] }, { - variableType: CollectionStateVariableType.collectionName, + variableType: DataCollectionStateVariableType.collectionName, expectedValues: ['my_collection', 'my_collection', 'my_collection'], }, - { variableType: CollectionStateVariableType.totalItems, expectedValues: [3, 3, 3] }, - { variableType: CollectionStateVariableType.remainingItems, expectedValues: [2, 1, 0] }, + { variableType: DataCollectionStateVariableType.totalItems, expectedValues: [3, 3, 3] }, + { variableType: DataCollectionStateVariableType.remainingItems, expectedValues: [2, 1, 0] }, ]; stateVariableTests.forEach(({ variableType, expectedValues }) => { diff --git a/packages/core/test/specs/data_sources/model/collection_component/__snapshots__/CollectionComponent.ts.snap b/packages/core/test/specs/data_sources/model/data_collection/__snapshots__/ComponentDataCollection.ts.snap similarity index 100% rename from packages/core/test/specs/data_sources/model/collection_component/__snapshots__/CollectionComponent.ts.snap rename to packages/core/test/specs/data_sources/model/data_collection/__snapshots__/ComponentDataCollection.ts.snap diff --git a/packages/core/test/specs/dom_components/model/ComponentTypes.ts b/packages/core/test/specs/dom_components/model/ComponentTypes.ts index f074d4b3b..63db8a034 100644 --- a/packages/core/test/specs/dom_components/model/ComponentTypes.ts +++ b/packages/core/test/specs/dom_components/model/ComponentTypes.ts @@ -1,5 +1,3 @@ -import { CollectionVariableType } from '../../../../src/data_sources/model/collection_component/constants'; -import { CollectionStateVariableType } from '../../../../src/data_sources/model/collection_component/types'; import Editor from '../../../../src/editor'; describe('Component Types', () => { @@ -98,10 +96,3 @@ describe('Component Types', () => { expect(cmp.components().at(0).is('svg-in')).toBe(true); }); }); - -export type CollectionVariableDefinition = { - type: typeof CollectionVariableType; - variableType: CollectionStateVariableType; - collectionName?: string; - path?: string; -};