mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 11:57:37 -02:30
Added Organization lookup to custom inv script
The custom inventory script form needed to have an organization associated with it, so I added a lookup to the form and made sure this was incorporated with the Reset functionality
This commit is contained in:
@@ -34,6 +34,15 @@ angular.module('CustomInventoryFormDefinition', [])
|
|||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false
|
editRequired: false
|
||||||
},
|
},
|
||||||
|
organization: {
|
||||||
|
label: 'Organization',
|
||||||
|
type: 'lookup',
|
||||||
|
sourceModel: 'organization',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngClick: 'lookUpOrganization()',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false
|
||||||
|
},
|
||||||
script: {
|
script: {
|
||||||
label: 'Custom Script',
|
label: 'Custom Script',
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
|
|||||||
@@ -177,9 +177,9 @@ angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'Sc
|
|||||||
|
|
||||||
|
|
||||||
.factory('CustomInventoryAdd', ['$compile','SchedulerInit', 'Rest', 'Wait', 'CustomInventoryList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
.factory('CustomInventoryAdd', ['$compile','SchedulerInit', 'Rest', 'Wait', 'CustomInventoryList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
||||||
'SearchInit' , 'PaginateInit', 'GenerateList',
|
'SearchInit' , 'PaginateInit', 'GenerateList', 'LookUpInit', 'OrganizationList',
|
||||||
function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
||||||
SearchInit, PaginateInit, GenerateList) {
|
SearchInit, PaginateInit, GenerateList, LookUpInit, OrganizationList) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
generator = GenerateForm,
|
generator = GenerateForm,
|
||||||
@@ -191,12 +191,22 @@ function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInvento
|
|||||||
generator.inject(form, { id:'custom-script-dialog', mode: 'add' , scope:scope, related: false, breadCrumbs: false});
|
generator.inject(form, { id:'custom-script-dialog', mode: 'add' , scope:scope, related: false, breadCrumbs: false});
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
url: GetBasePath('organization'),
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
// hdr: "Select Custom Inventory",
|
||||||
|
list: OrganizationList,
|
||||||
|
field: 'organization',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ name: scope.name, description: scope.description, script: scope.script })
|
Rest.post({ name: scope.name, description: scope.description, organization: scope.organization, script: scope.script })
|
||||||
.success(function () {
|
.success(function () {
|
||||||
view.inject( list, {
|
view.inject( list, {
|
||||||
id : 'custom-script-dialog',
|
id : 'custom-script-dialog',
|
||||||
@@ -238,9 +248,9 @@ function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInvento
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('CustomInventoryEdit', ['$compile','CustomInventoryList', 'Rest', 'Wait', 'GenerateList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
.factory('CustomInventoryEdit', ['$compile','CustomInventoryList', 'Rest', 'Wait', 'GenerateList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm',
|
||||||
'SearchInit', 'PaginateInit', '$routeParams',
|
'SearchInit', 'PaginateInit', '$routeParams', 'OrganizationList', 'LookUpInit',
|
||||||
function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm,
|
||||||
SearchInit, PaginateInit, $routeParams) {
|
SearchInit, PaginateInit, $routeParams, OrganizationList, LookUpInit) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
id = params.id,
|
id = params.id,
|
||||||
@@ -260,6 +270,15 @@ function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventor
|
|||||||
activityStream: false
|
activityStream: false
|
||||||
});
|
});
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
LookUpInit({
|
||||||
|
url: GetBasePath('organization'),
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
// hdr: "Select Custom Inventory",
|
||||||
|
list: OrganizationList,
|
||||||
|
field: 'organization',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Wait('start');
|
Wait('start');
|
||||||
@@ -272,6 +291,14 @@ function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventor
|
|||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
master[fld] = data[fld];
|
master[fld] = data[fld];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (form.fields[fld].sourceModel && data.summary_fields &&
|
||||||
|
data.summary_fields[form.fields[fld].sourceModel]) {
|
||||||
|
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
|
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||||
|
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
|
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
@@ -284,7 +311,7 @@ function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventor
|
|||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(url+ id+'/');
|
Rest.setUrl(url+ id+'/');
|
||||||
Rest.put({ name: scope.name, description: scope.description, script: scope.script })
|
Rest.put({ name: scope.name, description: scope.description, organization: scope.organization, script: scope.script })
|
||||||
.success(function () {
|
.success(function () {
|
||||||
view.inject( list, {
|
view.inject( list, {
|
||||||
id : 'custom-script-dialog',
|
id : 'custom-script-dialog',
|
||||||
@@ -320,10 +347,11 @@ function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventor
|
|||||||
|
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
generator.reset();
|
generator.reset();
|
||||||
//$('#forks-slider').slider("option", "value", $scope.forks);
|
|
||||||
for (var fld in master) {
|
for (var fld in master) {
|
||||||
scope[fld] = master[fld];
|
scope[fld] = master[fld];
|
||||||
}
|
}
|
||||||
|
scope.organization_name = master.organization_name;
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
Reference in New Issue
Block a user