FIX: mutate value if numeric in enums

This commit is contained in:
Joffrey JAFFEUX 2017-11-13 18:51:19 -08:00
parent 030c141383
commit e0bee3a3bc
2 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
{{combo-box valueAttribute="value" content=setting.validValues value=value none=setting.allowsNone}}
{{combo-box castInteger=true valueAttribute="value" content=setting.validValues value=value none=setting.allowsNone}}
{{preview}}
{{setting-validation-message message=validationMessage}}
<div class='desc'>{{{unbound setting.description}}}</div>

View File

@ -13,8 +13,12 @@ export default Ember.Mixin.create({
return content;
},
_isNumeric(input) {
return !isNaN(parseFloat(input)) && isFinite(input);
},
_castInteger(value) {
if (this.get("castInteger") === true && Ember.isPresent(value)) {
if (this.get("castInteger") === true && Ember.isPresent(value) && this._isNumeric(value)) {
return parseInt(value, 10);
}