[Edit] Refresh Library less aggressively

Update the root object (used to populate the Library pane)
less often, to avoid recreating the whole tree and thereby
causing the tree to collapse. WTD-788.
This commit is contained in:
Victor Woeltjen
2015-02-26 16:53:15 -08:00
parent 970b5e70ba
commit 988716ff01
3 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,47 @@
/*global define*/
define(
[],
function () {
"use strict";
/**
* Supports the Library and Elements panes in Edit mode.
* @constructor
*/
function EditPanesController($scope) {
var root;
// Update root object based on represented object
function updateRoot(domainObject) {
var context = domainObject &&
domainObject.getCapability('context'),
newRoot = context && context.getRoot(),
oldId = root && root.getId(),
newId = newRoot && newRoot.getId();
// Only update if this has actually changed,
// to avoid excessive refreshing.
if (oldId !== newId) {
root = newRoot;
}
}
// Update root when represented object changes
$scope.$watch('domainObject', updateRoot);
return {
/**
* Get the root-level domain object, as reported by the
* represented domain object.
* @returns {DomainObject} the root object
*/
getRoot: function () {
return root;
}
};
}
return EditPanesController;
}
);