grabbed default verbosity from the API

This commit is contained in:
John Mitchell 2015-06-05 13:54:49 -04:00
parent 4849808ee9
commit 055ca1362a
3 changed files with 22 additions and 3 deletions

View File

@ -80,8 +80,13 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams,
choicesReadyCount++;
if (choicesReadyCount === 2) {
var verbosity;
// this sets the default options for the selects as specified by the controller.
$scope.verbosity = $scope.adhoc_verbosity_options[$scope.verbosity_field.default];
for (verbosity in $scope.adhoc_verbosity_options) {
if ($scope.adhoc_verbosity_options[verbosity].isDefault) {
$scope.verbosity = $scope.adhoc_verbosity_options[verbosity];
}
}
$("#forks-number").spinner("value", $scope.forks_field.default);
$scope.forks = $scope.forks_field.default;
Wait('stop'); // END: form population

View File

@ -340,8 +340,13 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $
$scope.removeChoicesReady = $scope.$on('choicesReadyVerbosity', function () {
selectCount++;
if (selectCount === 2) {
var verbosity;
// this sets the default options for the selects as specified by the controller.
$scope.verbosity = $scope.verbosity_options[$scope.verbosity_field.default];
for (verbosity in $scope.verbosity_options) {
if ($scope.verbosity_options[verbosity].isDefault) {
$scope.verbosity = $scope.verbosity_options[verbosity];
}
}
$scope.job_type = $scope.job_type_options[$scope.job_type_field.default];
// if you're getting to the form from the scan job section on inventories,

View File

@ -765,8 +765,9 @@ angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter'])
Rest.setUrl(url);
Rest.options()
.success(function (data) {
var choices;
var choices, defaultChoice;
choices = (choice_name) ? data.actions.GET[field][choice_name] : data.actions.GET[field].choices;
defaultChoice = data.actions.POST[field].default;
if (choices) {
// including 'name' property so list can be used by search
choices.forEach(function(choice) {
@ -777,6 +778,14 @@ angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter'])
});
});
}
if (defaultChoice !== undefined) {
var val;
for (val in scope[variable]) {
if (scope[variable][val].value === defaultChoice) {
scope[variable][val].isDefault = true;
}
}
}
if (callback) {
scope.$emit(callback);
}