remove getSelectedTableRowIds (Tables.getSelected)

This commit is contained in:
Andrew Dolgov 2018-12-02 10:46:09 +03:00
parent 874560db54
commit aa2f119eb6
2 changed files with 21 additions and 20 deletions

View File

@ -62,14 +62,30 @@ const Lists = {
}
};
// noinspection JSUnusedGlobalSymbols
const Tables = {
onRowChecked: function(elem) {
// account for dojo checkboxes
elem = elem.domNode || elem;
elem.up("tr").toggleClassName("Selected");
},
getSelected: function(elemId) {
const rv = [];
$(elemId).select("tr").each((row) => {
if (row.hasClassName("Selected")) {
// either older prefix-XXX notation or separate attribute
const rowId = row.getAttribute("data-row-id") || row.id.replace(/^[A-Z]*?-/, "");
if (!isNaN(rowId))
rv.push(parseInt(rowId));
}
});
return rv;
}
}
};
const Utils = {
_rpc_seq: 0,
@ -526,7 +542,7 @@ const CommonDialogs = {
title: __("Feeds with update errors"),
style: "width: 600px",
getSelectedFeeds: function () {
return getSelectedTableRowIds("prefErrorFeedList");
return Tables.getSelected("prefErrorFeedList");
},
removeSelected: function () {
const sel_rows = this.getSelectedFeeds();
@ -1570,21 +1586,6 @@ function selectTableRows(id, mode) {
}
}
function getSelectedTableRowIds(id) {
const rows = [];
const elem_rows = $(id).rows;
for (let i = 0; i < elem_rows.length; i++) {
if (elem_rows[i].hasClassName("Selected")) {
const bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, "");
rows.push(bare_id);
}
}
return rows;
}
// noinspection JSUnusedGlobalSymbols
function label_to_feed_id(label) {
return _label_base_index - 1 - Math.abs(label);

View File

@ -314,7 +314,7 @@ function getSelectedLabels() {
}
function getSelectedUsers() {
return getSelectedTableRowIds("prefUserList");
return Tables.getSelected("prefUserList");
}
function getSelectedFeeds() {
@ -832,7 +832,7 @@ function showInactiveFeeds() {
title: __("Feeds without recent updates"),
style: "width: 600px",
getSelectedFeeds: function () {
return getSelectedTableRowIds("prefInactiveFeedList");
return Tables.getSelected("prefInactiveFeedList");
},
removeSelected: function () {
const sel_rows = this.getSelectedFeeds();
@ -922,7 +922,7 @@ function editProfiles() {
title: __("Settings Profiles"),
style: "width: 600px",
getSelectedProfiles: function () {
return getSelectedTableRowIds("prefFeedProfileList");
return Tables.getSelected("prefFeedProfileList");
},
removeSelected: function () {
const sel_rows = this.getSelectedProfiles();