[Inspector] Listen for mutation and refresh composition

...so that elements pool is updated when selected object's composition changes. Fixes #1869
This commit is contained in:
Pegah Sarram
2018-01-19 00:17:27 -08:00
committed by Victor Woeltjen
parent 0363d0e8ad
commit d4e3e6689c
2 changed files with 69 additions and 10 deletions

View File

@ -52,8 +52,20 @@ define(
}
function setSelection(selection) {
self.scope.selection = selection;
self.refreshComposition(selection);
if (!selection[0]) {
return;
}
if (self.mutationListener) {
self.mutationListener();
delete self.mutationListener;
}
var domainObject = selection[0].context.oldItem;
self.refreshComposition(domainObject);
self.mutationListener = domainObject.getCapability('mutation')
.listen(self.refreshComposition.bind(self, domainObject));
}
$scope.filterBy = filterBy;
@ -70,16 +82,11 @@ define(
/**
* Gets the composition for the selected object and populates the scope with it.
*
* @param selection the selection object
* @param domainObject the selected object
* @private
*/
ElementsController.prototype.refreshComposition = function (selection) {
if (!selection[0]) {
return;
}
var selected = selection[0].context.oldItem;
var selectedObjectComposition = selected && selected.useCapability('composition');
ElementsController.prototype.refreshComposition = function (domainObject) {
var selectedObjectComposition = domainObject.useCapability('composition');
if (selectedObjectComposition) {
selectedObjectComposition.then(function (composition) {