diff --git a/awx/ui/client/src/controllers/Projects.js b/awx/ui/client/src/controllers/Projects.js index e020319223..7cb876d179 100644 --- a/awx/ui/client/src/controllers/Projects.js +++ b/awx/ui/client/src/controllers/Projects.js @@ -414,7 +414,7 @@ ProjectsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', export function ProjectsEdit($scope, $rootScope, $compile, $location, $log, - $stateParams, ProjectsForm, Rest, Alert, ProcessErrors, + $stateParams, ProjectsForm, Rest, Alert, ProcessErrors, GenerateForm, Prompt, ClearScope, GetBasePath, GetProjectPath, Authorization, GetChoices, Empty, DebugForm, Wait, ProjectUpdate, $state, CreateSelect2, ToggleNotification, i18n) { @@ -587,7 +587,7 @@ export function ProjectsEdit($scope, $rootScope, $compile, $location, $log, // Save changes to the parent $scope.formSave = function() { var fld, i, params; - //generator.clearApiErrors(); + GenerateForm.clearApiErrors($scope); Wait('start'); $rootScope.flashMessage = null; params = {}; diff --git a/awx/ui/client/src/controllers/Teams.js b/awx/ui/client/src/controllers/Teams.js index b4ae59fb39..5eb75c4ee3 100644 --- a/awx/ui/client/src/controllers/Teams.js +++ b/awx/ui/client/src/controllers/Teams.js @@ -105,8 +105,7 @@ export function TeamsAdd($scope, $rootScope, $stateParams, TeamForm, GenerateFor // Inject dynamic view var defaultUrl = GetBasePath('teams'), - form = TeamForm, - generator = GenerateForm; + form = TeamForm; init(); @@ -120,7 +119,7 @@ export function TeamsAdd($scope, $rootScope, $stateParams, TeamForm, GenerateFor // Save $scope.formSave = function() { var fld, data; - generator.clearApiErrors(); + GenerateForm.clearApiErrors($scope); Wait('start'); Rest.setUrl(defaultUrl); data = {}; @@ -216,7 +215,6 @@ export function TeamsEdit($scope, $rootScope, $stateParams, $scope.formSave = function() { $rootScope.flashMessage = null; if ($scope[form.name + '_form'].$valid) { - Rest.setUrl(defaultUrl + id + '/'); var data = processNewData(form.fields); Rest.put(data).success(function() { $state.go($state.current, null, { reload: true }); diff --git a/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js b/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js index e749a6d44c..dec6b6397a 100644 --- a/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js +++ b/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js @@ -202,7 +202,7 @@ function adhocController($q, $scope, $location, $stateParams, "privilege_escalation": "" }; - GenerateForm.clearApiErrors(); + GenerateForm.clearApiErrors($scope); // populate data with the relevant form values for (fld in adhocForm.fields) { diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.controller.js b/awx/ui/client/src/inventory-scripts/edit/edit.controller.js index bb4147c083..2dce989b26 100644 --- a/awx/ui/client/src/inventory-scripts/edit/edit.controller.js +++ b/awx/ui/client/src/inventory-scripts/edit/edit.controller.js @@ -50,7 +50,7 @@ export default ['Rest', 'Wait', } $scope.formSave = function() { - generator.clearApiErrors(); + generator.clearApiErrors($scope); Wait('start'); Rest.setUrl(url + id + '/'); Rest.put({ diff --git a/awx/ui/client/src/job-templates/add/job-templates-add.controller.js b/awx/ui/client/src/job-templates/add/job-templates-add.controller.js index 1e7d79d167..f509f9b2fe 100644 --- a/awx/ui/client/src/job-templates/add/job-templates-add.controller.js +++ b/awx/ui/client/src/job-templates/add/job-templates-add.controller.js @@ -280,7 +280,7 @@ function saveCompleted(id) { - $state.go('jobTemplates.edit', {id: id}, {reload: true}); + $state.go('jobTemplates.edit', {job_template_id: id}, {reload: true}); } if ($scope.removeTemplateSaveSuccess) { @@ -419,7 +419,7 @@ $scope.survey_enabled = false; } - generator.clearApiErrors(); + generator.clearApiErrors($scope); Wait('start'); @@ -501,6 +501,7 @@ } catch (err) { Wait('stop'); + console.log(err) Alert("Error", "Error parsing extra variables. " + "Parser returned: " + err); } diff --git a/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js b/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js index be6ea855fc..95d7a8272a 100644 --- a/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js +++ b/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js @@ -542,7 +542,7 @@ export default $scope.survey_enabled = false; } - generator.clearApiErrors(); + generator.clearApiErrors($scope); Wait('start'); diff --git a/awx/ui/client/src/notifications/add/add.controller.js b/awx/ui/client/src/notifications/add/add.controller.js index 80e3d4ed69..1f007c3e2f 100644 --- a/awx/ui/client/src/notifications/add/add.controller.js +++ b/awx/ui/client/src/notifications/add/add.controller.js @@ -120,7 +120,7 @@ export default ['$rootScope', 'Rest', 'Wait', 'NotificationsFormObject', var params, v = $scope.notification_type.value; - generator.clearApiErrors(); + generator.clearApiErrors($scope); params = { "name": $scope.name, "description": $scope.description, diff --git a/awx/ui/client/src/notifications/edit/edit.controller.js b/awx/ui/client/src/notifications/edit/edit.controller.js index c96d930204..57f4a25055 100644 --- a/awx/ui/client/src/notifications/edit/edit.controller.js +++ b/awx/ui/client/src/notifications/edit/edit.controller.js @@ -197,7 +197,7 @@ export default ['Rest', 'Wait', var params, v = $scope.notification_type.value; - generator.clearApiErrors(); + generator.clearApiErrors($scope); params = { "name": $scope.name, "description": $scope.description, diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 3ed0c224a9..af110494b4 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -303,21 +303,21 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat return html; }, - clearApiErrors: function () { + clearApiErrors: function (scope) { for (var fld in this.form.fields) { if (this.form.fields[fld].sourceModel) { - this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '_api_error'] = ''; + scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '_api_error'] = ''; $('[name="' + this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '"]').removeClass('ng-invalid'); } else if (this.form.fields[fld].realName) { this.scope[this.form.fields[fld].realName + '_api_error'] = ''; $('[name="' + this.form.fields[fld].realName + '"]').removeClass('ng-invalid'); } else { - this.scope[fld + '_api_error'] = ''; + scope[fld + '_api_error'] = ''; $('[name="' + fld + '"]').removeClass('ng-invalid'); } } - if (!this.scope.$$phase) { - this.scope.$digest(); + if (!scope.$$phase) { + scope.$digest(); } },