[Containment] Enforce containment rules in locator

Enforce containment rules in locator; WTD-962.
This commit is contained in:
Victor Woeltjen
2015-04-07 22:21:37 -07:00
parent 7cabead3bc
commit 0550e09344
5 changed files with 31 additions and 8 deletions

View File

@@ -17,13 +17,25 @@ define(
// the full tree
// * treeModel: The model for the embedded tree representation,
// used for bi-directional object selection.
function setLocatingObject(domainObject) {
function setLocatingObject(domainObject, priorObject) {
var context = domainObject &&
domainObject.getCapability("context");
$scope.rootObject = context && context.getRoot();
$scope.rootObject = (context && context.getRoot()) || $scope.rootObject;
$scope.treeModel.selectedObject = domainObject;
$scope.ngModel[$scope.field] = domainObject;
// Restrict which locations can be selected
if (domainObject &&
$scope.structure &&
$scope.structure.validate) {
if (!$scope.structure.validate(domainObject)) {
setLocatingObject(
$scope.structure.validate(priorObject) ?
priorObject : undefined
);
}
}
}
// Initial state for the tree's model