diff --git a/docs/modules/DataSources.md b/docs/modules/DataSources.md index 23d9313e5..962358849 100644 --- a/docs/modules/DataSources.md +++ b/docs/modules/DataSources.md @@ -52,7 +52,7 @@ editor.addComponents([ components: [ { type: 'data-variable', - value: 'default', + defaultValue: 'default', path: 'my-datasource.id1.content', }, ], @@ -76,14 +76,14 @@ editor.addComponents([ components: [ { type: 'data-variable', - value: 'default', + defaultValue: 'default', path: 'my-datasource.id1.content', }, ], style: { color: { type: 'data-variable', - value: 'red', + defaultValue: 'red', path: 'my-datasource.id2.color', }, }, @@ -118,7 +118,7 @@ editor.addComponents([ name: 'value', value: { type: 'data-variable', - value: 'default', + defaultValue: 'default', path: 'my-datasource.id1.value', }, }, @@ -253,7 +253,7 @@ editor.addComponents([ components: [ { type: 'data-variable', - value: 'default', + defaultValue: 'default', path: 'my-datasource.id1.counter', }, ], diff --git a/src/data_sources/model/ComponentDataVariable.ts b/src/data_sources/model/ComponentDataVariable.ts index 6f740ed4b..7c5d81b92 100644 --- a/src/data_sources/model/ComponentDataVariable.ts +++ b/src/data_sources/model/ComponentDataVariable.ts @@ -10,13 +10,13 @@ export default class ComponentDataVariable extends Component { ...super.defaults, type: DataVariableType, path: '', - value: '', + defaultValue: '', }; } getInnerHTML(opts: ToHTMLOptions) { - const { path, value } = this.attributes; - const val = this.em.DataSources.getValue(path, value); + const { path, defaultValue } = this.attributes; + const val = this.em.DataSources.getValue(path, defaultValue); return val; } diff --git a/src/data_sources/model/DataVariable.ts b/src/data_sources/model/DataVariable.ts index 4b8569c6e..fce884565 100644 --- a/src/data_sources/model/DataVariable.ts +++ b/src/data_sources/model/DataVariable.ts @@ -10,7 +10,7 @@ export default class DataVariable extends Model { defaults() { return { type: DataVariableType, - value: '', + defaultValue: '', path: '', }; } @@ -36,8 +36,8 @@ export default class DataVariable extends Model { } getDataValue() { - const { path, value } = this.attributes; - const val = this.em?.DataSources?.getValue?.(path, value); + const { path, defaultValue } = this.attributes; + const val = this.em?.DataSources?.getValue?.(path, defaultValue); return val; } diff --git a/src/data_sources/model/TraitDataVariable.ts b/src/data_sources/model/TraitDataVariable.ts index aa6ce9a38..b8aedc1f5 100644 --- a/src/data_sources/model/TraitDataVariable.ts +++ b/src/data_sources/model/TraitDataVariable.ts @@ -4,11 +4,9 @@ import Trait from '../../trait_manager/model/Trait'; export default class TraitDataVariable extends DataVariable { trait?: Trait; - initialize(attrs: any, options: any) { - super.initialize(attrs, options); + constructor(attrs: any, options: any) { + super(attrs, options); this.trait = options.trait; - - return this; } onDataSourceChange() { diff --git a/src/data_sources/view/ComponentDataVariableView.ts b/src/data_sources/view/ComponentDataVariableView.ts index 63e846e94..2c9832535 100644 --- a/src/data_sources/view/ComponentDataVariableView.ts +++ b/src/data_sources/view/ComponentDataVariableView.ts @@ -37,8 +37,8 @@ export default class ComponentDataVariableView extends ComponentView { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'ds1.id1.name', }, ], @@ -69,7 +69,7 @@ describe('ComponentDataVariable', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'ds2.id1.name', }, ], @@ -90,7 +90,7 @@ describe('ComponentDataVariable', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'unknown.id1.name', }, ], @@ -112,7 +112,7 @@ describe('ComponentDataVariable', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'ds3.id1.name', }, ], @@ -137,7 +137,7 @@ describe('ComponentDataVariable', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${dataSource.id}.id1.name`, }, ], @@ -164,7 +164,7 @@ describe('ComponentDataVariable', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'ds4.id1.name', }, ], @@ -198,7 +198,7 @@ describe('ComponentDataVariable', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'dsNestedObject.id1.nestedObject.name', }, ], @@ -237,7 +237,7 @@ describe('ComponentDataVariable', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'dsNestedArray.id1.items.0.nestedObject.name', }, ], diff --git a/test/specs/data_sources/model/StyleDataVariable.ts b/test/specs/data_sources/model/StyleDataVariable.ts index 01ced18ed..bd3adc3d7 100644 --- a/test/specs/data_sources/model/StyleDataVariable.ts +++ b/test/specs/data_sources/model/StyleDataVariable.ts @@ -48,7 +48,7 @@ describe('StyleDataVariable', () => { style: { color: { type: DataVariableType, - value: 'black', + defaultValue: 'black', path: 'colors-data.id1.color', }, }, @@ -72,7 +72,7 @@ describe('StyleDataVariable', () => { style: { color: { type: DataVariableType, - value: 'black', + defaultValue: 'black', path: 'colors-data.id1.color', }, }, @@ -96,7 +96,7 @@ describe('StyleDataVariable', () => { style: { color: { type: DataVariableType, - value: 'black', + defaultValue: 'black', path: 'unknown.id1.color', }, }, @@ -127,7 +127,7 @@ describe('StyleDataVariable', () => { style: { color: { type: DataVariableType, - value: 'black', + defaultValue: 'black', path: 'style-data.id1.nestedObject.color', }, }, diff --git a/test/specs/data_sources/model/TraitDataVariable.ts b/test/specs/data_sources/model/TraitDataVariable.ts index 988bfbacb..a4abaf3c5 100644 --- a/test/specs/data_sources/model/TraitDataVariable.ts +++ b/test/specs/data_sources/model/TraitDataVariable.ts @@ -52,7 +52,7 @@ describe('TraitDataVariable', () => { name: 'value', value: { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${inputDataSource.id}.id1.value`, }, }, @@ -81,7 +81,7 @@ describe('TraitDataVariable', () => { name: 'placeholder', value: { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${inputDataSource.id}.id1.value`, }, }, @@ -117,7 +117,7 @@ describe('TraitDataVariable', () => { name: 'value', value: { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${inputDataSource.id}.id1.value`, }, }, @@ -159,7 +159,7 @@ describe('TraitDataVariable', () => { name: 'value', value: { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'nested-input-data.id1.nestedObject.value', }, }, @@ -191,7 +191,7 @@ describe('TraitDataVariable', () => { name: 'checked', value: { type: 'data-variable', - value: 'false', + defaultValue: 'false', path: `${inputDataSource.id}.id1.value`, }, valueTrue: 'true', @@ -233,7 +233,7 @@ describe('TraitDataVariable', () => { name: 'src', value: { type: 'data-variable', - value: 'default', + defaultValue: 'default', path: `${inputDataSource.id}.id1.value`, }, }, @@ -269,7 +269,7 @@ describe('TraitDataVariable', () => { name: 'href', value: { type: 'data-variable', - value: 'default', + defaultValue: 'default', path: `${inputDataSource.id}.id1.value`, }, }, @@ -306,7 +306,7 @@ describe('TraitDataVariable', () => { changeProp: true, value: { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${inputDataSource.id}.id1.value`, }, }, diff --git a/test/specs/data_sources/serialization.ts b/test/specs/data_sources/serialization.ts index 8706b1c79..6c60179a5 100644 --- a/test/specs/data_sources/serialization.ts +++ b/test/specs/data_sources/serialization.ts @@ -96,7 +96,7 @@ describe('DataSource Serialization', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${componentDataSource.id}.id1.content`, }, ], @@ -113,7 +113,7 @@ describe('DataSource Serialization', () => { test('ComponentDataVariable', () => { const dataVariable = { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${componentDataSource.id}.id1.content`, }; @@ -136,7 +136,7 @@ describe('DataSource Serialization', () => { test('StyleDataVariable', () => { const dataVariable = { type: DataVariableType, - value: 'black', + defaultValue: 'black', path: 'colors-data.id1.color', }; @@ -168,7 +168,7 @@ describe('DataSource Serialization', () => { test('TraitDataVariable', () => { const dataVariable = { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: `${traitDataSource.id}.id1.value`, }; @@ -309,7 +309,7 @@ describe('DataSource Serialization', () => { color: { path: 'colors-data.id1.color', type: 'data-variable', - value: 'black', + defaultValue: 'black', }, }, }, @@ -345,7 +345,7 @@ describe('DataSource Serialization', () => { value: { path: 'test-input.id1.value', type: 'data-variable', - value: 'default', + defaultValue: 'default', }, }, tagName: 'input', diff --git a/test/specs/data_sources/transformers.ts b/test/specs/data_sources/transformers.ts index dd0b7c258..785b5c086 100644 --- a/test/specs/data_sources/transformers.ts +++ b/test/specs/data_sources/transformers.ts @@ -53,7 +53,7 @@ describe('DataSource Transformers', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'test-data-source.id1.content', }, ], @@ -95,7 +95,7 @@ describe('DataSource Transformers', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'test-data-source.id1.content', }, ], @@ -135,7 +135,7 @@ describe('DataSource Transformers', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'test-data-source.id1.content', }, ], @@ -171,7 +171,7 @@ describe('DataSource Transformers', () => { components: [ { type: DataVariableType, - value: 'default', + defaultValue: 'default', path: 'test-data-source.id1.content', }, ],