From 8b275b206be9a10dc3dfe1333bd0854083e4f464 Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Fri, 5 Apr 2019 09:34:55 -0700 Subject: [PATCH] Remove selection fix (#2348) * add a function to change selection of deleted item in remove action, and update flexlayouts * resize when item is deleted * fix for resize handles not showing after object is dropped * fix isAlias logic for folder views * remove uneccesary console log * move selection logic to flexible layouts * only update inspector views if selection has changed to a new context * force a digest in the plot options controller once the series are added * conditionally show snapshot button only if notebook is installed --- .../components/flexibleLayout.vue | 30 ++++++++++++------- .../components/resizeHandle.vue | 2 ++ src/plugins/flexibleLayout/toolbarProvider.js | 6 ++-- .../components/composition-loader.js | 3 +- .../src/inspector/PlotOptionsController.js | 7 +++-- src/ui/inspector/InspectorViews.vue | 13 ++++++++ src/ui/layout/BrowseBar.vue | 12 ++++++-- 7 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/plugins/flexibleLayout/components/flexibleLayout.vue b/src/plugins/flexibleLayout/components/flexibleLayout.vue index 974c37950a..934ff0b63c 100644 --- a/src/plugins/flexibleLayout/components/flexibleLayout.vue +++ b/src/plugins/flexibleLayout/components/flexibleLayout.vue @@ -414,6 +414,7 @@ import Container from '../utils/container'; import Frame from '../utils/frame'; import ResizeHandle from './resizeHandle.vue'; import DropHint from './dropHint.vue'; +import RemoveAction from '../../remove/RemoveAction.js'; const MIN_CONTAINER_SIZE = 5; @@ -505,7 +506,7 @@ export default { remove associated domainObjects from composition */ container.frames.forEach(f => { - this.composition.remove({identifier: f.domainObjectIdentifier}); + this.removeFromComposition(f.domainObjectIdentifier); }); this.containers.splice(containerIndex, 1); @@ -520,6 +521,7 @@ export default { } sizeToFill(this.containers); + this.setSelectionToParent(); this.persist(); }, moveFrame(toContainerIndex, toFrameIndex, frameId, fromContainerIndex) { @@ -553,20 +555,24 @@ export default { deleteFrame(frameId) { let container = this.containers .filter(c => c.frames.some(f => f.id === frameId))[0]; - let containerIndex = this.containers.indexOf(container); let frame = container .frames .filter((f => f.id === frameId))[0]; - let frameIndex = container.frames.indexOf(frame); - /* - remove associated domainObject from composition - */ - this.composition.remove({identifier: frame.domainObjectIdentifier}); - - container.frames.splice(frameIndex, 1); - sizeToFill(container.frames); - this.persist(containerIndex); + this.removeFromComposition(frame.domainObjectIdentifier) + .then(() => { + sizeToFill(container.frames) + this.setSelectionToParent(); + }); + }, + removeFromComposition(identifier) { + return this.openmct.objects.get(identifier).then((childDomainObject) => { + this.RemoveAction.removeFromComposition(this.domainObject, childDomainObject); + }); + }, + setSelectionToParent() { + let currentSelection = this.openmct.selection.selected; + this.openmct.selection.select(currentSelection.slice(1)); }, allowContainerDrop(event, index) { if (!event.dataTransfer.types.includes('containerid')) { @@ -657,6 +663,8 @@ export default { this.composition.on('remove', this.removeChildObject); this.composition.on('add', this.addFrame); + this.RemoveAction = new RemoveAction(this.openmct); + this.unobserve = this.openmct.objects.observe(this.domainObject, '*', this.updateDomainObject); }, beforeDestroy() { diff --git a/src/plugins/flexibleLayout/components/resizeHandle.vue b/src/plugins/flexibleLayout/components/resizeHandle.vue index 88ac094899..d72f0a7f0a 100644 --- a/src/plugins/flexibleLayout/components/resizeHandle.vue +++ b/src/plugins/flexibleLayout/components/resizeHandle.vue @@ -79,10 +79,12 @@ export default { mounted() { document.addEventListener('dragstart', this.setDragging); document.addEventListener('dragend', this.unsetDragging); + document.addEventListener('drop', this.unsetDragging); }, destroyed() { document.removeEventListener('dragstart', this.setDragging); document.removeEventListener('dragend', this.unsetDragging); + document.removeEventListener('drop', this.unsetDragging); } } diff --git a/src/plugins/flexibleLayout/toolbarProvider.js b/src/plugins/flexibleLayout/toolbarProvider.js index 245c926421..588a2fd179 100644 --- a/src/plugins/flexibleLayout/toolbarProvider.js +++ b/src/plugins/flexibleLayout/toolbarProvider.js @@ -77,11 +77,11 @@ function ToolbarProvider(openmct) { .containers; let container = containers .filter(c => c.frames.some(f => f.id === frameId))[0]; - let frame = container + let containerIndex = containers.indexOf(container); + let frame = container && container .frames .filter((f => f.id === frameId))[0]; - let containerIndex = containers.indexOf(container); - let frameIndex = container.frames.indexOf(frame); + let frameIndex = container && container.frames.indexOf(frame); deleteFrame = { control: "button", diff --git a/src/plugins/folderView/components/composition-loader.js b/src/plugins/folderView/components/composition-loader.js index 5d8de5349f..c885673e6e 100644 --- a/src/plugins/folderView/components/composition-loader.js +++ b/src/plugins/folderView/components/composition-loader.js @@ -14,6 +14,7 @@ export default { }, mounted() { this.composition = this.openmct.composition.get(this.domainObject); + this.keystring = this.openmct.objects.makeKeyString(this.domainObject.identifier); if (!this.composition) { return; } @@ -34,7 +35,7 @@ export default { this.items.push({ model: child, type: type.definition, - isAlias: this.domainObject.identifier.key !== child.location, + isAlias: this.keystring !== child.location, objectPath: [child].concat(this.openmct.router.path), objectKeyString: this.openmct.objects.makeKeyString(child.identifier) }); diff --git a/src/plugins/plot/src/inspector/PlotOptionsController.js b/src/plugins/plot/src/inspector/PlotOptionsController.js index c54896df5c..5961dfe117 100644 --- a/src/plugins/plot/src/inspector/PlotOptionsController.js +++ b/src/plugins/plot/src/inspector/PlotOptionsController.js @@ -70,12 +70,15 @@ define([ this.listenTo(this.$scope, '$destroy', this.destroy, this); this.listenTo(config.series, 'add', this.addSeries, this); this.listenTo(config.series, 'remove', this.resetAllSeries, this); + config.series.forEach(this.addSeries, this); }; PlotOptionsController.prototype.addSeries = function (series, index) { - this.$scope.plotSeries[index] = series; - series.locateOldObject(this.$scope.domainObject); + this.$timeout(function () { + this.$scope.plotSeries[index] = series; + series.locateOldObject(this.$scope.domainObject); + }.bind(this)); }; PlotOptionsController.prototype.resetAllSeries = function (series, index) { diff --git a/src/ui/inspector/InspectorViews.vue b/src/ui/inspector/InspectorViews.vue index bd51c91c6f..5147c141ab 100644 --- a/src/ui/inspector/InspectorViews.vue +++ b/src/ui/inspector/InspectorViews.vue @@ -7,6 +7,8 @@