mirror of
https://github.com/nasa/openmct.git
synced 2025-06-21 16:49:42 +00:00
[Selection] support getting object view's selection context (#2272)
* Get selection context from object view for constructing the context in subobject view. * Implement getSelectionContext for flexible layout provider and remove code that makes flexible layout self selectable. * Get selection context from object frame when constructing context for frames. * Disable Add button when selected parent is a flexible layout * Make 'Add' button working for selected display layouts in a flexible layout. * fix expand error and fix flexible layout toggle container issue * Check for parent object before getting composition.
This commit is contained in:
committed by
Deep Tailor
parent
e254fafb5c
commit
666bb41697
@ -26,7 +26,8 @@
|
|||||||
<object-frame v-if="domainObject"
|
<object-frame v-if="domainObject"
|
||||||
:domain-object="domainObject"
|
:domain-object="domainObject"
|
||||||
:object-path="objectPath"
|
:object-path="objectPath"
|
||||||
:has-frame="item.hasFrame">
|
:has-frame="item.hasFrame"
|
||||||
|
ref="objectFrame">
|
||||||
</object-frame>
|
</object-frame>
|
||||||
</layout-frame>
|
</layout-frame>
|
||||||
</template>
|
</template>
|
||||||
@ -98,13 +99,15 @@
|
|||||||
setObject(domainObject) {
|
setObject(domainObject) {
|
||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
this.objectPath = [this.domainObject].concat(this.openmct.router.path);
|
this.objectPath = [this.domainObject].concat(this.openmct.router.path);
|
||||||
this.context = {
|
this.$nextTick(function () {
|
||||||
item: domainObject,
|
let childContext = this.$refs.objectFrame.getSelectionContext();
|
||||||
layoutItem: this.item,
|
childContext.item = domainObject;
|
||||||
index: this.index
|
childContext.layoutItem = this.item;
|
||||||
};
|
childContext.index = this.index;
|
||||||
this.removeSelectable = this.openmct.selection.selectable(
|
this.context = childContext;
|
||||||
this.$el, this.context, this.initSelect);
|
this.removeSelectable = this.openmct.selection.selectable(
|
||||||
|
this.$el, this.context, this.initSelect);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
v-if="domainObject"
|
v-if="domainObject"
|
||||||
:domain-object="domainObject"
|
:domain-object="domainObject"
|
||||||
:object-path="objectPath"
|
:object-path="objectPath"
|
||||||
:has-frame="hasFrame">
|
:has-frame="hasFrame"
|
||||||
|
ref="objectFrame">
|
||||||
</object-frame>
|
</object-frame>
|
||||||
|
|
||||||
<div class="c-fl-frame__size-indicator"
|
<div class="c-fl-frame__size-indicator"
|
||||||
@ -78,14 +79,14 @@ export default {
|
|||||||
this.setSelection();
|
this.setSelection();
|
||||||
},
|
},
|
||||||
setSelection() {
|
setSelection() {
|
||||||
let context = {
|
this.$nextTick(function () {
|
||||||
item: this.domainObject,
|
let childContext = this.$refs.objectFrame.getSelectionContext();
|
||||||
addContainer: this.addContainer,
|
childContext.item = this.domainObject;
|
||||||
type: 'frame',
|
childContext.type = 'frame';
|
||||||
frameId: this.frame.id
|
childContext.frameId = this.frame.id;
|
||||||
};
|
this.unsubscribeSelection = this.openmct.selection.selectable(
|
||||||
|
this.$refs.frame, childContext, false);
|
||||||
this.unsubscribeSelection = this.openmct.selection.selectable(this.$refs.frame, context, false);
|
});
|
||||||
},
|
},
|
||||||
initDrag(event) {
|
initDrag(event) {
|
||||||
let type = this.openmct.types.get(this.domainObject.type),
|
let type = this.openmct.types.get(this.domainObject.type),
|
||||||
|
@ -53,7 +53,7 @@ function ToolbarProvider(openmct) {
|
|||||||
toggleContainer = {
|
toggleContainer = {
|
||||||
control: 'toggle-button',
|
control: 'toggle-button',
|
||||||
key: 'toggle-layout',
|
key: 'toggle-layout',
|
||||||
domainObject: secondary ? secondary.context.item : primary.context.item,
|
domainObject: primary.context.item,
|
||||||
property: 'configuration.rowsLayout',
|
property: 'configuration.rowsLayout',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
@ -140,6 +140,8 @@ function ToolbarProvider(openmct) {
|
|||||||
title: 'Add Container'
|
title: 'Add Container'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
toggleContainer.domainObject = secondary.context.item;
|
||||||
|
|
||||||
} else if (primary.context.type === 'container') {
|
} else if (primary.context.type === 'container') {
|
||||||
|
|
||||||
deleteContainer = {
|
deleteContainer = {
|
||||||
|
@ -129,6 +129,10 @@
|
|||||||
objectPath: Array,
|
objectPath: Array,
|
||||||
hasFrame: Boolean,
|
hasFrame: Boolean,
|
||||||
},
|
},
|
||||||
|
components: {
|
||||||
|
ObjectView,
|
||||||
|
ContextMenuDropDown,
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
expand() {
|
expand() {
|
||||||
let objectView = this.$refs.objectView,
|
let objectView = this.$refs.objectView,
|
||||||
@ -142,12 +146,11 @@
|
|||||||
parentElement.append(childElement);
|
parentElement.append(childElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
getSelectionContext() {
|
||||||
|
return this.$refs.objectView.getSelectionContext();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
ObjectView,
|
|
||||||
ContextMenuDropDown,
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
let objectType = this.openmct.types.get(this.domainObject.type),
|
let objectType = this.openmct.types.get(this.domainObject.type),
|
||||||
cssClass = objectType && objectType.definition ? objectType.definition.cssClass : 'icon-object-unknown',
|
cssClass = objectType && objectType.definition ? objectType.definition.cssClass : 'icon-object-unknown',
|
||||||
|
@ -40,6 +40,11 @@ export default {
|
|||||||
}
|
}
|
||||||
delete this.viewContainer;
|
delete this.viewContainer;
|
||||||
delete this.currentView;
|
delete this.currentView;
|
||||||
|
|
||||||
|
if (this.removeSelectable) {
|
||||||
|
this.removeSelectable();
|
||||||
|
delete this.removeSelectable;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updateView(immediatelySelect) {
|
updateView(immediatelySelect) {
|
||||||
this.clear();
|
this.clear();
|
||||||
@ -61,12 +66,7 @@ export default {
|
|||||||
|
|
||||||
if (immediatelySelect) {
|
if (immediatelySelect) {
|
||||||
this.removeSelectable = openmct.selection.selectable(
|
this.removeSelectable = openmct.selection.selectable(
|
||||||
this.$el,
|
this.$el, this.getSelectionContext(), true);
|
||||||
this.currentView.getSelectionContext ?
|
|
||||||
this.currentView.getSelectionContext() :
|
|
||||||
{ item: this.currentObject },
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
show(object, viewKey, immediatelySelect) {
|
show(object, viewKey, immediatelySelect) {
|
||||||
@ -87,6 +87,13 @@ export default {
|
|||||||
this.viewKey = viewKey;
|
this.viewKey = viewKey;
|
||||||
this.updateView(immediatelySelect);
|
this.updateView(immediatelySelect);
|
||||||
},
|
},
|
||||||
|
getSelectionContext() {
|
||||||
|
if (this.currentView.getSelectionContext) {
|
||||||
|
return this.currentView.getSelectionContext();
|
||||||
|
} else {
|
||||||
|
return { item: this.currentObject };
|
||||||
|
}
|
||||||
|
},
|
||||||
onDragOver(event) {
|
onDragOver(event) {
|
||||||
if (this.hasComposableDomainObject(event)) {
|
if (this.hasComposableDomainObject(event)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -235,7 +235,7 @@
|
|||||||
if (selection[0]) {
|
if (selection[0]) {
|
||||||
let parentObject = selection[0].context.item;
|
let parentObject = selection[0].context.item;
|
||||||
|
|
||||||
this.hasComposition = !!this.openmct.composition.get(parentObject);
|
this.hasComposition = !!(parentObject && this.openmct.composition.get(parentObject));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user