1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 18:21:12 +03:00

Ac-630 cloud_credential_name value is now set after data loaded for Job Template edit page.

This commit is contained in:
Chris Houseknecht 2013-11-19 09:06:25 +00:00
parent 6b418d4a5c
commit e2209ce3bd

View File

@ -419,11 +419,33 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
}
});
if (scope.cloudCredentialReadyRemove) {
scope.cloudCredentialReadyRemove();
}
scope.cloudCredentialReadyRemove = scope.$on('cloudCredentialReady', function(e, name) {
scope['cloud_credential_name'] = name;
master['cloud_credential_name'] = name;
// Clone the CredentialList object for use with cloud_credential. Cloning
// and changing properties to avoid collision.
var CloudCredentialList = {};
jQuery.extend(true, CloudCredentialList, CredentialList);
CloudCredentialList.name = 'cloudcredentials',
CloudCredentialList.iterator = 'cloudcredential',
LookUpInit({
url: GetBasePath('credentials') + '?cloud=true',
scope: scope,
form: form,
current_item: scope['cloud_credential'],
list: CloudCredentialList,
field: 'cloud_credential'
});
});
// Retrieve each related set and populate the playbook list
if (scope.jobTemplateLoadedRemove) {
scope.jobTemplateLoadedRemove();
}
scope.jobTemplateLoadedRemove = scope.$on('jobTemplateLoaded', function() {
scope.jobTemplateLoadedRemove = scope.$on('jobTemplateLoaded', function(e, related_cloud_credential) {
for (var set in relatedSets) {
scope.search(relatedSets[set].iterator);
}
@ -438,6 +460,17 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
default_val: dft
});
if (related_cloud_credential) {
Rest.setUrl(related_cloud_credential);
Rest.get()
.success( function(data, status, headers, config) {
scope.$emit('cloudCredentialReady', data.name);
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to related cloud credential. GET returned status: ' + status });
});
}
});
// Retrieve detail record and prepopulate the form
@ -511,22 +544,6 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
field: 'credential'
});
// Clone the CredentialList object for use with cloud_credential. Cloning
// and changing properties to avoid collision.
var CloudCredentialList = {};
jQuery.extend(true, CloudCredentialList, CredentialList);
CloudCredentialList.name = 'cloudcredentials',
CloudCredentialList.iterator = 'cloudcredential',
LookUpInit({
url: GetBasePath('credentials') + '?cloud=true',
scope: scope,
form: form,
current_item: data.cloud_credential,
list: CloudCredentialList,
field: 'cloud_credential'
});
LookUpInit({
scope: scope,
form: form,
@ -538,7 +555,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
scope.$emit('jobTemplateLoaded');
scope.$emit('jobTemplateLoaded', data.related.cloud_credential);
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,