From ce4eccc5136ace099bb4ac7923f50b7c1b6f8b2f Mon Sep 17 00:00:00 2001 From: gconsidine Date: Mon, 24 Jul 2017 14:27:40 -0400 Subject: [PATCH 1/2] Add assignment of on list change --- .../credentials/list/credentials-list.controller.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/credentials/list/credentials-list.controller.js b/awx/ui/client/src/credentials/list/credentials-list.controller.js index 244afe6cc5..a160bfa40e 100644 --- a/awx/ui/client/src/credentials/list/credentials-list.controller.js +++ b/awx/ui/client/src/credentials/list/credentials-list.controller.js @@ -21,16 +21,14 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', ' $scope.canAdd = params.canAdd; }); + $scope.$watch(list.name, assignCredentialKinds); + // search init $scope.list = list; $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope.selected = []; - - $scope[list.name].forEach(credential => { - credential.kind = credentialType.getById(credential.credential_type).name; - }); } $scope.$on(`${list.iterator}_options`, function(event, data){ @@ -42,6 +40,12 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', ' optionsRequestDataProcessing(); }); + function assignCredentialKinds () { + $scope[list.name].forEach(credential => { + credential.kind = credentialType.getById(credential.credential_type).name; + }); + } + // iterate over the list and add fields like type label, after the // OPTIONS request returns, or the list is sorted/paginated/searched function optionsRequestDataProcessing(){ From 20162014b757a32352e18b930c2d683e0ac38c15 Mon Sep 17 00:00:00 2001 From: gconsidine Date: Mon, 24 Jul 2017 16:50:19 -0400 Subject: [PATCH 2/2] Add check if list is an array before looping --- .../src/credentials/list/credentials-list.controller.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/awx/ui/client/src/credentials/list/credentials-list.controller.js b/awx/ui/client/src/credentials/list/credentials-list.controller.js index a160bfa40e..30acfc38c5 100644 --- a/awx/ui/client/src/credentials/list/credentials-list.controller.js +++ b/awx/ui/client/src/credentials/list/credentials-list.controller.js @@ -41,6 +41,10 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', ' }); function assignCredentialKinds () { + if (!Array.isArray($scope[list.name])) { + return; + } + $scope[list.name].forEach(credential => { credential.kind = credentialType.getById(credential.credential_type).name; });