fix for type labels for organizations.projects and organizations.job-templates

This commit is contained in:
jaredevantabor 2016-12-20 19:11:56 -08:00
parent 3d32597ec4
commit 39792b77ae
4 changed files with 65 additions and 0 deletions

View File

@ -38,6 +38,34 @@ export default ['$scope', '$rootScope', '$location', '$log',
});
}
$scope.$on(`${list.iterator}_options`, function(event, data){
$scope.options = data.data.actions.GET;
optionsRequestDataProcessing();
});
$scope.$watchCollection(`${$scope.list.name}`, function() {
optionsRequestDataProcessing();
}
);
// iterate over the list and add fields like type label, after the
// OPTIONS request returns, or the list is sorted/paginated/searched
function optionsRequestDataProcessing(){
$scope[list.name].forEach(function(item, item_idx) {
var itm = $scope[list.name][item_idx];
// Set the item type label
if (list.fields.type && $scope.options && $scope.options.hasOwnProperty('type')) {
$scope.options.type.choices.every(function(choice) {
if (choice[0] === item.type) {
itm.type_label = choice[1];
return false;
}
return true;
});
}
});
}
$scope.addJobTemplate = function() {
$state.go('jobTemplates.add');
};

View File

@ -66,6 +66,39 @@ export default ['$scope', '$rootScope', '$location', '$log',
});
}
$scope.$on(`${list.iterator}_options`, function(event, data){
$scope.options = data.data.actions.GET;
optionsRequestDataProcessing();
});
$scope.$watchCollection(`${$scope.list.name}`, function() {
optionsRequestDataProcessing();
}
);
// iterate over the list and add fields like type label, after the
// OPTIONS request returns, or the list is sorted/paginated/searched
function optionsRequestDataProcessing(){
$scope[list.name].forEach(function(item, item_idx) {
var itm = $scope[list.name][item_idx];
// Set the item type label
if (list.fields.scm_type && $scope.options &&
$scope.options.hasOwnProperty('scm_type')) {
$scope.options.scm_type.choices.every(function(choice) {
if (choice[0] === item.scm_type) {
itm.type_label = choice[1];
return false;
}
return true;
});
}
// buildTooltips(itm);
});
}
// Go out and get the organization
Rest.setUrl(orgBase + $stateParams.organization_id);
Rest.get()

View File

@ -298,6 +298,7 @@ export default [{
list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12";
list.iterator = 'job_template';
list.name = 'job_templates';
list.fields.type.ngBind = "job_template.type_label";
return list;
}],
OrgJobTemplateDataset: ['OrgJobTemplateList', 'QuerySet', '$stateParams', 'GetBasePath',

View File

@ -15,6 +15,9 @@ export default ['$scope', '$filter',
var singleJobStatus = true;
var firstJobStatus;
var recentJobs = $scope.jobs;
if(!recentJobs){
return;
}
var sparkData =
_.sortBy(recentJobs.map(function(job) {