Browse Source

Merge pull request #8218 from Piccirello/webui-selection-bug

Reselect webui torrents after full_update. Temporary fix for #8209.
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
6f7f7d87c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/webui/www/private/scripts/client.js
  2. 22
      src/webui/www/private/scripts/dynamicTable.js

6
src/webui/www/private/scripts/client.js

@ -298,9 +298,11 @@ window.addEvent('load', function () {
onSuccess : function (response) { onSuccess : function (response) {
$('error_div').set('html', ''); $('error_div').set('html', '');
if (response) { if (response) {
var torrentsTableSelectedRows;
var update_categories = false; var update_categories = false;
var full_update = (response['full_update'] === true); var full_update = (response['full_update'] === true);
if (full_update) { if (full_update) {
torrentsTableSelectedRows = torrentsTable.selectedRowsIds();
torrentsTable.clear(); torrentsTable.clear();
category_list = {}; category_list = {};
} }
@ -357,6 +359,10 @@ window.addEvent('load', function () {
updateCategoryList(); updateCategoryList();
torrentsTableContextMenu.updateCategoriesSubMenu(category_list); torrentsTableContextMenu.updateCategoriesSubMenu(category_list);
} }
if (full_update)
// re-select previously selected rows
torrentsTable.reselectRows(torrentsTableSelectedRows);
} }
clearTimeout(syncMainDataTimer); clearTimeout(syncMainDataTimer);
syncMainDataTimer = syncMainData.delay(syncMainDataTimerPeriod); syncMainDataTimer = syncMainData.delay(syncMainDataTimerPeriod);

22
src/webui/www/private/scripts/dynamicTable.js

@ -489,22 +489,26 @@ var DynamicTable = new Class({
}, },
selectRow : function (rowId) { selectRow : function (rowId) {
this.selectedRows.empty(); this.deselectAll();
this.selectedRows.push(rowId); this.selectedRows.push(rowId);
var trs = this.tableBody.getElements('tr'); this.tableBody.getElements('tr').each(function(tr) {
for (var i = 0; i < trs.length; i++) { if (tr.rowId == rowId)
var tr = trs[i];
if (tr.rowId == rowId) {
if (!tr.hasClass('selected'))
tr.addClass('selected'); tr.addClass('selected');
}
else else
if (tr.hasClass('selected'))
tr.removeClass('selected'); tr.removeClass('selected');
} });
this.onSelectedRowChanged(); this.onSelectedRowChanged();
}, },
reselectRows : function(rowIds) {
this.deselectAll();
this.selectedRows = rowIds.slice();
this.tableBody.getElements('tr').each(function(tr) {
if (rowIds.indexOf(tr.rowId) > -1)
tr.addClass('selected');
});
},
onSelectedRowChanged : function () {}, onSelectedRowChanged : function () {},
updateRowData : function (data) { updateRowData : function (data) {

Loading…
Cancel
Save