[Layout] Select the fixed position view only if the parent is not selected.

Also, add mutation listener if domain object is defined to fix the TypeError.

Fixes # 1909 and #1912
This commit is contained in:
Pegah Sarram 2018-02-13 13:23:49 -08:00
parent d4e3e6689c
commit e5d869f01e
3 changed files with 16 additions and 4 deletions

View File

@ -64,8 +64,10 @@ define(
var domainObject = selection[0].context.oldItem;
self.refreshComposition(domainObject);
self.mutationListener = domainObject.getCapability('mutation')
.listen(self.refreshComposition.bind(self, domainObject));
if (domainObject) {
self.mutationListener = domainObject.getCapability('mutation')
.listen(self.refreshComposition.bind(self, domainObject));
}
}
$scope.filterBy = filterBy;
@ -86,7 +88,7 @@ define(
* @private
*/
ElementsController.prototype.refreshComposition = function (domainObject) {
var selectedObjectComposition = domainObject.useCapability('composition');
var selectedObjectComposition = domainObject && domainObject.useCapability('composition');
if (selectedObjectComposition) {
selectedObjectComposition.then(function (composition) {

View File

@ -127,6 +127,16 @@ define(
expect(mockUnlisten).toHaveBeenCalled();
});
it("does not listen on mutation for element proxy selectable", function () {
selectable[0] = {
context: {
elementProxy: {}
}
};
mockOpenMCT.selection.on.mostRecentCall.args[1](selectable);
expect(mockDomainObject.getCapability).not.toHaveBeenCalledWith('mutation');
});
});
}
);

View File

@ -272,7 +272,7 @@ define(
self.resizeHandles = self.generateDragHandles(self.selectedElementProxy);
} else {
// Make fixed view selectable if it's not already.
if (!self.fixedViewSelectable) {
if (!self.fixedViewSelectable && selectable.length === 1) {
self.fixedViewSelectable = true;
selection.context.viewProxy = new FixedProxy(addElement, $q, dialogService);
self.openmct.selection.select(selection);