Skip to content

Commit

Permalink
Add setValue to the property model
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Oct 31, 2017
1 parent 1279ad7 commit ecf22d6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/style_manager/model/Property.js
Expand Up @@ -14,6 +14,7 @@ module.exports = require('backbone').Model.extend({
fixedValues: ['initial', 'inherit'],
},


initialize(opt) {
var o = opt || {};
var name = this.get('name');
Expand All @@ -27,6 +28,24 @@ module.exports = require('backbone').Model.extend({
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
* @param {string} value
Expand All @@ -51,6 +70,7 @@ module.exports = require('backbone').Model.extend({
return String.prototype.substring.apply(valueStr, args);
},


/**
* Get the default value
* @return {string}
Expand All @@ -60,6 +80,7 @@ module.exports = require('backbone').Model.extend({
return this.get('defaults');
},


/**
* Get a complete value of the property.
* This probably will replace the getValue when all
Expand Down

0 comments on commit ecf22d6

Please sign in to comment.