From 0aeef2d0337f1d4bcb2eacb527c670f4125b4b72 Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Thu, 16 Jan 2025 12:59:58 +0200 Subject: [PATCH] Improve DataCollectionVariable serialization --- .../ComponentDataCollectionVariable.ts | 6 +++--- .../data_collection/DataCollectionVariable.ts | 13 +++++++++++-- .../core/src/dom_components/model/Component.ts | 14 +++++++------- .../model/ComponentDynamicValueWatcher.ts | 4 ++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/packages/core/src/data_sources/model/data_collection/ComponentDataCollectionVariable.ts b/packages/core/src/data_sources/model/data_collection/ComponentDataCollectionVariable.ts index 484aa9fd3..15a55a191 100644 --- a/packages/core/src/data_sources/model/data_collection/ComponentDataCollectionVariable.ts +++ b/packages/core/src/data_sources/model/data_collection/ComponentDataCollectionVariable.ts @@ -13,9 +13,9 @@ export default class ComponentDataCollectionVariable extends Component { // @ts-ignore ...super.defaults, type: CollectionVariableType, - variableType: '', - path: '', - collectionName: keyInnerCollectionState, + collectionName: undefined, + variableType: undefined, + path: undefined, }; } diff --git a/packages/core/src/data_sources/model/data_collection/DataCollectionVariable.ts b/packages/core/src/data_sources/model/data_collection/DataCollectionVariable.ts index 7e8073ecd..c2d8a8b61 100644 --- a/packages/core/src/data_sources/model/data_collection/DataCollectionVariable.ts +++ b/packages/core/src/data_sources/model/data_collection/DataCollectionVariable.ts @@ -18,9 +18,9 @@ export default class DataCollectionVariable extends Model { return { type: CollectionVariableType, + collectionName: undefined, variableType: undefined, - path: '', - collectionName: keyInnerCollectionState, + path: undefined, value: undefined, }; } @@ -86,8 +86,17 @@ export default class DataCollectionVariable extends Model { } -export interface SetAttrOptions extends SetOptions, UpdateStyleOptions, DynamicWatchersOptions { } -export interface ComponentSetOptions extends SetOptions, DynamicWatchersOptions { } +export interface IComponent extends ExtractMethods {} +export interface SetAttrOptions extends SetOptions, UpdateStyleOptions, DynamicWatchersOptions {} +export interface ComponentSetOptions extends SetOptions, DynamicWatchersOptions {} const escapeRegExp = (str: string) => { return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); @@ -229,12 +229,12 @@ export default class Component extends StyleableModel { return this.frame?.getPage(); } - preInit() { } + preInit() {} /** * Hook method, called once the model is created */ - init() { } + init() {} /** * Hook method, called when the model has been updated (eg. updated some model's property) @@ -242,12 +242,12 @@ export default class Component extends StyleableModel { * @param {*} value Property value, if triggered after some property update * @param {*} previous Property previous value, if triggered after some property update */ - updated(property: string, value: any, previous: any) { } + updated(property: string, value: any, previous: any) {} /** * Hook method, called once the model has been removed */ - removed() { } + removed() {} em!: EditorModel; opt!: ComponentOptions; diff --git a/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts b/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts index bbee5e838..1eefa87e2 100644 --- a/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts +++ b/packages/core/src/dom_components/model/ComponentDynamicValueWatcher.ts @@ -56,8 +56,8 @@ export class ComponentDynamicValueWatcher extends Model { Object.entries(props).map(([key, value]) => excludedFromEvaluation.includes(key) ? [key, value] // Return excluded keys as they are - : [key, this.propertyWatcher.addDynamicValues({ [key]: value }, options)[key]] - ) + : [key, this.propertyWatcher.addDynamicValues({ [key]: value }, options)[key]], + ), ); if (props.attributes) {