Browse Source

Update correctly integer type when model is changed

pull/1518/head
Artur Arseniev 7 years ago
parent
commit
7f2c9bc215
  1. 1
      src/domain_abstract/ui/Input.js
  2. 1
      src/domain_abstract/ui/InputNumber.js
  3. 9
      src/style_manager/model/PropertyComposite.js
  4. 12
      src/style_manager/view/PropertyIntegerView.js
  5. 5
      src/style_manager/view/PropertySliderView.js

1
src/domain_abstract/ui/Input.js

@ -75,6 +75,7 @@ module.exports = Backbone.View.extend({
}, },
render() { render() {
this.inputEl = null;
const el = this.$el; const el = this.$el;
el.addClass(this.inputClass()); el.addClass(this.inputClass());
el.html(this.template()); el.html(this.template());

1
src/domain_abstract/ui/InputNumber.js

@ -269,6 +269,7 @@ module.exports = Input.extend({
render() { render() {
Input.prototype.render.call(this); Input.prototype.render.call(this);
this.unitEl = null;
const unit = this.getUnitEl(); const unit = this.getUnitEl();
unit && unit &&
this.$el this.$el

9
src/style_manager/model/PropertyComposite.js

@ -86,5 +86,14 @@ module.exports = Property.extend({
} }
return this.get('properties').getFullValue(); return this.get('properties').getFullValue();
},
/**
* Get property at some index
* @param {Number} index
* @return {Object}
*/
getPropertyAt(index) {
return this.get('properties').at(index);
} }
}); });

12
src/style_manager/view/PropertyIntegerView.js

@ -13,6 +13,7 @@ module.exports = PropertyView.extend({
const model = this.model; const model = this.model;
this.listenTo(model, 'change:unit', this.modelValueChanged); this.listenTo(model, 'change:unit', this.modelValueChanged);
this.listenTo(model, 'el:change', this.elementUpdated); this.listenTo(model, 'el:change', this.elementUpdated);
this.listenTo(model, 'change:units', this.render);
}, },
setValue(value) { setValue(value) {
@ -25,6 +26,11 @@ module.exports = PropertyView.extend({
const ppfx = this.ppfx; const ppfx = this.ppfx;
if (!this.input) { if (!this.input) {
console.log(
'onRender',
this.model.get('property'),
this.model.get('units')
);
const input = this.model.input; const input = this.model.input;
input.ppfx = ppfx; input.ppfx = ppfx;
input.render(); input.render();
@ -36,5 +42,11 @@ module.exports = PropertyView.extend({
this.input = this.$input.get(0); this.input = this.$input.get(0);
this.inputInst = input; this.inputInst = input;
} }
},
clearCached() {
PropertyView.prototype.clearCached.apply(this, arguments);
this.unit = null;
this.$unit = null;
} }
}); });

5
src/style_manager/view/PropertySliderView.js

@ -46,8 +46,9 @@ module.exports = Property.extend({
}, },
setValue(value) { setValue(value) {
this.getSliderEl().value = parseFloat(value); const parsed = this.model.parseValue(value);
this.inputInst.setValue(value, { silent: 1 }); this.getSliderEl().value = parseFloat(parsed.value);
Property.prototype.setValue.apply(this, arguments);
}, },
onRender() { onRender() {

Loading…
Cancel
Save