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) ?
|
$scope.structure.validate(priorObject) ?
|
||||||
priorObject : undefined
|
priorObject : undefined
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set validity
|
||||||
|
if ($scope.ngModelController) {
|
||||||
|
$scope.ngModelController.$setValidity(
|
||||||
|
'composition',
|
||||||
|
!!$scope.treeModel.selectedObject
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial state for the tree's model
|
// Initial state for the tree's model
|
||||||
|
@ -26,20 +26,18 @@ define(
|
|||||||
controlMap[control.key] = path;
|
controlMap[control.key] = path;
|
||||||
});
|
});
|
||||||
|
|
||||||
function controller($scope) {
|
function link(scope, element, attrs, ngModelController) {
|
||||||
$scope.$watch("key", function (key) {
|
scope.$watch("key", function (key) {
|
||||||
// Pass the template URL to ng-include via scope.
|
// Pass the template URL to ng-include via scope.
|
||||||
$scope.inclusion = controlMap[key];
|
scope.inclusion = controlMap[key];
|
||||||
});
|
});
|
||||||
|
scope.ngModelController = ngModelController;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Only show at the element level
|
// Only show at the element level
|
||||||
restrict: "E",
|
restrict: "E",
|
||||||
|
|
||||||
// Use the included controller to populate scope
|
|
||||||
controller: controller,
|
|
||||||
|
|
||||||
// Use ng-include as a template; "inclusion" will be the real
|
// Use ng-include as a template; "inclusion" will be the real
|
||||||
// template path
|
// template path
|
||||||
template: '<ng-include src="inclusion"></ng-include>',
|
template: '<ng-include src="inclusion"></ng-include>',
|
||||||
@ -47,6 +45,12 @@ define(
|
|||||||
// ngOptions is terminal, so we need to be higher priority
|
// ngOptions is terminal, so we need to be higher priority
|
||||||
priority: 1000,
|
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
|
// Pass through Angular's normal input field attributes
|
||||||
scope: {
|
scope: {
|
||||||
// Used to choose which form control to use
|
// Used to choose which form control to use
|
||||||
|
Loading…
Reference in New Issue
Block a user