Browse Source

Refactor CollectionStateVariableType

pull/6359/head
mohamedsalem401 1 year ago
parent
commit
e2d4bbe2ed
  1. 24
      packages/core/src/data_sources/model/collection_component/types.ts
  2. 5
      packages/core/test/specs/dom_components/model/ComponentTypes.ts

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

@ -11,14 +11,24 @@ type CollectionConfig = {
dataSource: CollectionDataSource;
};
export enum CollectionStateVariableType {
current_index = 'current_index',
start_index = 'start_index',
current_item = 'current_item',
end_index = 'end_index',
collection_name = 'collection_name',
total_items = 'total_items',
remaining_items = 'remaining_items',
}
export type CollectionState = {
current_index: number;
start_index: number;
current_item: any;
end_index: number;
collection_name?: string;
total_items: number;
remaining_items: number;
[CollectionStateVariableType.current_index]: number;
[CollectionStateVariableType.start_index]: number;
[CollectionStateVariableType.current_item]: any;
[CollectionStateVariableType.end_index]: number;
[CollectionStateVariableType.collection_name]?: string;
[CollectionStateVariableType.total_items]: number;
[CollectionStateVariableType.remaining_items]: number;
};
export type CollectionsStateMap = {

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

@ -1,5 +1,5 @@
import { CollectionVariableType } from '../../../../src/data_sources/model/collection_component/constants';
import { CollectionState } from '../../../../src/data_sources/model/collection_component/types';
import { CollectionStateVariableType } from '../../../../src/data_sources/model/collection_component/types';
import Editor from '../../../../src/editor';
describe('Component Types', () => {
@ -98,9 +98,10 @@ describe('Component Types', () => {
expect(cmp.components().at(0).is('svg-in')).toBe(true);
});
});
export type CollectionVariableDefinition = {
type: typeof CollectionVariableType;
variable_type: keyof CollectionState;
variable_type: CollectionStateVariableType;
collection_name?: string;
path?: string;
};

Loading…
Cancel
Save