mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Merge pull request #617 from jlmitch5/fixAddInteraction
fixed add interaction with lists
This commit is contained in:
commit
bf965027f7
@ -245,7 +245,7 @@ JobTemplatesList.$inject = ['$scope', '$rootScope', '$location', '$log',
|
||||
'$state'
|
||||
];
|
||||
|
||||
export function JobTemplatesAdd($filter, $scope, $rootScope, $compile,
|
||||
export function JobTemplatesAdd(Refresh, $filter, $scope, $rootScope, $compile,
|
||||
$location, $log, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
||||
ProcessErrors, ReturnToCaller, ClearScope, GetBasePath, InventoryList,
|
||||
CredentialList, ProjectList, LookUpInit, md5Setup, ParseTypeChange, Wait,
|
||||
@ -583,6 +583,15 @@ export function JobTemplatesAdd($filter, $scope, $rootScope, $compile,
|
||||
.success(function(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){
|
||||
//once the job template information is saved we submit the survey info to the correct endpoint
|
||||
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',
|
||||
'Rest', 'Alert', 'ProcessErrors', 'ReturnToCaller', 'ClearScope',
|
||||
'GetBasePath', 'InventoryList', 'CredentialList', 'ProjectList',
|
||||
|
@ -309,15 +309,6 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams,
|
||||
});
|
||||
|
||||
$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.get()
|
||||
.success(function (data) {
|
||||
@ -343,14 +334,6 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams,
|
||||
};
|
||||
|
||||
$scope.refresh = function () {
|
||||
/*Wait('start');
|
||||
$scope.projectLoading = false;
|
||||
Refresh({
|
||||
scope: $scope,
|
||||
set: 'projects',
|
||||
iterator: 'project',
|
||||
url: $scope.current_url
|
||||
});*/
|
||||
$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,
|
||||
ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit,
|
||||
OrganizationList, CredentialList, GetChoices, DebugForm, Wait, $state) {
|
||||
@ -489,6 +472,15 @@ export function ProjectsAdd($scope, $rootScope, $compile, $location, $log,
|
||||
Rest.setUrl(url);
|
||||
Rest.post(data)
|
||||
.success(function (data) {
|
||||
$scope.addedItem = data.id;
|
||||
|
||||
Refresh({
|
||||
scope: $scope,
|
||||
set: 'projects',
|
||||
iterator: 'project',
|
||||
url: $scope.current_url
|
||||
});
|
||||
|
||||
var id = data.id,
|
||||
url = GetBasePath('projects') + id + '/organizations/',
|
||||
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',
|
||||
'ProcessErrors', 'ClearScope', 'GetBasePath', 'ReturnToCaller',
|
||||
'GetProjectPath', 'LookUpInit', 'OrganizationList', 'CredentialList',
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name helpers.function:Credentials
|
||||
@ -190,8 +190,8 @@ angular.module('CredentialsHelper', ['Utilities'])
|
||||
}
|
||||
])
|
||||
|
||||
.factory('FormSave', ['$location', 'Alert', 'Rest', 'ProcessErrors', 'Empty', 'GetBasePath', 'CredentialForm', 'ReturnToCaller', 'Wait',
|
||||
function ($location, Alert, Rest, ProcessErrors, Empty, GetBasePath, CredentialForm, ReturnToCaller, Wait) {
|
||||
.factory('FormSave', ['Refresh', '$location', 'Alert', 'Rest', 'ProcessErrors', 'Empty', 'GetBasePath', 'CredentialForm', 'ReturnToCaller', 'Wait',
|
||||
function (Refresh, $location, Alert, Rest, ProcessErrors, Empty, GetBasePath, CredentialForm, ReturnToCaller, Wait) {
|
||||
return function (params) {
|
||||
var scope = params.scope,
|
||||
mode = params.mode,
|
||||
@ -254,7 +254,16 @@ angular.module('CredentialsHelper', ['Utilities'])
|
||||
GetBasePath('users') + data.user + '/credentials/';
|
||||
Rest.setUrl(url);
|
||||
Rest.post(data)
|
||||
.success(function () {
|
||||
.success(function (data) {
|
||||
scope.addedItem = data.id;
|
||||
|
||||
Refresh({
|
||||
scope: scope,
|
||||
set: 'credentials',
|
||||
iterator: 'credential',
|
||||
url: url
|
||||
});
|
||||
|
||||
Wait('stop');
|
||||
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
if (base === 'credentials') {
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name helpers.function:refresh
|
||||
@ -69,7 +69,16 @@ export default
|
||||
|
||||
// if you're editing an object, make sure you're on the right
|
||||
// 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 restUrl = params.url.split("?")[0];
|
||||
var pageSize = scope[iterator + '_page_size'];
|
||||
|
@ -5,12 +5,12 @@
|
||||
*************************************************/
|
||||
|
||||
export default
|
||||
[ '$compile','SchedulerInit', 'Rest', 'Wait',
|
||||
[ '$rootScope', 'pagination', '$compile','SchedulerInit', 'Rest', 'Wait',
|
||||
'inventoryScriptsFormObject', 'ProcessErrors', 'GetBasePath', 'Empty',
|
||||
'GenerateForm', 'SearchInit' , 'PaginateInit',
|
||||
'LookUpInit', 'OrganizationList', '$scope', '$state',
|
||||
function(
|
||||
$compile, SchedulerInit, Rest, Wait,
|
||||
$rootScope, pagination, $compile, SchedulerInit, Rest, Wait,
|
||||
inventoryScriptsFormObject, ProcessErrors, GetBasePath, Empty,
|
||||
GenerateForm, SearchInit, PaginateInit,
|
||||
LookUpInit, OrganizationList, $scope, $state
|
||||
@ -38,6 +38,7 @@ export default
|
||||
|
||||
// Save
|
||||
scope.formSave = function () {
|
||||
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
@ -47,10 +48,10 @@ export default
|
||||
organization: scope.organization,
|
||||
script: scope.script
|
||||
})
|
||||
.success(function () {
|
||||
$state.transitionTo('inventoryScriptsList');
|
||||
.success(function (data) {
|
||||
$rootScope.addedItem = data.id;
|
||||
$state.go('inventoryScripts', {}, {reload: true});
|
||||
Wait('stop');
|
||||
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||
|
@ -29,6 +29,11 @@ export default
|
||||
list: list,
|
||||
url: defaultUrl
|
||||
});
|
||||
|
||||
if ($rootScope.addedItem) {
|
||||
scope.addedItem = $rootScope.addedItem;
|
||||
delete $rootScope.addedItem;
|
||||
}
|
||||
PaginateInit({
|
||||
scope: scope,
|
||||
list: list,
|
||||
|
@ -942,17 +942,17 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
html += (field.awSurveyQuestion) ? "aw-survey-question" : "";
|
||||
|
||||
if (field.ngDisabled || field.ask) {
|
||||
var disabled = "";
|
||||
var _disabled = "";
|
||||
if (field.ngDisabled) {
|
||||
disabled += field.ngDisabled;
|
||||
_disabled += field.ngDisabled;
|
||||
}
|
||||
if (field.ngDisabled && field.ask) {
|
||||
disabled += " || ";
|
||||
_disabled += " || ";
|
||||
}
|
||||
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.awRequiredWhen) ? "data-awrequired-init='" + field.awRequiredWhen.init + "' aw-required-when='" +
|
||||
|
Loading…
Reference in New Issue
Block a user