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

View File

@ -27,9 +27,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
Rest.options() Rest.options()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
var choices = data.actions.GET.source.choices var choices = data.actions.GET.source.choices
console.log(choices);
for (var i=0; i < choices.length; i++) { for (var i=0; i < choices.length; i++) {
if (choices[i][0] !== 'file') { 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', .factory('SourceChange', [ 'GetBasePath', 'CredentialList', 'LookUpInit', 'Empty',
function(GetBasePath, CredentialList, LookUpInit){ function(GetBasePath, CredentialList, LookUpInit, Empty){
return function(params) { return function(params) {
var scope = params.scope; var scope = params.scope;
var form = params.form; var form = params.form;
if (!Empty(scope['source'])) {
if (scope['source'].value == 'file') { if (scope['source'].value == 'file') {
scope.sourcePathRequired = true; 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', []);
$('#s2id_group_source_regions').select2('data', [{ id: 'all', text: 'All' }]); $('#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 kind = (scope.source.value == 'rax') ? 'rax' : 'aws';
var url = GetBasePath('credentials') + '?cloud=true&kind=' + kind; var url = GetBasePath('credentials') + '?cloud=true&kind=' + kind;
LookUpInit({ LookUpInit({
@ -249,6 +254,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
field: 'credential' field: 'credential'
}); });
} }
}
}
}]) }])
@ -862,13 +870,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
var parseError = false; var parseError = false;
var saveError = 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, var data = { group: group_id,
source: scope['source'].value, source: ( (source && source.value) ? source.value : '' ),
source_path: scope['source_path'], source_path: scope['source_path'],
credential: scope['credential'], credential: scope['credential'],
overwrite: scope['overwrite'], 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 }); { hdr: 'Error!', msg: 'Failed to update group inventory source. PUT status: ' + status });
}); });
} }
}
else {
// No source value
scope.$emit('SaveComplete', false);
}
}); });
// Cancel // Cancel

View File

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