From 01042285412bdba9e1b2edb41e95872a0207234d Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 18 Jul 2018 17:38:11 -0400 Subject: [PATCH] Let disassociate jt cred requests finish before attempting to associate any new ones --- .../multi-credential/multi-credential.service.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/src/templates/job_templates/multi-credential/multi-credential.service.js b/awx/ui/client/src/templates/job_templates/multi-credential/multi-credential.service.js index ecb2512247..83a39b8eb4 100644 --- a/awx/ui/client/src/templates/job_templates/multi-credential/multi-credential.service.js +++ b/awx/ui/client/src/templates/job_templates/multi-credential/multi-credential.service.js @@ -38,14 +38,11 @@ function MultiCredentialService (Rest, ProcessErrors, $q, GetBasePath) { .filter(id => selected.indexOf(id) < 0) .map(id => disassociate({ related }, id)); - const associationPromises = selected - .filter(id => currentlyAssociated.indexOf(id) < 0) - .map(id => associate({ related }, id)); - - const promises = disassociationPromises - .concat(associationPromises); - - return $q.all(promises); + return $q.all(disassociationPromises).then(() => { + _.each(selected.filter(id => currentlyAssociated.indexOf(id) < 0), (id) => { + associate({related}, id); + }); + }); }); };