Skip to content

Commit

Permalink
Prevent setting status in case the model is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Jul 5, 2017
1 parent 1316e30 commit 23e96cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ <h1 class="bdg-title">The team</h1>
}
},{
id: 'clean-all',
run: function(editor, sender){
run: function(editor, sender) {
sender.set('active',false);
if(confirm('Are you sure to clean the canvas?')){
if(confirm('Are you sure to clean the canvas?')) {
var comps = editor.DomComponents.clear();
}
}
Expand Down Expand Up @@ -1299,7 +1299,6 @@ <h1 class="heading">Insert title here</h1>
editor.on('storage:store', function(e) {
console.log('STORE ', e);
})

editor.render();
</script>
</body>
Expand Down
3 changes: 2 additions & 1 deletion src/dom_components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ module.exports = () => {
}catch(err){}
}else if(d.html)
obj = d.html;
if (obj) {

if (obj && obj.length) {
this.clear();
this.getComponents().reset();
this.getComponents().add(obj);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/Sorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ module.exports = Backbone.View.extend({

if (src) {
var srcModel = this.getSourceModel();
srcModel && srcModel.set('status', 'freezed');
srcModel && srcModel.set && srcModel.set('status', 'freezed');
this.$document.on('mouseup', this.endMove);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ module.exports = Backbone.View.extend({
let comps = em.get('DomComponents').getComponents();
let tempModel = comps.add(dropContent);
dropModel = comps.remove(tempModel);
this.dropModel = dropModel;
this.dropModel = dropModel instanceof Array ? dropModel[0] : dropModel;
}
return dropModel;
}
Expand Down Expand Up @@ -759,7 +759,7 @@ module.exports = Backbone.View.extend({

if (src) {
var srcModel = this.getSourceModel();
if (srcModel) {
if (srcModel && srcModel.set) {
srcModel.set('status', '');
srcModel.set('status', 'selected');
}
Expand Down

0 comments on commit 23e96cd

Please sign in to comment.