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

Fixed inventory group source drop-down so that selecting 'Choose a source' behaves the same as choosing 'Manual'. Fixed AC-989.

This commit is contained in:
Chris Houseknecht 2014-01-28 10:58:50 -05:00 committed by Matthew Jones
parent 1f6fe73a4a
commit be66062123
3 changed files with 105 additions and 107 deletions

View File

@ -67,12 +67,12 @@ angular.module('GroupFormDefinition', [])
ngChange: 'sourceChange()',
addRequired: false,
editRequired: false,
'default': { label: 'Manual', value: '' },
//'default': { label: 'Manual', value: '' },
tab: 'source'
},
source_path: {
label: 'Script Path',
ngShow: "source.value == 'file'",
ngShow: "source && source.value == 'file'",
type: 'text',
awRequiredWhen: {variable: "sourcePathRequired", init: "false" },
tab: 'source'
@ -80,7 +80,7 @@ angular.module('GroupFormDefinition', [])
credential: {
label: 'Cloud Credential',
type: 'lookup',
ngShow: "source.value !== ''",
ngShow: "source && source.value !== ''",
sourceModel: 'credential',
sourceField: 'name',
ngClick: 'lookUpCredential()',
@ -91,7 +91,7 @@ angular.module('GroupFormDefinition', [])
source_regions: {
label: 'Regions',
type: 'text',
ngShow: "source.value == 'rax' || source.value == 'ec2'",
ngShow: "source && (source.value == 'rax' || source.value == 'ec2')",
addRequired: false,
editRequired: false,
awMultiselect: 'source_region_choices',
@ -105,7 +105,7 @@ angular.module('GroupFormDefinition', [])
},
source_vars: {
label: 'Source Variables',
ngShow: "source.value == 'file' || source.value == 'ec2'",
ngShow: "source && (source.value == 'file' || source.value == 'ec2')",
type: 'textarea',
addRequired: false,
editRequird: false,
@ -145,7 +145,7 @@ angular.module('GroupFormDefinition', [])
checkbox_group: {
label: 'Update Options',
type: 'checkbox_group',
ngShow: "source.value !== '' && source.value !== null",
ngShow: "source && (source.value !== '' && source.value !== null)",
tab: 'source',
fields: [

View File

@ -27,9 +27,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
Rest.options()
.success( function(data, status, headers, config) {
var choices = data.actions.GET.source.choices
console.log(choices);
for (var i=0; i < choices.length; i++) {
if (choices[i][0] !== 'file') {
scope[variable].push({ label: (choices[i][0] == "") ? 'Manual' : choices[i][1] , value: choices[i][0] });
scope[variable].push({
label: ( (choices[i][0] == '') ? 'Manual' : choices[i][1] ),
value: choices[i][0]
});
}
}
})
@ -212,13 +216,14 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
}
}])
.factory('SourceChange', [ 'GetBasePath', 'CredentialList', 'LookUpInit',
function(GetBasePath, CredentialList, LookUpInit){
.factory('SourceChange', [ 'GetBasePath', 'CredentialList', 'LookUpInit', 'Empty',
function(GetBasePath, CredentialList, LookUpInit, Empty){
return function(params) {
var scope = params.scope;
var form = params.form;
if (!Empty(scope['source'])) {
if (scope['source'].value == 'file') {
scope.sourcePathRequired = true;
}
@ -238,7 +243,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
//$('#s2id_group_source_regions').select2('data', []);
$('#s2id_group_source_regions').select2('data', [{ id: 'all', text: 'All' }]);
}
else
if (scope['source'].value == 'rax' || scope['source'].value == 'ec2') {
var kind = (scope.source.value == 'rax') ? 'rax' : 'aws';
var url = GetBasePath('credentials') + '?cloud=true&kind=' + kind;
LookUpInit({
@ -249,6 +254,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
field: 'credential'
});
}
}
}
}])
@ -862,13 +870,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
var parseError = false;
var saveError = false;
// Update the selector tree with new group name, descr
//SetNodeName({ scope: scope['selectedNode'], group_id: group_id,
// name: scope.name, description: scope.description });
if (scope.source.value !== null && scope.source.value !== '') {
var data = { group: group_id,
source: scope['source'].value,
source: ( (source && source.value) ? source.value : '' ),
source_path: scope['source_path'],
credential: scope['credential'],
overwrite: scope['overwrite'],
@ -927,11 +930,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
{ hdr: 'Error!', msg: 'Failed to update group inventory source. PUT status: ' + status });
});
}
}
else {
// No source value
scope.$emit('SaveComplete', false);
}
});
// Cancel

View File

@ -735,7 +735,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities'])
field.awRequiredWhen.variable + "\" " : "";
html += ">\n";
html += "<option value=\"\">";
html += (field.defaultOption) ? field.defaultOption : "Choose " + field.label;
html += (field.defaultOption) ? field.defaultOption : "Choose a " + field.label.toLowerCase();
html += "</option>\n";
html += "</select>\n";
// Add error messages
@ -1462,8 +1462,8 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities'])
html += "<tr ng-repeat=\"" + form.related[itm].iterator + " in " + itm + "\" >\n";
if (form.related[itm].index == undefined || form.related[itm].index !== false) {
html += "<td>{{ $index + (" + form.related[itm].iterator + "Page * " +
form.related[itm].iterator + "PageSize) + 1 }}.</td>\n";
html += "<td>{{ $index + ((" + form.related[itm].iterator + "_page - 1) * " +
form.related[itm].iterator + "_page_size) + 1 }}.</td>\n";
}
var cnt = 1;
var rfield;