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 = { const Tables = {
onRowChecked: function(elem) { onRowChecked: function(elem) {
// account for dojo checkboxes // account for dojo checkboxes
elem = elem.domNode || elem; elem = elem.domNode || elem;
elem.up("tr").toggleClassName("Selected"); 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 = { const Utils = {
_rpc_seq: 0, _rpc_seq: 0,
@ -526,7 +542,7 @@ const CommonDialogs = {
title: __("Feeds with update errors"), title: __("Feeds with update errors"),
style: "width: 600px", style: "width: 600px",
getSelectedFeeds: function () { getSelectedFeeds: function () {
return getSelectedTableRowIds("prefErrorFeedList"); return Tables.getSelected("prefErrorFeedList");
}, },
removeSelected: function () { removeSelected: function () {
const sel_rows = this.getSelectedFeeds(); 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 // noinspection JSUnusedGlobalSymbols
function label_to_feed_id(label) { function label_to_feed_id(label) {
return _label_base_index - 1 - Math.abs(label); return _label_base_index - 1 - Math.abs(label);

View File

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