add delete button for notifications

This commit is contained in:
Matthias 2021-11-30 23:19:58 +01:00
parent 679647433a
commit cefc4af861
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -90,7 +90,8 @@ function loadNotificationTable(table, options={}) {
{ {
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
var bRead = getReadEditButton(row.pk, row.read) var bRead = getReadEditButton(row.pk, row.read)
var html = "<div class='btn-group float-right' role='group'>" + bRead + "</div>"; var bDel = "<button title='{% trans "Delete Notification" %}' class='notification-delete btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-trash-alt icon-red'></span></button>";
var html = "<div class='btn-group float-right' role='group'>" + bRead + bDel + "</div>";
return html; return html;
} }
} }
@ -126,5 +127,15 @@ $("#history-refresh").on('click', function() {
$("#history-table").bootstrapTable('refresh'); $("#history-table").bootstrapTable('refresh');
}); });
$("#history-table").on('click', '.notification-delete', function() {
constructForm(`/api/notifications/${$(this).attr('pk')}/`, {
method: 'DELETE',
title: '{% trans "Delete Notification" %}',
onSuccess: function(data) {
updateNotificationTables();
}
});
});
enableSidebar('notifications'); enableSidebar('notifications');
{% endblock %} {% endblock %}