mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 11:17:04 +00:00
[Containment] Set validity in locator
Set validity of selected location from locator control, to disallow creation when no valid location is selected (which is possible due to containment rules.) WTD-962.
This commit is contained in:
parent
0550e09344
commit
cc0a46d5cc
@ -34,8 +34,17 @@ define(
|
||||
$scope.structure.validate(priorObject) ?
|
||||
priorObject : undefined
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Set validity
|
||||
if ($scope.ngModelController) {
|
||||
$scope.ngModelController.$setValidity(
|
||||
'composition',
|
||||
!!$scope.treeModel.selectedObject
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Initial state for the tree's model
|
||||
|
@ -26,20 +26,18 @@ define(
|
||||
controlMap[control.key] = path;
|
||||
});
|
||||
|
||||
function controller($scope) {
|
||||
$scope.$watch("key", function (key) {
|
||||
function link(scope, element, attrs, ngModelController) {
|
||||
scope.$watch("key", function (key) {
|
||||
// Pass the template URL to ng-include via scope.
|
||||
$scope.inclusion = controlMap[key];
|
||||
scope.inclusion = controlMap[key];
|
||||
});
|
||||
scope.ngModelController = ngModelController;
|
||||
}
|
||||
|
||||
return {
|
||||
// Only show at the element level
|
||||
restrict: "E",
|
||||
|
||||
// Use the included controller to populate scope
|
||||
controller: controller,
|
||||
|
||||
// Use ng-include as a template; "inclusion" will be the real
|
||||
// template path
|
||||
template: '<ng-include src="inclusion"></ng-include>',
|
||||
@ -47,6 +45,12 @@ define(
|
||||
// ngOptions is terminal, so we need to be higher priority
|
||||
priority: 1000,
|
||||
|
||||
// Get the ngModelController, so that controls can set validity
|
||||
require: 'ngModel',
|
||||
|
||||
// Link function
|
||||
link: link,
|
||||
|
||||
// Pass through Angular's normal input field attributes
|
||||
scope: {
|
||||
// Used to choose which form control to use
|
||||
|
Loading…
Reference in New Issue
Block a user