diff --git a/src/domain_abstract/ui/Input.js b/src/domain_abstract/ui/Input.js index fe6b479a3..4981c90f5 100644 --- a/src/domain_abstract/ui/Input.js +++ b/src/domain_abstract/ui/Input.js @@ -75,6 +75,7 @@ module.exports = Backbone.View.extend({ }, render() { + this.inputEl = null; const el = this.$el; el.addClass(this.inputClass()); el.html(this.template()); diff --git a/src/domain_abstract/ui/InputNumber.js b/src/domain_abstract/ui/InputNumber.js index 434a2cc96..5beae61aa 100644 --- a/src/domain_abstract/ui/InputNumber.js +++ b/src/domain_abstract/ui/InputNumber.js @@ -269,6 +269,7 @@ module.exports = Input.extend({ render() { Input.prototype.render.call(this); + this.unitEl = null; const unit = this.getUnitEl(); unit && this.$el diff --git a/src/style_manager/model/PropertyComposite.js b/src/style_manager/model/PropertyComposite.js index 2228c1e48..6bea2a159 100644 --- a/src/style_manager/model/PropertyComposite.js +++ b/src/style_manager/model/PropertyComposite.js @@ -86,5 +86,14 @@ module.exports = Property.extend({ } return this.get('properties').getFullValue(); + }, + + /** + * Get property at some index + * @param {Number} index + * @return {Object} + */ + getPropertyAt(index) { + return this.get('properties').at(index); } }); diff --git a/src/style_manager/view/PropertyIntegerView.js b/src/style_manager/view/PropertyIntegerView.js index b2d19fbf5..83e206889 100644 --- a/src/style_manager/view/PropertyIntegerView.js +++ b/src/style_manager/view/PropertyIntegerView.js @@ -13,6 +13,7 @@ module.exports = PropertyView.extend({ const model = this.model; this.listenTo(model, 'change:unit', this.modelValueChanged); this.listenTo(model, 'el:change', this.elementUpdated); + this.listenTo(model, 'change:units', this.render); }, setValue(value) { @@ -25,6 +26,11 @@ module.exports = PropertyView.extend({ const ppfx = this.ppfx; if (!this.input) { + console.log( + 'onRender', + this.model.get('property'), + this.model.get('units') + ); const input = this.model.input; input.ppfx = ppfx; input.render(); @@ -36,5 +42,11 @@ module.exports = PropertyView.extend({ this.input = this.$input.get(0); this.inputInst = input; } + }, + + clearCached() { + PropertyView.prototype.clearCached.apply(this, arguments); + this.unit = null; + this.$unit = null; } }); diff --git a/src/style_manager/view/PropertySliderView.js b/src/style_manager/view/PropertySliderView.js index f84c0e993..040033b42 100644 --- a/src/style_manager/view/PropertySliderView.js +++ b/src/style_manager/view/PropertySliderView.js @@ -46,8 +46,9 @@ module.exports = Property.extend({ }, setValue(value) { - this.getSliderEl().value = parseFloat(value); - this.inputInst.setValue(value, { silent: 1 }); + const parsed = this.model.parseValue(value); + this.getSliderEl().value = parseFloat(parsed.value); + Property.prototype.setValue.apply(this, arguments); }, onRender() {