|
|
@ -135,26 +135,28 @@ module.exports = Backbone.Model.extend({ |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
listenRule(model) { |
|
|
listenRule(model) { |
|
|
this.stopListening(model, 'change:style', this.ruleUpdated); |
|
|
this.stopListening(model, 'change:style', this.componentsUpdated); |
|
|
this.listenTo(model, 'change:style', this.ruleUpdated); |
|
|
this.listenTo(model, 'change:style', this.componentsUpdated); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Triggered when rule is updated |
|
|
* Triggered when something in components is changed |
|
|
* @param {Object} model |
|
|
* @param {Object} model |
|
|
* @param {Mixed} val Value |
|
|
* @param {Mixed} val Value |
|
|
* @param {Object} opt Options |
|
|
* @param {Object} opt Options |
|
|
* @private |
|
|
* @private |
|
|
* */ |
|
|
* */ |
|
|
ruleUpdated(model, val, opt) { |
|
|
componentsUpdated(model, val, opt) { |
|
|
var count = this.get('changesCount') + 1, |
|
|
var count = this.get('changesCount') + 1; |
|
|
avSt = opt ? opt.avoidStore : 0; |
|
|
var avoidStore = opt ? opt.avoidStore : 0; |
|
|
this.set('changesCount', count); |
|
|
|
|
|
var stm = this.get('StorageManager'); |
|
|
var stm = this.get('StorageManager'); |
|
|
if(stm.isAutosave() && count < stm.getStepsBeforeSave()) |
|
|
this.set('changesCount', count); |
|
|
|
|
|
|
|
|
|
|
|
if (!stm.isAutosave() || count < stm.getStepsBeforeSave()) { |
|
|
return; |
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(!avSt){ |
|
|
if (!avoidStore) { |
|
|
this.store(); |
|
|
this.store(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -218,27 +220,6 @@ module.exports = Backbone.Model.extend({ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Triggered when components are updated |
|
|
|
|
|
* @param {Object} model |
|
|
|
|
|
* @param {Mixed} val Value |
|
|
|
|
|
* @param {Object} opt Options |
|
|
|
|
|
* @private |
|
|
|
|
|
* */ |
|
|
|
|
|
componentsUpdated(model, val, opt) { |
|
|
|
|
|
var updatedCount = this.get('changesCount') + 1, |
|
|
|
|
|
avSt = opt ? opt.avoidStore : 0; |
|
|
|
|
|
this.set('changesCount', updatedCount); |
|
|
|
|
|
var stm = this.get('StorageManager'); |
|
|
|
|
|
if(stm.isAutosave() && updatedCount < stm.getStepsBeforeSave()){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!avSt){ |
|
|
|
|
|
this.store(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Callback on component selection |
|
|
* Callback on component selection |
|
|
* @param {Object} Model |
|
|
* @param {Object} Model |
|
|
|