Skip to content

Commit

Permalink
Ref #16602 - Add an unique ID for the notification
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Mar 15, 2021
1 parent 7b124e6 commit 6c28a92
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions js/src/error_report.js
Expand Up @@ -114,19 +114,19 @@ var ErrorReport = {
* @return {void}
*/
showErrorNotification: function () {
var key = Math.random().toString(36).substring(2, 12);
while (key in ErrorReport.keyDict) {
key = Math.random().toString(36).substring(2, 12);
}
ErrorReport.keyDict[key] = 1;

var $div = $(
'<div class="alert alert-danger userPermissionModal error_message" role="alert" id="error_notification"></div>'
'<div class="alert alert-danger userPermissionModal" role="alert" id="error_notification_' + key + '"></div>'
).append(
Functions.getImage('s_error') + Messages.strErrorOccurred
);

var $buttons = $('<div class="float-end"></div>');
var key = Math.random().toString(36).substring(2, 12);
while (key in ErrorReport.keyDict) {
key = Math.random().toString(36).substring(2, 12);
}
ErrorReport.keyDict[key] = 1;
var buttonHtml = '<button class="btn btn-primary" id="show_error_report_' + key + '">';
buttonHtml += Messages.strShowReportDetails;
buttonHtml += '</button>';
Expand All @@ -136,7 +136,7 @@ var ErrorReport = {
buttonHtml += Functions.getImage('s_cog', Messages.strChangeReportSettings);
buttonHtml += '</a>';

buttonHtml += '<a href="#" id="ignore_error_' + key + '">';
buttonHtml += '<a href="#" id="ignore_error_' + key + '" data-notification-id="' + key + '">';
buttonHtml += Functions.getImage('b_close', Messages.strIgnore);
buttonHtml += '</a>';

Expand All @@ -158,7 +158,7 @@ var ErrorReport = {
// don't remove the hash fragment by navigating to #
e.preventDefault();
}
$('.error_message').fadeOut(function () {
$('#error_notification_' + $(this).data('notification-id')).fadeOut(function () {
$(this).remove();
});
},
Expand Down

0 comments on commit 6c28a92

Please sign in to comment.