mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 00:37:37 -02:30
Refactored formSave to remove old survey logic as well as remove unnecessary event emit.
This commit is contained in:
@@ -323,15 +323,22 @@
|
||||
|
||||
// Save
|
||||
$scope.formSave = function () {
|
||||
var fld, data = {};
|
||||
$scope.invalid_survey = false;
|
||||
if ($scope.removeGatherFormFields) {
|
||||
$scope.removeGatherFormFields();
|
||||
|
||||
// users can't save a survey with a scan job
|
||||
if($scope.job_type.value === "scan" && $scope.survey_enabled === true){
|
||||
$scope.survey_enabled = false;
|
||||
}
|
||||
$scope.removeGatherFormFields = $scope.$on('GatherFormFields', function(e, data) {
|
||||
// Can't have a survey enabled without a survey
|
||||
if($scope.survey_enabled === true && $scope.survey_exists!==true){
|
||||
$scope.survey_enabled = false;
|
||||
}
|
||||
|
||||
generator.clearApiErrors();
|
||||
|
||||
Wait('start');
|
||||
data = {};
|
||||
var fld;
|
||||
|
||||
try {
|
||||
for (fld in form.fields) {
|
||||
if (form.fields[fld].type === 'select' && fld !== 'playbook') {
|
||||
@@ -392,37 +399,6 @@
|
||||
Wait('stop');
|
||||
Alert("Error", "Error parsing extra variables. Parser returned: " + err);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if ($scope.removePromptForSurvey) {
|
||||
$scope.removePromptForSurvey();
|
||||
}
|
||||
$scope.removePromptForSurvey = $scope.$on('PromptForSurvey', function() {
|
||||
var action = function () {
|
||||
// $scope.$emit("GatherFormFields");
|
||||
Wait('start');
|
||||
$('#prompt-modal').modal('hide');
|
||||
$scope.addSurvey();
|
||||
|
||||
};
|
||||
Prompt({
|
||||
hdr: 'Incomplete Survey',
|
||||
body: '<div class="Prompt-bodyQuery">Do you want to create a survey before proceeding?</div>',
|
||||
action: action
|
||||
});
|
||||
});
|
||||
|
||||
// users can't save a survey with a scan job
|
||||
if($scope.job_type.value === "scan" && $scope.survey_enabled === true){
|
||||
$scope.survey_enabled = false;
|
||||
}
|
||||
// Can't have a survey enabled without a survey
|
||||
if($scope.survey_enabled === true && $scope.survey_exists!==true){
|
||||
$scope.survey_enabled = false;
|
||||
}
|
||||
|
||||
$scope.$emit("GatherFormFields");
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -420,15 +420,22 @@ export default
|
||||
|
||||
// Save changes to the parent
|
||||
$scope.formSave = function () {
|
||||
var fld, data = {};
|
||||
$scope.invalid_survey = false;
|
||||
if ($scope.removeGatherFormFields) {
|
||||
$scope.removeGatherFormFields();
|
||||
|
||||
// users can't save a survey with a scan job
|
||||
if($scope.job_type.value === "scan" && $scope.survey_enabled === true){
|
||||
$scope.survey_enabled = false;
|
||||
}
|
||||
$scope.removeGatherFormFields = $scope.$on('GatherFormFields', function(e, data) {
|
||||
// Can't have a survey enabled without a survey
|
||||
if($scope.survey_enabled === true && $scope.survey_exists!==true){
|
||||
$scope.survey_enabled = false;
|
||||
}
|
||||
|
||||
generator.clearApiErrors();
|
||||
|
||||
Wait('start');
|
||||
data = {};
|
||||
var fld;
|
||||
|
||||
try {
|
||||
// Make sure we have valid variable data
|
||||
data.extra_vars = ToJSON($scope.parseType, $scope.variables, true);
|
||||
@@ -458,43 +465,6 @@ export default
|
||||
Wait('stop');
|
||||
Alert("Error", "Error parsing extra variables. Parser returned: " + err);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if ($scope.removePromptForSurvey) {
|
||||
$scope.removePromptForSurvey();
|
||||
}
|
||||
$scope.removePromptForSurvey = $scope.$on('PromptForSurvey', function() {
|
||||
var action = function () {
|
||||
// $scope.$emit("GatherFormFields");
|
||||
Wait('start');
|
||||
$('#prompt-modal').modal('hide');
|
||||
$scope.addSurvey();
|
||||
|
||||
};
|
||||
Prompt({
|
||||
hdr: 'Incomplete Survey',
|
||||
body: '<div class="Prompt-bodyQuery">Do you want to create a survey before proceeding?</div>',
|
||||
action: action
|
||||
});
|
||||
});
|
||||
|
||||
// users can't save a survey with a scan job
|
||||
if($scope.job_type.value === "scan" && $scope.survey_enabled === true){
|
||||
$scope.survey_enabled = false;
|
||||
}
|
||||
if($scope.survey_enabled === true && $scope.survey_exists!==true){
|
||||
// $scope.$emit("PromptForSurvey");
|
||||
|
||||
// The original design for this was a pop up that would prompt the user if they wanted to create a
|
||||
// survey, because they had enabled one but not created it yet. We switched this for now so that
|
||||
// an error message would be displayed by the survey buttons that tells the user to add a survey or disabled
|
||||
// surveys.
|
||||
$scope.invalid_survey = true;
|
||||
return;
|
||||
} else {
|
||||
$scope.$emit("GatherFormFields");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user