mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 04:47:44 -02:30
Fixes error thrown when saving various forms: `Cannot set property
'name_api_error' of null` Resolves #3822 & #3832
This commit is contained in:
@@ -414,7 +414,7 @@ ProjectsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log',
|
|||||||
|
|
||||||
|
|
||||||
export function ProjectsEdit($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,
|
Prompt, ClearScope, GetBasePath, GetProjectPath, Authorization,
|
||||||
GetChoices, Empty, DebugForm, Wait, ProjectUpdate, $state, CreateSelect2, ToggleNotification, i18n) {
|
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
|
// Save changes to the parent
|
||||||
$scope.formSave = function() {
|
$scope.formSave = function() {
|
||||||
var fld, i, params;
|
var fld, i, params;
|
||||||
//generator.clearApiErrors();
|
GenerateForm.clearApiErrors($scope);
|
||||||
Wait('start');
|
Wait('start');
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
params = {};
|
params = {};
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ export function TeamsAdd($scope, $rootScope, $stateParams, TeamForm, GenerateFor
|
|||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var defaultUrl = GetBasePath('teams'),
|
var defaultUrl = GetBasePath('teams'),
|
||||||
form = TeamForm,
|
form = TeamForm;
|
||||||
generator = GenerateForm;
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -120,7 +119,7 @@ export function TeamsAdd($scope, $rootScope, $stateParams, TeamForm, GenerateFor
|
|||||||
// Save
|
// Save
|
||||||
$scope.formSave = function() {
|
$scope.formSave = function() {
|
||||||
var fld, data;
|
var fld, data;
|
||||||
generator.clearApiErrors();
|
GenerateForm.clearApiErrors($scope);
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
data = {};
|
data = {};
|
||||||
@@ -216,7 +215,6 @@ export function TeamsEdit($scope, $rootScope, $stateParams,
|
|||||||
$scope.formSave = function() {
|
$scope.formSave = function() {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
if ($scope[form.name + '_form'].$valid) {
|
if ($scope[form.name + '_form'].$valid) {
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
|
||||||
var data = processNewData(form.fields);
|
var data = processNewData(form.fields);
|
||||||
Rest.put(data).success(function() {
|
Rest.put(data).success(function() {
|
||||||
$state.go($state.current, null, { reload: true });
|
$state.go($state.current, null, { reload: true });
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ function adhocController($q, $scope, $location, $stateParams,
|
|||||||
"privilege_escalation": ""
|
"privilege_escalation": ""
|
||||||
};
|
};
|
||||||
|
|
||||||
GenerateForm.clearApiErrors();
|
GenerateForm.clearApiErrors($scope);
|
||||||
|
|
||||||
// populate data with the relevant form values
|
// populate data with the relevant form values
|
||||||
for (fld in adhocForm.fields) {
|
for (fld in adhocForm.fields) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default ['Rest', 'Wait',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.formSave = function() {
|
$scope.formSave = function() {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors($scope);
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(url + id + '/');
|
Rest.setUrl(url + id + '/');
|
||||||
Rest.put({
|
Rest.put({
|
||||||
|
|||||||
@@ -280,7 +280,7 @@
|
|||||||
|
|
||||||
|
|
||||||
function saveCompleted(id) {
|
function saveCompleted(id) {
|
||||||
$state.go('jobTemplates.edit', {id: id}, {reload: true});
|
$state.go('jobTemplates.edit', {job_template_id: id}, {reload: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.removeTemplateSaveSuccess) {
|
if ($scope.removeTemplateSaveSuccess) {
|
||||||
@@ -419,7 +419,7 @@
|
|||||||
$scope.survey_enabled = false;
|
$scope.survey_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors($scope);
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
@@ -501,6 +501,7 @@
|
|||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
console.log(err)
|
||||||
Alert("Error", "Error parsing extra variables. " +
|
Alert("Error", "Error parsing extra variables. " +
|
||||||
"Parser returned: " + err);
|
"Parser returned: " + err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ export default
|
|||||||
$scope.survey_enabled = false;
|
$scope.survey_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors($scope);
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export default ['$rootScope', 'Rest', 'Wait', 'NotificationsFormObject',
|
|||||||
var params,
|
var params,
|
||||||
v = $scope.notification_type.value;
|
v = $scope.notification_type.value;
|
||||||
|
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors($scope);
|
||||||
params = {
|
params = {
|
||||||
"name": $scope.name,
|
"name": $scope.name,
|
||||||
"description": $scope.description,
|
"description": $scope.description,
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ export default ['Rest', 'Wait',
|
|||||||
var params,
|
var params,
|
||||||
v = $scope.notification_type.value;
|
v = $scope.notification_type.value;
|
||||||
|
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors($scope);
|
||||||
params = {
|
params = {
|
||||||
"name": $scope.name,
|
"name": $scope.name,
|
||||||
"description": $scope.description,
|
"description": $scope.description,
|
||||||
|
|||||||
@@ -303,21 +303,21 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
|
|
||||||
clearApiErrors: function () {
|
clearApiErrors: function (scope) {
|
||||||
for (var fld in this.form.fields) {
|
for (var fld in this.form.fields) {
|
||||||
if (this.form.fields[fld].sourceModel) {
|
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');
|
$('[name="' + this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '"]').removeClass('ng-invalid');
|
||||||
} else if (this.form.fields[fld].realName) {
|
} else if (this.form.fields[fld].realName) {
|
||||||
this.scope[this.form.fields[fld].realName + '_api_error'] = '';
|
this.scope[this.form.fields[fld].realName + '_api_error'] = '';
|
||||||
$('[name="' + this.form.fields[fld].realName + '"]').removeClass('ng-invalid');
|
$('[name="' + this.form.fields[fld].realName + '"]').removeClass('ng-invalid');
|
||||||
} else {
|
} else {
|
||||||
this.scope[fld + '_api_error'] = '';
|
scope[fld + '_api_error'] = '';
|
||||||
$('[name="' + fld + '"]').removeClass('ng-invalid');
|
$('[name="' + fld + '"]').removeClass('ng-invalid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.scope.$$phase) {
|
if (!scope.$$phase) {
|
||||||
this.scope.$digest();
|
scope.$digest();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user