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() {
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')) {

View File

@ -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) {

View File

@ -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,

View File

@ -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});