migrated job type select to using api options as well

This commit is contained in:
John Mitchell 2015-04-21 13:31:08 -04:00
parent 802fed2a76
commit bcd57b18c2

View File

@ -272,13 +272,7 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $
};
$scope.mode = "add";
$scope.parseType = 'yaml';
ParseTypeChange({ scope: $scope, field_id: 'job_templates_variables', onChange: callback });
$scope.job_type_options = [
{ value: 'run', label: 'Run' },
{ value: 'check', label: 'Check' },
{ value: 'scan' , label: 'Scan'}
];
ParseTypeChange({ scope: $scope, field_id: 'job_templates_variables', onChange: callback })
$scope.playbook_options = [];
$scope.allow_callbacks = 'false';
@ -341,16 +335,22 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $
});
});
var selectCount = 0;
if ($scope.removeChoicesReady) {
$scope.removeChoicesReady();
}
$scope.removeChoicesReady = $scope.$on('choicesReadyVerbosity', function () {
// this sets the default option as specified by the controller.
$scope.verbosity = $scope.verbosity_options[$scope.verbosity_field.default];
$scope.$emit('lookUpInitialize');
selectCount++;
if (selectCount === 2) {
// this sets the default options for the selects as specified by the controller.
$scope.verbosity = $scope.verbosity_options[$scope.verbosity_field.default];
$scope.job_type = $scope.job_type_options[$scope.job_type_field.default];
$scope.$emit('lookUpInitialize');
}
});
// setup verbosity options lookup
// setup verbosity options select
GetChoices({
scope: $scope,
url: defaultUrl,
@ -359,6 +359,15 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $
callback: 'choicesReadyVerbosity'
});
// setup job type options select
GetChoices({
scope: $scope,
url: defaultUrl,
field: 'job_type',
variable: 'job_type_options',
callback: 'choicesReadyVerbosity'
});
// Update playbook select whenever project value changes
selectPlaybook = function (oldValue, newValue) {
var url;
@ -668,13 +677,6 @@ export function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log,
$scope.parseType = 'yaml';
$scope.showJobType = false;
// Our job type options
$scope.job_type_options = [
{ value: 'run', label: 'Run' },
{ value: 'check', label: 'Check' },
{ value: 'scan', label: 'Scan'}
];
SurveyControllerInit({
scope: $scope,
parent_scope: $scope,
@ -972,7 +974,7 @@ export function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log,
}
$scope.removeChoicesReady = $scope.$on('choicesReady', function() {
choicesCount++;
if (choicesCount === 3) {
if (choicesCount === 4) {
$scope.$emit('LoadJobs');
}
});
@ -1002,6 +1004,15 @@ export function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log,
callback: 'choicesReady'
});
// setup job type options lookup
GetChoices({
scope: $scope,
url: defaultUrl,
field: 'job_type',
variable: 'job_type_options',
callback: 'choicesReady'
});
function saveCompleted() {
setTimeout(function() {
$scope.$apply(function() {