mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +00:00
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
This commit is contained in:
@ -414,6 +414,7 @@ import Container from '../utils/container';
|
|||||||
import Frame from '../utils/frame';
|
import Frame from '../utils/frame';
|
||||||
import ResizeHandle from './resizeHandle.vue';
|
import ResizeHandle from './resizeHandle.vue';
|
||||||
import DropHint from './dropHint.vue';
|
import DropHint from './dropHint.vue';
|
||||||
|
import RemoveAction from '../../remove/RemoveAction.js';
|
||||||
|
|
||||||
const MIN_CONTAINER_SIZE = 5;
|
const MIN_CONTAINER_SIZE = 5;
|
||||||
|
|
||||||
@ -505,7 +506,7 @@ export default {
|
|||||||
remove associated domainObjects from composition
|
remove associated domainObjects from composition
|
||||||
*/
|
*/
|
||||||
container.frames.forEach(f => {
|
container.frames.forEach(f => {
|
||||||
this.composition.remove({identifier: f.domainObjectIdentifier});
|
this.removeFromComposition(f.domainObjectIdentifier);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.containers.splice(containerIndex, 1);
|
this.containers.splice(containerIndex, 1);
|
||||||
@ -520,6 +521,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sizeToFill(this.containers);
|
sizeToFill(this.containers);
|
||||||
|
this.setSelectionToParent();
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
moveFrame(toContainerIndex, toFrameIndex, frameId, fromContainerIndex) {
|
moveFrame(toContainerIndex, toFrameIndex, frameId, fromContainerIndex) {
|
||||||
@ -553,20 +555,24 @@ export default {
|
|||||||
deleteFrame(frameId) {
|
deleteFrame(frameId) {
|
||||||
let container = this.containers
|
let container = this.containers
|
||||||
.filter(c => c.frames.some(f => f.id === frameId))[0];
|
.filter(c => c.frames.some(f => f.id === frameId))[0];
|
||||||
let containerIndex = this.containers.indexOf(container);
|
|
||||||
let frame = container
|
let frame = container
|
||||||
.frames
|
.frames
|
||||||
.filter((f => f.id === frameId))[0];
|
.filter((f => f.id === frameId))[0];
|
||||||
let frameIndex = container.frames.indexOf(frame);
|
|
||||||
|
|
||||||
/*
|
this.removeFromComposition(frame.domainObjectIdentifier)
|
||||||
remove associated domainObject from composition
|
.then(() => {
|
||||||
*/
|
sizeToFill(container.frames)
|
||||||
this.composition.remove({identifier: frame.domainObjectIdentifier});
|
this.setSelectionToParent();
|
||||||
|
});
|
||||||
container.frames.splice(frameIndex, 1);
|
},
|
||||||
sizeToFill(container.frames);
|
removeFromComposition(identifier) {
|
||||||
this.persist(containerIndex);
|
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) {
|
allowContainerDrop(event, index) {
|
||||||
if (!event.dataTransfer.types.includes('containerid')) {
|
if (!event.dataTransfer.types.includes('containerid')) {
|
||||||
@ -657,6 +663,8 @@ export default {
|
|||||||
this.composition.on('remove', this.removeChildObject);
|
this.composition.on('remove', this.removeChildObject);
|
||||||
this.composition.on('add', this.addFrame);
|
this.composition.on('add', this.addFrame);
|
||||||
|
|
||||||
|
this.RemoveAction = new RemoveAction(this.openmct);
|
||||||
|
|
||||||
this.unobserve = this.openmct.objects.observe(this.domainObject, '*', this.updateDomainObject);
|
this.unobserve = this.openmct.objects.observe(this.domainObject, '*', this.updateDomainObject);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
@ -79,10 +79,12 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
document.addEventListener('dragstart', this.setDragging);
|
document.addEventListener('dragstart', this.setDragging);
|
||||||
document.addEventListener('dragend', this.unsetDragging);
|
document.addEventListener('dragend', this.unsetDragging);
|
||||||
|
document.addEventListener('drop', this.unsetDragging);
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
document.removeEventListener('dragstart', this.setDragging);
|
document.removeEventListener('dragstart', this.setDragging);
|
||||||
document.removeEventListener('dragend', this.unsetDragging);
|
document.removeEventListener('dragend', this.unsetDragging);
|
||||||
|
document.removeEventListener('drop', this.unsetDragging);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -77,11 +77,11 @@ function ToolbarProvider(openmct) {
|
|||||||
.containers;
|
.containers;
|
||||||
let container = containers
|
let container = containers
|
||||||
.filter(c => c.frames.some(f => f.id === frameId))[0];
|
.filter(c => c.frames.some(f => f.id === frameId))[0];
|
||||||
let frame = container
|
let containerIndex = containers.indexOf(container);
|
||||||
|
let frame = container && container
|
||||||
.frames
|
.frames
|
||||||
.filter((f => f.id === frameId))[0];
|
.filter((f => f.id === frameId))[0];
|
||||||
let containerIndex = containers.indexOf(container);
|
let frameIndex = container && container.frames.indexOf(frame);
|
||||||
let frameIndex = container.frames.indexOf(frame);
|
|
||||||
|
|
||||||
deleteFrame = {
|
deleteFrame = {
|
||||||
control: "button",
|
control: "button",
|
||||||
|
@ -14,6 +14,7 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.composition = this.openmct.composition.get(this.domainObject);
|
this.composition = this.openmct.composition.get(this.domainObject);
|
||||||
|
this.keystring = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||||
if (!this.composition) {
|
if (!this.composition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -34,7 +35,7 @@ export default {
|
|||||||
this.items.push({
|
this.items.push({
|
||||||
model: child,
|
model: child,
|
||||||
type: type.definition,
|
type: type.definition,
|
||||||
isAlias: this.domainObject.identifier.key !== child.location,
|
isAlias: this.keystring !== child.location,
|
||||||
objectPath: [child].concat(this.openmct.router.path),
|
objectPath: [child].concat(this.openmct.router.path),
|
||||||
objectKeyString: this.openmct.objects.makeKeyString(child.identifier)
|
objectKeyString: this.openmct.objects.makeKeyString(child.identifier)
|
||||||
});
|
});
|
||||||
|
@ -70,12 +70,15 @@ define([
|
|||||||
this.listenTo(this.$scope, '$destroy', this.destroy, this);
|
this.listenTo(this.$scope, '$destroy', this.destroy, this);
|
||||||
this.listenTo(config.series, 'add', this.addSeries, this);
|
this.listenTo(config.series, 'add', this.addSeries, this);
|
||||||
this.listenTo(config.series, 'remove', this.resetAllSeries, this);
|
this.listenTo(config.series, 'remove', this.resetAllSeries, this);
|
||||||
|
|
||||||
config.series.forEach(this.addSeries, this);
|
config.series.forEach(this.addSeries, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlotOptionsController.prototype.addSeries = function (series, index) {
|
PlotOptionsController.prototype.addSeries = function (series, index) {
|
||||||
|
this.$timeout(function () {
|
||||||
this.$scope.plotSeries[index] = series;
|
this.$scope.plotSeries[index] = series;
|
||||||
series.locateOldObject(this.$scope.domainObject);
|
series.locateOldObject(this.$scope.domainObject);
|
||||||
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
PlotOptionsController.prototype.resetAllSeries = function (series, index) {
|
PlotOptionsController.prototype.resetAllSeries = function (series, index) {
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct'],
|
inject: ['openmct'],
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -16,9 +18,20 @@
|
|||||||
destroyed() {
|
destroyed() {
|
||||||
this.openmct.selection.off('change', this.updateSelection);
|
this.openmct.selection.off('change', this.updateSelection);
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
selection: []
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateSelection() {
|
updateSelection() {
|
||||||
let selection = this.openmct.selection.get();
|
let selection = this.openmct.selection.get();
|
||||||
|
|
||||||
|
if (_.isEqual(this.selection[0], selection[0])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.selection = selection;
|
||||||
|
|
||||||
if (this.selectedViews) {
|
if (this.selectedViews) {
|
||||||
this.selectedViews.forEach(selectedView => {
|
this.selectedViews.forEach(selectedView => {
|
||||||
selectedView.destroy();
|
selectedView.destroy();
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- Action buttons -->
|
<!-- Action buttons -->
|
||||||
<div class="l-browse-bar__actions">
|
<div class="l-browse-bar__actions">
|
||||||
<button class="l-browse-bar__actions__notebook-entry c-button icon-notebook"
|
<button v-if="notebookEnabled"
|
||||||
|
class="l-browse-bar__actions__notebook-entry c-button icon-notebook"
|
||||||
title="New Notebook entry"
|
title="New Notebook entry"
|
||||||
@click="snapshot()">
|
@click="snapshot()">
|
||||||
</button>
|
</button>
|
||||||
@ -167,7 +168,8 @@ const PLACEHOLDER_OBJECT = {};
|
|||||||
showSaveMenu: false,
|
showSaveMenu: false,
|
||||||
domainObject: PLACEHOLDER_OBJECT,
|
domainObject: PLACEHOLDER_OBJECT,
|
||||||
viewKey: undefined,
|
viewKey: undefined,
|
||||||
isEditing: this.openmct.editor.isEditing()
|
isEditing: this.openmct.editor.isEditing(),
|
||||||
|
notebookEnabled: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -213,7 +215,11 @@ const PLACEHOLDER_OBJECT = {};
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
|
|
||||||
|
if (this.openmct.types.get('notebook')) {
|
||||||
this.notebookSnapshot = new NotebookSnapshot(this.openmct);
|
this.notebookSnapshot = new NotebookSnapshot(this.openmct);
|
||||||
|
this.notebookEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('click', this.closeViewAndSaveMenu);
|
document.addEventListener('click', this.closeViewAndSaveMenu);
|
||||||
window.addEventListener('beforeunload', this.promptUserbeforeNavigatingAway);
|
window.addEventListener('beforeunload', this.promptUserbeforeNavigatingAway);
|
||||||
|
Reference in New Issue
Block a user