mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
Fix error where controller was accessing wrong prompt_for_days_form scope.
This commit is contained in:
parent
ffa1f37742
commit
704a2a73c7
@ -30,41 +30,27 @@ export default
|
||||
});
|
||||
};
|
||||
getManagementJobs();
|
||||
var scope = $rootScope.$new();
|
||||
scope.cleanupJob = true;
|
||||
|
||||
$scope.cleanupJob = true;
|
||||
// This handles the case where the user refreshes the management job notifications page.
|
||||
if($state.current.name === 'managementJobsList.notifications') {
|
||||
$scope.activeCard = parseInt($state.params.management_id);
|
||||
$scope.cardAction = "notifications";
|
||||
}
|
||||
|
||||
// Cancel
|
||||
scope.cancelConfigure = function () {
|
||||
try {
|
||||
$('#configure-dialog').dialog('close');
|
||||
$("#configure-save-button").remove();
|
||||
}
|
||||
catch(e) {
|
||||
//ignore
|
||||
}
|
||||
|
||||
Wait('stop');
|
||||
};
|
||||
|
||||
$scope.submitCleanupJob = function(id, name){
|
||||
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
|
||||
CreateDialog({
|
||||
id: 'prompt-for-days-facts',
|
||||
title: name,
|
||||
scope: scope,
|
||||
scope: $scope,
|
||||
width: 500,
|
||||
height: 470,
|
||||
minWidth: 200,
|
||||
callback: 'PromptForDaysFacts',
|
||||
resizable: false,
|
||||
onOpen: function(){
|
||||
scope.$watch('prompt_for_days_facts_form.$invalid', function(invalid) {
|
||||
$scope.$watch('prompt_for_days_facts_form.$invalid', function(invalid) {
|
||||
if (invalid === true) {
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else {
|
||||
@ -72,10 +58,11 @@ export default
|
||||
}
|
||||
});
|
||||
|
||||
var fieldScope = scope.$parent;
|
||||
var fieldScope = $scope.$parent;
|
||||
|
||||
// set these form elements up on the $scope where the form
|
||||
// is the parent of the current $scope
|
||||
|
||||
// set these form elements up on the scope where the form
|
||||
// is the parent of the current scope
|
||||
fieldScope.keep_unit_choices = [{
|
||||
"label" : "Days",
|
||||
"value" : "d"
|
||||
@ -100,9 +87,9 @@ export default
|
||||
"label" : "Years",
|
||||
"value" : "y"
|
||||
}];
|
||||
scope.prompt_for_days_facts_form.$setPristine();
|
||||
scope.prompt_for_days_facts_form.$invalid = false;
|
||||
fieldScope.keep_unit = fieldScope.keep_unit_choices[0];
|
||||
$scope.prompt_for_days_facts_form.$setPristine();
|
||||
$scope.prompt_for_days_facts_form.$invalid = false;
|
||||
fieldScope.keep_unit = fieldScope.keep_unit_choices[0];
|
||||
fieldScope.granularity_keep_unit = fieldScope.granularity_keep_unit_choices[1];
|
||||
fieldScope.keep_amount = 30;
|
||||
fieldScope.granularity_keep_amount = 1;
|
||||
@ -120,8 +107,8 @@ export default
|
||||
"label": "Launch",
|
||||
"onClick": function() {
|
||||
var extra_vars = {
|
||||
"older_than": scope.keep_amount+scope.keep_unit.value,
|
||||
"granularity": scope.granularity_keep_amount+scope.granularity_keep_unit.value
|
||||
"older_than": $scope.keep_amount+$scope.keep_unit.value,
|
||||
"granularity": $scope.granularity_keep_amount+$scope.granularity_keep_unit.value
|
||||
},
|
||||
data = {};
|
||||
data.extra_vars = JSON.stringify(extra_vars);
|
||||
@ -135,9 +122,9 @@ export default
|
||||
$state.go('jobz', { id: data.system_job, type: 'system' }, { reload: true });
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
let template_id = scope.job_template_id;
|
||||
let template_id = $scope.job_template_id;
|
||||
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
|
||||
ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'),
|
||||
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
|
||||
msg: i18n.sprintf(i18n._('Failed updating job %s with variables. POST returned: %d'), template_id, status) });
|
||||
});
|
||||
},
|
||||
@ -147,10 +134,10 @@ export default
|
||||
]
|
||||
});
|
||||
|
||||
if (scope.removePromptForDays) {
|
||||
scope.removePromptForDays();
|
||||
if ($scope.removePromptForDays) {
|
||||
$scope.removePromptForDays();
|
||||
}
|
||||
scope.removePromptForDays = scope.$on('PromptForDaysFacts', function() {
|
||||
$scope.removePromptForDays = $scope.$on('PromptForDaysFacts', function() {
|
||||
// $('#configure-dialog').dialog('close');
|
||||
$('#prompt-for-days-facts').show();
|
||||
$('#prompt-for-days-facts').dialog('open');
|
||||
@ -179,14 +166,14 @@ export default
|
||||
CreateDialog({
|
||||
id: 'prompt-for-days' ,
|
||||
title: name,
|
||||
scope: scope,
|
||||
scope: $scope,
|
||||
width: 500,
|
||||
height: 300,
|
||||
minWidth: 200,
|
||||
callback: 'PromptForDays',
|
||||
resizable: false,
|
||||
onOpen: function(){
|
||||
scope.$watch('prompt_for_days_form.$invalid', function(invalid) {
|
||||
$scope.$watch('prompt_for_days_form.$invalid', function(invalid) {
|
||||
if (invalid === true) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
} else {
|
||||
@ -194,10 +181,10 @@ export default
|
||||
}
|
||||
});
|
||||
|
||||
var fieldScope = scope.$parent;
|
||||
let fieldScope = $scope.$parent;
|
||||
fieldScope.days_to_keep = 30;
|
||||
scope.prompt_for_days_form.$setPristine();
|
||||
scope.prompt_for_days_form.$invalid = false;
|
||||
$scope.prompt_for_days_form.$setPristine();
|
||||
$scope.prompt_for_days_form.$invalid = false;
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
@ -212,7 +199,7 @@ export default
|
||||
{
|
||||
"label": "Launch",
|
||||
"onClick": function() {
|
||||
var extra_vars = {"days": scope.days_to_keep },
|
||||
const extra_vars = {"days": $scope.days_to_keep },
|
||||
data = {};
|
||||
data.extra_vars = JSON.stringify(extra_vars);
|
||||
|
||||
@ -225,9 +212,9 @@ export default
|
||||
$state.go('jobz', { id: data.system_job, type: 'system' }, { reload: true });
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
let template_id = scope.job_template_id;
|
||||
let template_id = $scope.job_template_id;
|
||||
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
|
||||
ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'),
|
||||
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
|
||||
msg: i18n.sprintf(i18n._('Failed updating job %s with variables. POST returned: %d'), template_id, status) });
|
||||
});
|
||||
},
|
||||
@ -237,10 +224,10 @@ export default
|
||||
]
|
||||
});
|
||||
|
||||
if (scope.removePromptForDays) {
|
||||
scope.removePromptForDays();
|
||||
if ($scope.removePromptForDays) {
|
||||
$scope.removePromptForDays();
|
||||
}
|
||||
scope.removePromptForDays = scope.$on('PromptForDays', function() {
|
||||
$scope.removePromptForDays = $scope.$on('PromptForDays', function() {
|
||||
// $('#configure-dialog').dialog('close');
|
||||
$('#prompt-for-days').show();
|
||||
$('#prompt-for-days').dialog('open');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user