Browse Source

Add setValue to the property model

pull/487/head
Artur Arseniev 8 years ago
parent
commit
ecf22d66c9
  1. 21
      src/style_manager/model/Property.js

21
src/style_manager/model/Property.js

@ -14,6 +14,7 @@ module.exports = require('backbone').Model.extend({
fixedValues: ['initial', 'inherit'], fixedValues: ['initial', 'inherit'],
}, },
initialize(opt) { initialize(opt) {
var o = opt || {}; var o = opt || {};
var name = this.get('name'); var name = this.get('name');
@ -27,6 +28,24 @@ module.exports = require('backbone').Model.extend({
init && init(); init && init();
}, },
/**
* Update value
* @param {any} value
* @param {Boolen} [complete=true] Indicates if it's a final state
* @param {Object} [opts={}] Options
*/
setValue(value, complete = 1, opts = {}) {
this.set('value', value, { ...opts, avoidStore: 1});
// It's important to set an empty value, otherwise the
// UndoManager won't see the change
if (complete) {
this.set('value', '', opts);
this.set('value', value, opts);
}
},
/** /**
* Parse a raw value, generally fetched from the target, for this property * Parse a raw value, generally fetched from the target, for this property
* @param {string} value * @param {string} value
@ -51,6 +70,7 @@ module.exports = require('backbone').Model.extend({
return String.prototype.substring.apply(valueStr, args); return String.prototype.substring.apply(valueStr, args);
}, },
/** /**
* Get the default value * Get the default value
* @return {string} * @return {string}
@ -60,6 +80,7 @@ module.exports = require('backbone').Model.extend({
return this.get('defaults'); return this.get('defaults');
}, },
/** /**
* Get a complete value of the property. * Get a complete value of the property.
* This probably will replace the getValue when all * This probably will replace the getValue when all

Loading…
Cancel
Save