Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
Fixes title when deserializing variable. (#64)
Browse files Browse the repository at this point in the history
* Fixes title when deserializing variable.

* Fix alignment.
  • Loading branch information
chriscox authored Jan 13, 2017
1 parent 7cb0c9b commit 46f2410
Showing 6 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/core/variables/BooleanVariable.ts
Original file line number Diff line number Diff line change
@@ -82,6 +82,8 @@ export class BooleanVariable extends Variable implements IBooleanVariableParams
* @return {BooleanVariable} A new initialized BooleanVariable.
*/
static deserialize(data: ISerializableData): BooleanVariable {
return new BooleanVariable(data.key, data.selectedValue);
let variable = new BooleanVariable(data.key, data.selectedValue);
variable.title = data.title;
return variable;
}
}
4 changes: 3 additions & 1 deletion src/core/variables/ColorVariable.ts
Original file line number Diff line number Diff line change
@@ -117,6 +117,8 @@ export class ColorVariable extends Variable implements IColorVariableParams {
let limitedToValues = data.limitedToValues.map((color: string) => {
return TinyColor(color).toHexString();
});
return new ColorVariable(data.key, selectedValue, limitedToValues);
let variable = new ColorVariable(data.key, selectedValue, limitedToValues);
variable.title = data.title;
return variable;
}
}
6 changes: 4 additions & 2 deletions src/core/variables/NumberVariable.ts
Original file line number Diff line number Diff line change
@@ -114,10 +114,12 @@ export class NumberVariable extends Variable implements INumberVariableParams {
* @return {NumberVariable} A new initialized NumberVariable.
*/
static deserialize(data: ISerializableData): Variable {
return new NumberVariable(
let variable = new NumberVariable(
data.key,
data.selectedValue,
data.limitedToValues,
data.limitedToValues
);
variable.title = data.title;
return variable;
}
}
4 changes: 3 additions & 1 deletion src/core/variables/RangeVariable.ts
Original file line number Diff line number Diff line change
@@ -138,12 +138,14 @@ export class RangeVariable extends Variable implements IRangeVariableParams {
let minValue: number = data.minValue;
let maxValue: number = data.maxValue;
let increment: number = data.increment;
return new RangeVariable(
let variable = new RangeVariable(
data.key,
selectedValue,
minValue,
maxValue,
increment,
);
variable.title = data.title;
return variable;
}
}
4 changes: 3 additions & 1 deletion src/core/variables/StringVariable.ts
Original file line number Diff line number Diff line change
@@ -114,10 +114,12 @@ export class StringVariable extends Variable implements IStringVariableParams {
* @return {StringVariable} A new initialized StringVariable.
*/
static deserialize(data: ISerializableData): StringVariable {
return new StringVariable(
let variable = new StringVariable(
data.key,
data.selectedValue,
data.limitedToValues,
);
variable.title = data.title;
return variable;
}
}
2 changes: 1 addition & 1 deletion src/core/variables/Variable.ts
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ export class Variable implements IVariableParams {
}

/**
* Subclass should override this method and return a new instance of thei
* Subclass should override this method and return a new instance of the
* Variable class from serialized data.
* @param {ISerializableData} data The serialized data.
* @return {Variable} A new initialized Variable subclass.

0 comments on commit 46f2410

Please sign in to comment.