mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 18:57:01 +00:00
Update toolbar to get value and mutate object if toolbar item doesn't have applicableSelectedItems. Also, modify flexibale layout to select parent by clicking the element instead of using selection's private methods.
This commit is contained in:
parent
c6053e234a
commit
7fb3d86d06
@ -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')) {
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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});
|
||||
|
Loading…
Reference in New Issue
Block a user