mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02:30
Fixed Utilities.alert() so that Alert dialog boxes no longer render empty. The issue was one of scope. The alert dialogs exist in the parent scope. Often the scope of the caller is in a child or nested child scope. Alerts now have their own scope and the HTML is compiled just before render.
This commit is contained in:
@@ -192,7 +192,7 @@ angular.module('LookUpHelper', ['RestServices', 'Utilities', 'SearchHelper', 'Pa
|
||||
}
|
||||
if (found === false) {
|
||||
Alert('Missing Selection', 'Oops, you failed to make a selection. Click on a row to make your selection, ' +
|
||||
'and then click the Select button.');
|
||||
'and then click the Select button. Or, click Cancel to quit.');
|
||||
} else {
|
||||
$('#lookup-modal-dialog').dialog('close');
|
||||
if (postAction) {
|
||||
|
||||
@@ -75,57 +75,60 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
||||
* alert-info...). Pass an optional function(){}, if you want a specific action to occur when user
|
||||
* clicks 'OK' button. Set secondAlert to true, when a second dialog is needed.
|
||||
*/
|
||||
.factory('Alert', ['$rootScope',
|
||||
function ($rootScope) {
|
||||
return function (hdr, msg, cls, action, secondAlert, disableButtons) {
|
||||
if (secondAlert) {
|
||||
$rootScope.alertHeader2 = hdr;
|
||||
$rootScope.alertBody2 = msg;
|
||||
$rootScope.alertClass2 = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
||||
$('#alert-modal2').modal({
|
||||
show: true,
|
||||
keyboard: true,
|
||||
backdrop: 'static'
|
||||
});
|
||||
$rootScope.disableButtons2 = (disableButtons) ? true : false;
|
||||
|
||||
$('#alert-modal2').on('hidden.bs.modal', function () {
|
||||
if (action) {
|
||||
action();
|
||||
}
|
||||
});
|
||||
$(document).bind('keydown', function (e) {
|
||||
if (e.keyCode === 27) {
|
||||
$('#alert-modal2').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$rootScope.alertHeader = hdr;
|
||||
$rootScope.alertBody = msg;
|
||||
$rootScope.alertClass = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
||||
$('#alert-modal').modal({
|
||||
show: true,
|
||||
keyboard: true,
|
||||
backdrop: 'static'
|
||||
});
|
||||
.factory('Alert', ['$rootScope', '$compile', function ($rootScope, $compile) {
|
||||
return function (hdr, msg, cls, action, secondAlert, disableButtons) {
|
||||
var scope = $rootScope.$new(), e;
|
||||
if (secondAlert) {
|
||||
scope.alertHeader2 = hdr;
|
||||
scope.alertBody2 = msg;
|
||||
scope.alertClass2 = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
||||
e = angular.element(document.getElementById('alert-modal2'));
|
||||
$compile(e)(scope);
|
||||
$('#alert-modal2').modal({
|
||||
show: true,
|
||||
keyboard: true,
|
||||
backdrop: 'static'
|
||||
});
|
||||
scope.disableButtons2 = (disableButtons) ? true : false;
|
||||
|
||||
$('#alert-modal2').on('hidden.bs.modal', function () {
|
||||
if (action) {
|
||||
action();
|
||||
}
|
||||
});
|
||||
$(document).bind('keydown', function (e) {
|
||||
if (e.keyCode === 27) {
|
||||
$('#alert-modal2').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
scope.alertHeader = hdr;
|
||||
scope.alertBody = msg;
|
||||
scope.alertClass = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
||||
e = angular.element(document.getElementById('alert-modal'));
|
||||
$compile(e)(scope);
|
||||
$('#alert-modal').modal({
|
||||
show: true,
|
||||
keyboard: true,
|
||||
backdrop: 'static'
|
||||
});
|
||||
|
||||
$('#alert-modal').on('hidden.bs.modal', function () {
|
||||
if (action) {
|
||||
action();
|
||||
}
|
||||
});
|
||||
$('#alert-modal').on('hidden.bs.modal', function () {
|
||||
if (action) {
|
||||
action();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).bind('keydown', function (e) {
|
||||
if (e.keyCode === 27) {
|
||||
$('#alert-modal').modal('hide');
|
||||
}
|
||||
});
|
||||
$(document).bind('keydown', function (e) {
|
||||
if (e.keyCode === 27) {
|
||||
$('#alert-modal').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.disableButtons = (disableButtons) ? true : false;
|
||||
}
|
||||
};
|
||||
}
|
||||
])
|
||||
scope.disableButtons = (disableButtons) ? true : false;
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
.factory('ProcessErrors', ['$rootScope', '$cookieStore', '$log', '$location', 'Alert', 'Wait',
|
||||
|
||||
Reference in New Issue
Block a user