diff --git a/InvenTree/templates/InvenTree/notifications/notifications.html b/InvenTree/templates/InvenTree/notifications/notifications.html index cd48584d71..14d9fc49ab 100644 --- a/InvenTree/templates/InvenTree/notifications/notifications.html +++ b/InvenTree/templates/InvenTree/notifications/notifications.html @@ -22,6 +22,11 @@ {% block js_ready %} {{ block.super }} +function updateNotificationTables() { + $("#inbox-table").bootstrapTable('refresh'); + $("#history-table").bootstrapTable('refresh'); +} + function loadNotificationTable(table, options={}) { var params = options.params || {}; @@ -82,7 +87,16 @@ function loadNotificationTable(table, options={}) { }, { formatter: function(value, row, index, field) { - var bRead = ""; + if (row.read) { + var bReadText = '{% trans "Mark as unread" %}'; + var bReadIcon = 'fa-uncheck icon-red'; + var bReadTarget = 'unread'; + } else { + var bReadText = '{% trans "Mark as read" %}'; + var bReadIcon = 'fa-check icon-green'; + var bReadTarget = 'read'; + } + var bRead = ``; var html = "
" + bRead + "
"; return html; } @@ -91,13 +105,11 @@ function loadNotificationTable(table, options={}) { }); $(table).on('click', '.notification-read', function() { - var url = "/api/notifications/" + $(this).attr('pk') + "/read/"; + var url = `/api/notifications/${$(this).attr('pk')}/${$(this).attr('target')}/`; inventreePut(url, {}, { method: 'POST', - success: function() { - $(table).bootstrapTable('refresh'); - } + success: function() { updateNotificationTables(); } }); }); }