From 856dabbedf51d77f04c6b3f8edb4d1f31d63f82a Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 3 Jun 2018 01:09:29 +0200 Subject: [PATCH] Remove selectedComponent references --- src/editor/model/Editor.js | 3 --- src/selector_manager/view/ClassTagView.js | 2 +- src/style_manager/view/PropertyView.js | 2 +- test/specs/selector_manager/e2e/ClassManager.js | 6 +++--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index d8e438311..cdd0713ec 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -41,7 +41,6 @@ module.exports = Backbone.Model.extend({ selected: new Collection(), clipboard: null, designerMode: false, - selectedComponent: null, componentHovered: null, previousModel: null, changesCount: 0, @@ -227,10 +226,8 @@ module.exports = Backbone.Model.extend({ setSelected(el, opts = {}) { const model = getModel(el, $); if (model && !model.get('selectable')) return; - opts.forceChange && this.set('selectedComponent', ''); const selected = this.get('selected'); selected.remove(selected.filter(sel => sel !== model)); - // this.set('selectedComponent', model, opts); this.addSelected(model, opts); }, diff --git a/src/selector_manager/view/ClassTagView.js b/src/selector_manager/view/ClassTagView.js index 119c936de..bb00214c1 100644 --- a/src/selector_manager/view/ClassTagView.js +++ b/src/selector_manager/view/ClassTagView.js @@ -94,7 +94,7 @@ module.exports = require('backbone').View.extend({ const model = this.model; const coll = this.coll; const el = this.el; - const sel = em && em.get('selectedComponent'); + const sel = em && em.getSelected(); sel && sel.get & sel.get('classes').remove(model); coll && coll.remove(model); setTimeout(() => this.remove(), 0); diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index 9e79395ba..ed2f4c34d 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -413,7 +413,7 @@ module.exports = Backbone.View.extend({ */ isComponentStylable() { const em = this.em; - const component = em && em.get('selectedComponent'); + const component = em && em.getSelected(); if (!component) { return true; diff --git a/test/specs/selector_manager/e2e/ClassManager.js b/test/specs/selector_manager/e2e/ClassManager.js index 01a213675..99fcea47d 100644 --- a/test/specs/selector_manager/e2e/ClassManager.js +++ b/test/specs/selector_manager/e2e/ClassManager.js @@ -83,7 +83,7 @@ module.exports = { test('Can assign only one time the same class on selected component and the class viewer', () => { var model = components.add({}); - gjs.editor.set('selectedComponent', model); + gjs.editor.setSelected(model); tagEl.addNewTag('test'); tagEl.addNewTag('test'); expect(model.get('classes').length).toEqual(1); @@ -99,7 +99,7 @@ module.exports = { test('Removing from container removes also from selected component', () => { var model = components.add({}); - gjs.editor.set('selectedComponent', model); + gjs.editor.setSelected(model); tagEl.addNewTag('test'); tagEl .getClasses() @@ -111,7 +111,7 @@ module.exports = { test('Trigger correctly event on target with new class add', () => { var spy = sinon.spy(); var model = components.add({}); - gjs.editor.set('selectedComponent', model); + gjs.editor.setSelected(model); tagEl.addNewTag('test'); gjs.editor.on('component:update:classes', spy); tagEl.addNewTag('test');