mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-30 03:28:31 -07:00
Remember selected delete state on table redraw
This commit is contained in:
parent
609549f974
commit
41c94741e2
2 changed files with 19 additions and 14 deletions
|
@ -14,7 +14,7 @@
|
||||||
<span><i class="fa fa-history"></i> History</span>
|
<span><i class="fa fa-history"></i> History</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="button-bar">
|
<div class="button-bar">
|
||||||
<span data-toggle="popover" data-placement="left" data-content="Data deleting does not occur until after exiting delete mode." id="delete-message">
|
<span data-toggle="popover" data-placement="left" data-content="Select rows to delete. Data is deleted upon exiting delete mode." id="delete-message">
|
||||||
<button class="btn btn-danger" data-toggle="button" aria-pressed="false" autocomplete="off" id="row-edit-mode">
|
<button class="btn btn-danger" data-toggle="button" aria-pressed="false" autocomplete="off" id="row-edit-mode">
|
||||||
<i class="fa fa-trash-o"></i> Delete mode
|
<i class="fa fa-trash-o"></i> Delete mode
|
||||||
</button> 
|
</button> 
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
|
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" style="text-align: center;">
|
<div class="modal-body" style="text-align: center;">
|
||||||
<p>Are you REALLY sure you want to delete this history?</p>
|
<p>Are you REALLY sure you want to delete <strong><span id="deleteCount"></span></strong> history item(s)?</p>
|
||||||
<p>This is permanent and cannot be undone!</p>
|
<p>This is permanent and cannot be undone!</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -90,22 +90,18 @@
|
||||||
|
|
||||||
clearSearchButton('history_table', history_table);
|
clearSearchButton('history_table', history_table);
|
||||||
|
|
||||||
var history_to_purge = [];
|
|
||||||
$('#row-edit-mode').on('click', function() {
|
$('#row-edit-mode').on('click', function() {
|
||||||
$('#delete-message').popover();
|
$('#delete-message').popover();
|
||||||
|
|
||||||
if ($(this).hasClass('active')) {
|
if ($(this).hasClass('active')) {
|
||||||
history_to_purge = [];
|
if (history_to_delete.length > 0) {
|
||||||
$('.delete-control button.btn-danger').map(function () {
|
$('#deleteCount').text(history_to_delete.length);
|
||||||
history_to_purge.push($(this).attr('data-id'));
|
|
||||||
});
|
|
||||||
if (history_to_purge.length > 0) {
|
|
||||||
$('#confirm-modal').modal();
|
$('#confirm-modal').modal();
|
||||||
$('#confirm-modal').one('click', '#confirm-delete', function () {
|
$('#confirm-modal').one('click', '#confirm-delete', function () {
|
||||||
for (var i = 0; i < history_to_purge.length; i++) {
|
for (var i = 0; i < history_to_delete.length; i++) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'delete_history_rows',
|
url: 'delete_history_rows',
|
||||||
data: { row_id: history_to_purge[i] },
|
data: { row_id: history_to_delete[i] },
|
||||||
async: true,
|
async: true,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
var msg = "User history purged";
|
var msg = "User history purged";
|
||||||
|
@ -123,6 +119,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
history_to_delete = [];
|
||||||
$('.delete-control').each(function() {
|
$('.delete-control').each(function() {
|
||||||
$(this).removeClass('hidden');
|
$(this).removeClass('hidden');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var date_format = 'YYYY-MM-DD';
|
var date_format = 'YYYY-MM-DD';
|
||||||
var time_format = 'hh:mm a';
|
var time_format = 'hh:mm a';
|
||||||
|
var history_to_delete = [];
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'get_date_formats',
|
url: 'get_date_formats',
|
||||||
|
@ -18,7 +19,7 @@ history_table_options = {
|
||||||
"info":"Showing _START_ to _END_ of _TOTAL_ history items",
|
"info":"Showing _START_ to _END_ of _TOTAL_ history items",
|
||||||
"infoEmpty":"Showing 0 to 0 of 0 entries",
|
"infoEmpty":"Showing 0 to 0 of 0 entries",
|
||||||
"infoFiltered":"(filtered from _MAX_ total entries)",
|
"infoFiltered":"(filtered from _MAX_ total entries)",
|
||||||
"emptyTable": "No data in table",
|
"emptyTable": "No data in table"
|
||||||
},
|
},
|
||||||
"pagingType": "bootstrap",
|
"pagingType": "bootstrap",
|
||||||
"stateSave": true,
|
"stateSave": true,
|
||||||
|
@ -238,6 +239,11 @@ history_table_options = {
|
||||||
"preDrawCallback": function(settings) {
|
"preDrawCallback": function(settings) {
|
||||||
var msg = "<div class='msg'><i class='fa fa-refresh fa-spin'></i> Fetching rows...</div>";
|
var msg = "<div class='msg'><i class='fa fa-refresh fa-spin'></i> Fetching rows...</div>";
|
||||||
showMsg(msg, false, false, 0)
|
showMsg(msg, false, false, 0)
|
||||||
|
},
|
||||||
|
"rowCallback": function (row, rowData) {
|
||||||
|
if ($.inArray(rowData['id'], history_to_delete) !== -1) {
|
||||||
|
$(row).find('button[data-id="' + rowData['id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,9 +293,11 @@ $('#history_table').on('click', 'td.delete-control > button', function () {
|
||||||
var row = history_table.row( tr );
|
var row = history_table.row( tr );
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
if ($(this).hasClass('active')) {
|
var index = $.inArray(rowData['id'], history_to_delete);
|
||||||
$(this).toggleClass('btn-warning').toggleClass('btn-danger');
|
if (index === -1) {
|
||||||
|
history_to_delete.push(rowData['id']);
|
||||||
} else {
|
} else {
|
||||||
$(this).toggleClass('btn-danger').toggleClass('btn-warning');
|
history_to_delete.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
$(this).toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue