Created an Angular slider directive to support JQueryUI slider widget. Job Template page now uses a slider for Forks value. User can set the value with the slider or type in a value btwn 0 and 100. Additionally turned verbosity into a drop-down.

This commit is contained in:
chouseknecht
2013-06-06 15:01:23 -04:00
parent c7748999d8
commit 93e9c7a24d
24 changed files with 107 additions and 28 deletions

View File

@@ -168,6 +168,15 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
var form = JobTemplateForm;
var generator = GenerateForm;
var scope = generator.inject(form, {mode: 'add', related: false});
scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }];
scope.verbosity_options = [
{ value: '0', label: 'Silent' },
{ value: '1', label: 'Whisper' },
{ value: '2', label: 'Talk' },
{ value: '3', label: 'Scream' }];
scope.playbook_options = [];
generator.reset();
LoadBreadCrumbs();
@@ -221,10 +230,7 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
current_item: null,
list: ProjectList,
field: 'project'
});
scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }];
scope.playbook_options = [];
});
// Save
scope.formSave = function() {
@@ -261,7 +267,6 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
// Defaults
generator.reset();
};
}
JobTemplatesAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm',
@@ -281,13 +286,24 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
var generator = GenerateForm;
var form = JobTemplateForm;
var scope = generator.inject(form, {mode: 'edit', related: true});
// Our job type options
scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }];
scope.verbosity_options = [
{ value: '0', label: 'Silent' },
{ value: '1', label: 'Whisper' },
{ value: '2', label: 'Talk' },
{ value: '3', label: 'Scream' }];
scope.playbook_options = null;
scope.playbook = null;
generator.reset();
var base = $location.path().replace(/^\//,'').split('/')[0];
var master = {};
var id = $routeParams.id;
var relatedSets = {};
function getPlaybooks(project) {
if (project !== null && project !== '' && project !== undefined) {
var url = GetBasePath('projects') + project + '/playbooks/';
@@ -326,13 +342,9 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
scope.search(relatedSets[set].iterator);
}
getPlaybooks(scope.project);
$('#forks-slider').slider('value',scope.forks); // align slider handle with value.
});
// Our job type options
scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }];
scope.playbook_options = null;
scope.playbook = null;
// Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl + ':id/');
Rest.get({ params: {id: id} })
@@ -442,6 +454,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
for (var fld in master) {
scope[fld] = master[fld];
}
$('#forks-slider').slider("option", "value", scope.forks);
};
// Related set: Add button
@@ -481,7 +494,6 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
});
}
}
JobTemplatesEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm',