diff --git a/src/plugins/flexibleLayout/components/flexibleLayout.vue b/src/plugins/flexibleLayout/components/flexibleLayout.vue index 934ff0b63c..843a1b871e 100644 --- a/src/plugins/flexibleLayout/components/flexibleLayout.vue +++ b/src/plugins/flexibleLayout/components/flexibleLayout.vue @@ -571,8 +571,7 @@ export default { }); }, setSelectionToParent() { - let currentSelection = this.openmct.selection.selected; - this.openmct.selection.select(currentSelection.slice(1)); + this.$el.click(); }, allowContainerDrop(event, index) { if (!event.dataTransfer.types.includes('containerid')) { diff --git a/src/plugins/flexibleLayout/components/frame.vue b/src/plugins/flexibleLayout/components/frame.vue index 7751f8ebbd..4c5f401b76 100644 --- a/src/plugins/flexibleLayout/components/frame.vue +++ b/src/plugins/flexibleLayout/components/frame.vue @@ -79,12 +79,14 @@ export default { }, setSelection() { this.$nextTick(function () { - let childContext = this.$refs.objectFrame.getSelectionContext(); - childContext.item = this.domainObject; - childContext.type = 'frame'; - childContext.frameId = this.frame.id; - this.unsubscribeSelection = this.openmct.selection.selectable( - this.$refs.frame, childContext, false); + if (this.$refs && this.$refs.objectFrame) { + let childContext = this.$refs.objectFrame.getSelectionContext(); + childContext.item = this.domainObject; + childContext.type = 'frame'; + childContext.frameId = this.frame.id; + this.unsubscribeSelection = this.openmct.selection.selectable( + this.$refs.frame, childContext, false); + } }); }, initDrag(event) { diff --git a/src/plugins/flexibleLayout/toolbarProvider.js b/src/plugins/flexibleLayout/toolbarProvider.js index 0bd66f8174..bf7d941125 100644 --- a/src/plugins/flexibleLayout/toolbarProvider.js +++ b/src/plugins/flexibleLayout/toolbarProvider.js @@ -46,9 +46,7 @@ function ToolbarProvider(openmct) { separator; separator = { - control: "separator", - domainObject: primary.context.item, - key: "separator" + control: "separator" }; toggleContainer = { @@ -203,7 +201,7 @@ function ToolbarProvider(openmct) { let toolbar = [ toggleContainer, addContainer, - toggleFrame ? separator: undefined, + toggleFrame ? separator : undefined, toggleFrame, deleteFrame || deleteContainer ? separator : undefined, deleteFrame, diff --git a/src/ui/toolbar/Toolbar.vue b/src/ui/toolbar/Toolbar.vue index 69d8d6a240..a8f6866f9a 100644 --- a/src/ui/toolbar/Toolbar.vue +++ b/src/ui/toolbar/Toolbar.vue @@ -115,7 +115,7 @@ let value = undefined; let applicableSelectedItems = toolbarItem.applicableSelectedItems; - if (!applicableSelectedItems) { + if (!applicableSelectedItems && !toolbarItem.property) { return value; } @@ -123,9 +123,14 @@ value = this.getFormValue(domainObject, toolbarItem); } else { let values = []; - applicableSelectedItems.forEach(selectionPath => { - values.push(_.get(domainObject, this.getItemProperty(toolbarItem, selectionPath))); - }); + + if (applicableSelectedItems) { + applicableSelectedItems.forEach(selectionPath => { + values.push(this.getPropertyValue(domainObject, toolbarItem, selectionPath)); + }); + } else { + values.push(this.getPropertyValue(domainObject, toolbarItem)); + } // If all values are the same, use it, otherwise mark the item as non-specific. if (values.every(value => value === values[0])) { @@ -138,14 +143,29 @@ return value; }, + getPropertyValue(domainObject, toolbarItem, selectionPath, formKey) { + let property = this.getItemProperty(toolbarItem, selectionPath); + + if (formKey) { + property = property + "." + formKey; + } + + return _.get(domainObject, property); + }, getFormValue(domainObject, toolbarItem) { let value = {}; let values = {}; + toolbarItem.formKeys.map(key => { values[key] = []; - toolbarItem.applicableSelectedItems.forEach(selectionPath => { - values[key].push(_.get(domainObject, this.getItemProperty(toolbarItem, selectionPath) + "." + key)); - }); + + if (toolbarItem.applicableSelectedItems) { + toolbarItem.applicableSelectedItems.forEach(selectionPath => { + values[key].push(this.getPropertyValue(domainObject, toolbarItem, selectionPath, key)); + }); + } else { + values[key].push(this.getPropertyValue(domainObject, toolbarItem, undefined, key)); + } }); for (const key in values) { @@ -192,19 +212,35 @@ this.structure.map(s => { if (s.formKeys) { s.formKeys.forEach(key => { - item.applicableSelectedItems.forEach(selectionPath => { - this.openmct.objects.mutate(item.domainObject, - this.getItemProperty(item, selectionPath) + "." + key, value[key]); - }); + if (item.applicableSelectedItems) { + item.applicableSelectedItems.forEach(selectionPath => { + this.mutateObject(item, value[key], selectionPath, key); + }); + } else { + this.mutateObject(item, value[key], undefined, key); + } }); } }); } else { - item.applicableSelectedItems.forEach(selectionPath => { - this.openmct.objects.mutate(item.domainObject, this.getItemProperty(item, selectionPath), value); - }); + if (item.applicableSelectedItems) { + item.applicableSelectedItems.forEach(selectionPath => { + this.mutateObject(item, value, selectionPath); + }); + } else { + this.mutateObject(item, value); + } } }, + mutateObject(item, value, selectionPath, formKey) { + let property = this.getItemProperty(item, selectionPath); + + if (formKey) { + property = property + "." + formKey; + } + + this.openmct.objects.mutate(item.domainObject, property, value); + }, triggerMethod(item, event) { if (item.method) { item.method({...event});