Merge pull request #2360 from nasa/flex-layout-selection

Toolbar issues in Flexible layout
This commit is contained in:
Charles Hacskaylo 2019-04-06 13:57:21 -07:00 committed by GitHub
commit d93e7bfd1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 26 deletions

View File

@ -571,8 +571,7 @@ export default {
}); });
}, },
setSelectionToParent() { setSelectionToParent() {
let currentSelection = this.openmct.selection.selected; this.$el.click();
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')) {

View File

@ -79,12 +79,14 @@ export default {
}, },
setSelection() { setSelection() {
this.$nextTick(function () { this.$nextTick(function () {
if (this.$refs && this.$refs.objectFrame) {
let childContext = this.$refs.objectFrame.getSelectionContext(); let childContext = this.$refs.objectFrame.getSelectionContext();
childContext.item = this.domainObject; childContext.item = this.domainObject;
childContext.type = 'frame'; childContext.type = 'frame';
childContext.frameId = this.frame.id; childContext.frameId = this.frame.id;
this.unsubscribeSelection = this.openmct.selection.selectable( this.unsubscribeSelection = this.openmct.selection.selectable(
this.$refs.frame, childContext, false); this.$refs.frame, childContext, false);
}
}); });
}, },
initDrag(event) { initDrag(event) {

View File

@ -46,9 +46,7 @@ function ToolbarProvider(openmct) {
separator; separator;
separator = { separator = {
control: "separator", control: "separator"
domainObject: primary.context.item,
key: "separator"
}; };
toggleContainer = { toggleContainer = {
@ -203,7 +201,7 @@ function ToolbarProvider(openmct) {
let toolbar = [ let toolbar = [
toggleContainer, toggleContainer,
addContainer, addContainer,
toggleFrame ? separator: undefined, toggleFrame ? separator : undefined,
toggleFrame, toggleFrame,
deleteFrame || deleteContainer ? separator : undefined, deleteFrame || deleteContainer ? separator : undefined,
deleteFrame, deleteFrame,

View File

@ -115,7 +115,7 @@
let value = undefined; let value = undefined;
let applicableSelectedItems = toolbarItem.applicableSelectedItems; let applicableSelectedItems = toolbarItem.applicableSelectedItems;
if (!applicableSelectedItems) { if (!applicableSelectedItems && !toolbarItem.property) {
return value; return value;
} }
@ -123,9 +123,14 @@
value = this.getFormValue(domainObject, toolbarItem); value = this.getFormValue(domainObject, toolbarItem);
} else { } else {
let values = []; let values = [];
if (applicableSelectedItems) {
applicableSelectedItems.forEach(selectionPath => { applicableSelectedItems.forEach(selectionPath => {
values.push(_.get(domainObject, this.getItemProperty(toolbarItem, 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 all values are the same, use it, otherwise mark the item as non-specific.
if (values.every(value => value === values[0])) { if (values.every(value => value === values[0])) {
@ -138,14 +143,29 @@
return value; 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) { getFormValue(domainObject, toolbarItem) {
let value = {}; let value = {};
let values = {}; let values = {};
toolbarItem.formKeys.map(key => { toolbarItem.formKeys.map(key => {
values[key] = []; values[key] = [];
if (toolbarItem.applicableSelectedItems) {
toolbarItem.applicableSelectedItems.forEach(selectionPath => { toolbarItem.applicableSelectedItems.forEach(selectionPath => {
values[key].push(_.get(domainObject, this.getItemProperty(toolbarItem, selectionPath) + "." + key)); values[key].push(this.getPropertyValue(domainObject, toolbarItem, selectionPath, key));
}); });
} else {
values[key].push(this.getPropertyValue(domainObject, toolbarItem, undefined, key));
}
}); });
for (const key in values) { for (const key in values) {
@ -192,18 +212,34 @@
this.structure.map(s => { this.structure.map(s => {
if (s.formKeys) { if (s.formKeys) {
s.formKeys.forEach(key => { s.formKeys.forEach(key => {
if (item.applicableSelectedItems) {
item.applicableSelectedItems.forEach(selectionPath => { item.applicableSelectedItems.forEach(selectionPath => {
this.openmct.objects.mutate(item.domainObject, this.mutateObject(item, value[key], selectionPath, key);
this.getItemProperty(item, selectionPath) + "." + key, value[key]);
}); });
} else {
this.mutateObject(item, value[key], undefined, key);
}
}); });
} }
}); });
} else { } else {
if (item.applicableSelectedItems) {
item.applicableSelectedItems.forEach(selectionPath => { item.applicableSelectedItems.forEach(selectionPath => {
this.openmct.objects.mutate(item.domainObject, this.getItemProperty(item, selectionPath), value); 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) { triggerMethod(item, event) {
if (item.method) { if (item.method) {