Merge pull request #4996 from chrismeyersfsu/fix-4971

more gracefully handle the result of failed options request
This commit is contained in:
Chris Meyers 2017-01-30 12:56:38 -05:00 committed by GitHub
commit cba2a9694c

View File

@ -38,31 +38,34 @@ export function CredentialsList($scope, $rootScope, $location, $log,
$scope.$on(`${list.iterator}_options`, function(event, data){
$scope.options = data.data.actions.GET;
console.log($scope.options);
optionsRequestDataProcessing();
});
$scope.$watchCollection(`${$scope.list.name}`, function() {
optionsRequestDataProcessing();
}
);
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];
if ($scope[list.name] !== undefined) {
$scope[list.name].forEach(function(item, item_idx) {
var itm = $scope[list.name][item_idx];
// Set the item type label
if (list.fields.kind && $scope.options &&
$scope.options.hasOwnProperty('kind')) {
$scope.options.kind.choices.every(function(choice) {
if (choice[0] === item.kind) {
itm.kind_label = choice[1];
return false;
}
return true;
});
}
});
// Set the item type label
if (list.fields.kind && $scope.options &&
$scope.options.hasOwnProperty('kind')) {
$scope.options.kind.choices.every(function(choice) {
if (choice[0] === item.kind) {
itm.kind_label = choice[1];
return false;
}
return true;
});
}
});
}
}
$scope.addCredential = function() {