From 2476941eb212dcaa0a6db411a488309013d3c5e2 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 3 Dec 2014 13:51:07 -0800 Subject: [PATCH] [Forms] Add Locator control Add Locator form control, to allow selection of a destination for newly-created domain objects in a tree. WTD-593. --- platform/commonUI/browse/bundle.json | 11 ++++++ .../browse/res/templates/create/locator.html | 8 ++++ .../browse/src/creation/LocatorController.js | 39 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 platform/commonUI/browse/res/templates/create/locator.html create mode 100644 platform/commonUI/browse/src/creation/LocatorController.js diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index 14ff9344ba..e6cc265eff 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -30,6 +30,17 @@ "key": "CreateMenuController", "implementation": "creation/CreateMenuController", "depends": [ "$scope" ] + }, + { + "key": "LocatorController", + "implementation": "creation/LocatorController", + "depends": [ "$scope" ] + } + ], + "controls": [ + { + "key": "locator", + "templateUrl": "templates/create/locator.html" } ], "templates": [ diff --git a/platform/commonUI/browse/res/templates/create/locator.html b/platform/commonUI/browse/res/templates/create/locator.html new file mode 100644 index 0000000000..071611add1 --- /dev/null +++ b/platform/commonUI/browse/res/templates/create/locator.html @@ -0,0 +1,8 @@ +
+
+ + +
+
diff --git a/platform/commonUI/browse/src/creation/LocatorController.js b/platform/commonUI/browse/src/creation/LocatorController.js new file mode 100644 index 0000000000..5b2ea72e35 --- /dev/null +++ b/platform/commonUI/browse/src/creation/LocatorController.js @@ -0,0 +1,39 @@ +/*global define*/ + +define( + [], + function () { + "use strict"; + + /** + * Controller for the "locator" control, which provides the + * user with the ability to select a domain object as the + * destination for a newly-created object in the Create menu. + * @constructor + */ + function LocatorController($scope) { + // Populate values needed by the locator control. These are: + // * rootObject: The top-level object, since we want to show + // the full tree + // * treeModel: The model for the embedded tree representation, + // used for bi-directional object selection. + function setLocatingObject(domainObject) { + var context = domainObject && + domainObject.getCapability("context"); + + $scope.rootObject = context && context.getRoot(); + $scope.treeModel.selectedObject = domainObject; + $scope.ngModel[$scope.field] = domainObject; + } + + // Initial state for the tree's model + $scope.treeModel = + { selectedObject: $scope.ngModel[$scope.field] }; + + // Watch for changes from the tree + $scope.$watch("treeModel.selectedObject", setLocatingObject); + } + + return LocatorController; + } +);