Browse Source

Fix storage loading

pull/187/head
Artur Arseniev 9 years ago
parent
commit
63e0fd072c
  1. 12
      index.html
  2. 4
      src/dom_components/index.js
  3. 27
      src/editor/model/Editor.js
  4. 2
      src/editor/view/EditorView.js

12
index.html

@ -806,7 +806,7 @@
clearOnRender: 0, clearOnRender: 0,
storageManager:{ storageManager:{
autoload: 0, autoload: 1,
storeComponents: 1, storeComponents: 1,
storeStyles: 1, storeStyles: 1,
}, },
@ -1173,6 +1173,16 @@
}, },
}); });
/*
// Store and load events
editor.on('storage:load', function(e) {
console.log('LOAD ', e);
})
editor.on('storage:store', function(e) {
console.log('STORE ', e);
})
*/
editor.render(); editor.render();
</script> </script>
</body> </body>

4
src/dom_components/index.js

@ -216,10 +216,10 @@ module.exports = () => {
}catch(err){} }catch(err){}
}else if(d.html) }else if(d.html)
obj = d.html; obj = d.html;
if (obj) { if (obj) {
this.clear(); this.clear();
this.getComponents().reset(obj); this.getComponents().reset();
this.getComponents().add(obj);
} }
return obj; return obj;

27
src/editor/model/Editor.js

@ -161,18 +161,21 @@ module.exports = Backbone.Model.extend({
* @private * @private
* */ * */
componentsUpdated(model, val, opt) { componentsUpdated(model, val, opt) {
var count = this.get('changesCount') + 1; timedInterval && clearInterval(timedInterval);
var avoidStore = opt ? opt.avoidStore : 0; timedInterval = setTimeout(() => {
var stm = this.get('StorageManager'); var count = this.get('changesCount') + 1;
this.set('changesCount', count); var avoidStore = opt ? opt.avoidStore : 0;
var stm = this.get('StorageManager');
if (!stm.isAutosave() || count < stm.getStepsBeforeSave()) { this.set('changesCount', count);
return;
} if (!stm.isAutosave() || count < stm.getStepsBeforeSave()) {
return;
if (!avoidStore) { }
this.store();
} if (!avoidStore) {
this.store();
}
}, 0);
}, },
/** /**

2
src/editor/view/EditorView.js

@ -24,8 +24,8 @@ module.exports = Backbone.View.extend({
dComps.clear(); dComps.clear();
} }
dComps.getComponents().reset(config.components); dComps.getComponents().reset(config.components);
um.clear();
model.loadOnStart(); model.loadOnStart();
um.clear();
// This will init loaded components // This will init loaded components
dComps.onLoad(); dComps.onLoad();
} }

Loading…
Cancel
Save