mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 02:47:35 -02:30
Merge pull request #617 from jlmitch5/fixAddInteraction
fixed add interaction with lists
This commit is contained in:
@@ -245,7 +245,7 @@ JobTemplatesList.$inject = ['$scope', '$rootScope', '$location', '$log',
|
|||||||
'$state'
|
'$state'
|
||||||
];
|
];
|
||||||
|
|
||||||
export function JobTemplatesAdd($filter, $scope, $rootScope, $compile,
|
export function JobTemplatesAdd(Refresh, $filter, $scope, $rootScope, $compile,
|
||||||
$location, $log, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
$location, $log, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
||||||
ProcessErrors, ReturnToCaller, ClearScope, GetBasePath, InventoryList,
|
ProcessErrors, ReturnToCaller, ClearScope, GetBasePath, InventoryList,
|
||||||
CredentialList, ProjectList, LookUpInit, md5Setup, ParseTypeChange, Wait,
|
CredentialList, ProjectList, LookUpInit, md5Setup, ParseTypeChange, Wait,
|
||||||
@@ -583,6 +583,15 @@ export function JobTemplatesAdd($filter, $scope, $rootScope, $compile,
|
|||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
$scope.$emit('templateSaveSuccess', data);
|
$scope.$emit('templateSaveSuccess', data);
|
||||||
|
|
||||||
|
$scope.addedItem = data.id;
|
||||||
|
|
||||||
|
Refresh({
|
||||||
|
scope: $scope,
|
||||||
|
set: 'job_templates',
|
||||||
|
iterator: 'job_template',
|
||||||
|
url: $scope.current_url
|
||||||
|
});
|
||||||
|
|
||||||
if(data.survey_enabled===true){
|
if(data.survey_enabled===true){
|
||||||
//once the job template information is saved we submit the survey info to the correct endpoint
|
//once the job template information is saved we submit the survey info to the correct endpoint
|
||||||
var url = data.url+ 'survey_spec/';
|
var url = data.url+ 'survey_spec/';
|
||||||
@@ -656,7 +665,7 @@ export function JobTemplatesAdd($filter, $scope, $rootScope, $compile,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JobTemplatesAdd.$inject = ['$filter', '$scope', '$rootScope', '$compile',
|
JobTemplatesAdd.$inject = ['Refresh', '$filter', '$scope', '$rootScope', '$compile',
|
||||||
'$location', '$log', '$stateParams', 'JobTemplateForm', 'GenerateForm',
|
'$location', '$log', '$stateParams', 'JobTemplateForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'ReturnToCaller', 'ClearScope',
|
'Rest', 'Alert', 'ProcessErrors', 'ReturnToCaller', 'ClearScope',
|
||||||
'GetBasePath', 'InventoryList', 'CredentialList', 'ProjectList',
|
'GetBasePath', 'InventoryList', 'CredentialList', 'ProjectList',
|
||||||
|
|||||||
@@ -309,15 +309,6 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams,
|
|||||||
});
|
});
|
||||||
|
|
||||||
$scope.cancelUpdate = function (id, name) {
|
$scope.cancelUpdate = function (id, name) {
|
||||||
// // Start the cancel process
|
|
||||||
// var i, project, found = false;
|
|
||||||
// for (i = 0; i < $scope.projects.length; i++) {
|
|
||||||
// if ($scope.projects[i].id === id) {
|
|
||||||
// project = $scope.projects[i];
|
|
||||||
// found = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
Rest.setUrl(GetBasePath("projects") + id);
|
Rest.setUrl(GetBasePath("projects") + id);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
@@ -343,14 +334,6 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams,
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.refresh = function () {
|
$scope.refresh = function () {
|
||||||
/*Wait('start');
|
|
||||||
$scope.projectLoading = false;
|
|
||||||
Refresh({
|
|
||||||
scope: $scope,
|
|
||||||
set: 'projects',
|
|
||||||
iterator: 'project',
|
|
||||||
url: $scope.current_url
|
|
||||||
});*/
|
|
||||||
$scope.search(list.iterator);
|
$scope.search(list.iterator);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -398,7 +381,7 @@ ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log',
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
export function ProjectsAdd($scope, $rootScope, $compile, $location, $log,
|
export function ProjectsAdd(Refresh, $scope, $rootScope, $compile, $location, $log,
|
||||||
$stateParams, ProjectsForm, GenerateForm, Rest, Alert, ProcessErrors,
|
$stateParams, ProjectsForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||||
ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit,
|
ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit,
|
||||||
OrganizationList, CredentialList, GetChoices, DebugForm, Wait, $state) {
|
OrganizationList, CredentialList, GetChoices, DebugForm, Wait, $state) {
|
||||||
@@ -489,6 +472,15 @@ export function ProjectsAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
|
$scope.addedItem = data.id;
|
||||||
|
|
||||||
|
Refresh({
|
||||||
|
scope: $scope,
|
||||||
|
set: 'projects',
|
||||||
|
iterator: 'project',
|
||||||
|
url: $scope.current_url
|
||||||
|
});
|
||||||
|
|
||||||
var id = data.id,
|
var id = data.id,
|
||||||
url = GetBasePath('projects') + id + '/organizations/',
|
url = GetBasePath('projects') + id + '/organizations/',
|
||||||
org = { id: $scope.organization };
|
org = { id: $scope.organization };
|
||||||
@@ -530,7 +522,7 @@ export function ProjectsAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log',
|
ProjectsAdd.$inject = ['Refresh', '$scope', '$rootScope', '$compile', '$location', '$log',
|
||||||
'$stateParams', 'ProjectsForm', 'GenerateForm', 'Rest', 'Alert',
|
'$stateParams', 'ProjectsForm', 'GenerateForm', 'Rest', 'Alert',
|
||||||
'ProcessErrors', 'ClearScope', 'GetBasePath', 'ReturnToCaller',
|
'ProcessErrors', 'ClearScope', 'GetBasePath', 'ReturnToCaller',
|
||||||
'GetProjectPath', 'LookUpInit', 'OrganizationList', 'CredentialList',
|
'GetProjectPath', 'LookUpInit', 'OrganizationList', 'CredentialList',
|
||||||
|
|||||||
@@ -190,8 +190,8 @@ angular.module('CredentialsHelper', ['Utilities'])
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
.factory('FormSave', ['$location', 'Alert', 'Rest', 'ProcessErrors', 'Empty', 'GetBasePath', 'CredentialForm', 'ReturnToCaller', 'Wait',
|
.factory('FormSave', ['Refresh', '$location', 'Alert', 'Rest', 'ProcessErrors', 'Empty', 'GetBasePath', 'CredentialForm', 'ReturnToCaller', 'Wait',
|
||||||
function ($location, Alert, Rest, ProcessErrors, Empty, GetBasePath, CredentialForm, ReturnToCaller, Wait) {
|
function (Refresh, $location, Alert, Rest, ProcessErrors, Empty, GetBasePath, CredentialForm, ReturnToCaller, Wait) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
mode = params.mode,
|
mode = params.mode,
|
||||||
@@ -254,7 +254,16 @@ angular.module('CredentialsHelper', ['Utilities'])
|
|||||||
GetBasePath('users') + data.user + '/credentials/';
|
GetBasePath('users') + data.user + '/credentials/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success(function () {
|
.success(function (data) {
|
||||||
|
scope.addedItem = data.id;
|
||||||
|
|
||||||
|
Refresh({
|
||||||
|
scope: scope,
|
||||||
|
set: 'credentials',
|
||||||
|
iterator: 'credential',
|
||||||
|
url: url
|
||||||
|
});
|
||||||
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
var base = $location.path().replace(/^\//, '').split('/')[0];
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
if (base === 'credentials') {
|
if (base === 'credentials') {
|
||||||
|
|||||||
@@ -69,7 +69,16 @@ export default
|
|||||||
|
|
||||||
// if you're editing an object, make sure you're on the right
|
// if you're editing an object, make sure you're on the right
|
||||||
// page to display the element you are editing
|
// page to display the element you are editing
|
||||||
if ($location.$$url.split("/")[1] === params.set && $location.$$url.split("/")[2] && !scope.getNewPage) {
|
if (scope.addedItem) {
|
||||||
|
var id = scope.addedItem + "";
|
||||||
|
delete scope.addedItem;
|
||||||
|
var restUrl = params.url.split("?")[0];
|
||||||
|
var pageSize = scope[iterator + '_page_size'];
|
||||||
|
pagination.getInitialPageForList(id, restUrl, pageSize)
|
||||||
|
.then(function (currentPage) {
|
||||||
|
scope.getPage(currentPage, set, iterator);
|
||||||
|
});
|
||||||
|
} else if ($location.$$url.split("/")[1] === params.set && $location.$$url.split("/")[2] && $location.$$url.split("/")[2] !== "add" && !scope.getNewPage) {
|
||||||
var id = $location.$$url.split("/")[2];
|
var id = $location.$$url.split("/")[2];
|
||||||
var restUrl = params.url.split("?")[0];
|
var restUrl = params.url.split("?")[0];
|
||||||
var pageSize = scope[iterator + '_page_size'];
|
var pageSize = scope[iterator + '_page_size'];
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default
|
export default
|
||||||
[ '$compile','SchedulerInit', 'Rest', 'Wait',
|
[ '$rootScope', 'pagination', '$compile','SchedulerInit', 'Rest', 'Wait',
|
||||||
'inventoryScriptsFormObject', 'ProcessErrors', 'GetBasePath', 'Empty',
|
'inventoryScriptsFormObject', 'ProcessErrors', 'GetBasePath', 'Empty',
|
||||||
'GenerateForm', 'SearchInit' , 'PaginateInit',
|
'GenerateForm', 'SearchInit' , 'PaginateInit',
|
||||||
'LookUpInit', 'OrganizationList', '$scope', '$state',
|
'LookUpInit', 'OrganizationList', '$scope', '$state',
|
||||||
function(
|
function(
|
||||||
$compile, SchedulerInit, Rest, Wait,
|
$rootScope, pagination, $compile, SchedulerInit, Rest, Wait,
|
||||||
inventoryScriptsFormObject, ProcessErrors, GetBasePath, Empty,
|
inventoryScriptsFormObject, ProcessErrors, GetBasePath, Empty,
|
||||||
GenerateForm, SearchInit, PaginateInit,
|
GenerateForm, SearchInit, PaginateInit,
|
||||||
LookUpInit, OrganizationList, $scope, $state
|
LookUpInit, OrganizationList, $scope, $state
|
||||||
@@ -38,6 +38,7 @@ export default
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
@@ -47,10 +48,10 @@ export default
|
|||||||
organization: scope.organization,
|
organization: scope.organization,
|
||||||
script: scope.script
|
script: scope.script
|
||||||
})
|
})
|
||||||
.success(function () {
|
.success(function (data) {
|
||||||
$state.transitionTo('inventoryScriptsList');
|
$rootScope.addedItem = data.id;
|
||||||
|
$state.go('inventoryScripts', {}, {reload: true});
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ export default
|
|||||||
list: list,
|
list: list,
|
||||||
url: defaultUrl
|
url: defaultUrl
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($rootScope.addedItem) {
|
||||||
|
scope.addedItem = $rootScope.addedItem;
|
||||||
|
delete $rootScope.addedItem;
|
||||||
|
}
|
||||||
PaginateInit({
|
PaginateInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
list: list,
|
list: list,
|
||||||
|
|||||||
@@ -942,17 +942,17 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += (field.awSurveyQuestion) ? "aw-survey-question" : "";
|
html += (field.awSurveyQuestion) ? "aw-survey-question" : "";
|
||||||
|
|
||||||
if (field.ngDisabled || field.ask) {
|
if (field.ngDisabled || field.ask) {
|
||||||
var disabled = "";
|
var _disabled = "";
|
||||||
if (field.ngDisabled) {
|
if (field.ngDisabled) {
|
||||||
disabled += field.ngDisabled;
|
_disabled += field.ngDisabled;
|
||||||
}
|
}
|
||||||
if (field.ngDisabled && field.ask) {
|
if (field.ngDisabled && field.ask) {
|
||||||
disabled += " || ";
|
_disabled += " || ";
|
||||||
}
|
}
|
||||||
if (field.ask) {
|
if (field.ask) {
|
||||||
disabled += fld + "_ask";
|
_disabled += fld + "_ask";
|
||||||
}
|
}
|
||||||
html += "ng-disabled='" + disabled + "'";
|
html += "ng-disabled='" + _disabled + "'";
|
||||||
}
|
}
|
||||||
html += (field.autocomplete !== undefined) ? this.attr(field, 'autocomplete') : "";
|
html += (field.autocomplete !== undefined) ? this.attr(field, 'autocomplete') : "";
|
||||||
html += (field.awRequiredWhen) ? "data-awrequired-init='" + field.awRequiredWhen.init + "' aw-required-when='" +
|
html += (field.awRequiredWhen) ? "data-awrequired-init='" + field.awRequiredWhen.init + "' aw-required-when='" +
|
||||||
|
|||||||
Reference in New Issue
Block a user