From 1fe03ddcee6a5e569f5a7b76a43f7c80ce070f6c Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 18 Feb 2018 15:38:01 +0100 Subject: [PATCH] Don't trigger `component:add` when components are just moved. Fixes #868 --- src/asset_manager/view/FileUploader.js | 20 -------------------- src/dom_components/view/ComponentsView.js | 11 +++++------ src/utils/Sorter.js | 1 + 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/asset_manager/view/FileUploader.js b/src/asset_manager/view/FileUploader.js index e58a0c3d32..2c70980944 100644 --- a/src/asset_manager/view/FileUploader.js +++ b/src/asset_manager/view/FileUploader.js @@ -289,26 +289,6 @@ module.exports = Backbone.View.extend( videoNode.src = fileURL */ - /* - // Show local video files, http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/ - var URL = window.URL || window.webkitURL - var file = this.files[0] - var type = file.type - var videoNode = document.createElement('video'); - var canPlay = videoNode.canPlayType(type) // can use also for 'audio' types - if (canPlay === '') canPlay = 'no' - var message = 'Can play type "' + type + '": ' + canPlay - var isError = canPlay === 'no' - displayMessage(message, isError) - - if (isError) { - return - } - - var fileURL = URL.createObjectURL(file) - videoNode.src = fileURL - */ - // If it's an image, try to find its size if (type === 'image') { const data = { diff --git a/src/dom_components/view/ComponentsView.js b/src/dom_components/view/ComponentsView.js index 647952c03f..45fb2f9dae 100644 --- a/src/dom_components/view/ComponentsView.js +++ b/src/dom_components/view/ComponentsView.js @@ -11,18 +11,17 @@ module.exports = Backbone.View.extend({ /** * Add to collection - * @param {Object} Model - * - * @return void + * @param {Model} model + * @param {Collection} coll + * @param {Object} opts * @private * */ - addTo(model) { + addTo(model, coll = {}, opts = {}) { const em = this.config.em; const i = this.collection.indexOf(model); this.addToCollection(model, null, i); - if (em && !model.opt.temporary) { - em.trigger('add:component', model); // @deprecated + if (em && !opts.temporary) { em.trigger('component:add', model); } }, diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index 378b7719f0..90318287d0 100644 --- a/src/utils/Sorter.js +++ b/src/utils/Sorter.js @@ -969,6 +969,7 @@ module.exports = Backbone.View.extend({ if (!dropContent) { // Putting `avoidStore` here will make the UndoManager behave wrong + opts.temporary = 1; modelTemp = targetCollection.add({}, { ...opts }); if (model) {