[Mobile] Collapse tree on click

Collapse tree any time a user does an action in the
tree that would select an object; don't only do this
on navigation changes, because this fails to detect
occasions where user clicks the already-navigated-to
object.
This commit is contained in:
Victor Woeltjen
2015-09-21 10:53:45 -07:00
parent ae4313253c
commit 0c1f77cfab
9 changed files with 75 additions and 65 deletions

View File

@ -48,6 +48,15 @@ define(
* node expansion when this tree node's _subtree_ will contain
* the navigated object (recursively, this becomes an
* expand-to-show-navigated-object behavior.)
*
* Finally, if a `callback` property is passed in through the
* `parameters` attribute of the `tree-node`, that callback
* will be invoked whenever a user clicks in a manner which
* would result in a selection. This callback is invoked
* even if the selection does not change (if you are only
* interested in changes, watch the `selectedObject` property
* of the object passed in `ng-model` instead.)
*
* @memberof platform/commonUI/general
* @constructor
*/
@ -140,6 +149,22 @@ define(
$scope.$watch("domainObject", checkSelection);
}
/**
* Select the domain object represented by this node in the tree.
* This will both update the `selectedObject` property in
* the object passed in via `ng-model`, and will fire any `callback`
* passed in via `parameters`.
*/
TreeNodeController.prototype.select = function () {
if (this.$scope.ngModel) {
this.$scope.ngModel.selectedObject =
this.$scope.domainObject;
}
if ((this.$scope.parameters || {}).callback) {
this.$scope.parameters.callback(this.$scope.domainObject);
}
};
/**
* This method should be called when a node is expanded
* to record that this has occurred, to support one-time