add Lists.select() and make filter dialogs use it

This commit is contained in:
Andrew Dolgov 2018-12-06 09:52:12 +03:00
parent 40204618bf
commit 0e25f5d512
3 changed files with 21 additions and 33 deletions

View File

@ -282,24 +282,10 @@ define(["dojo/_base/declare"], function (declare) {
Filters.editFilterTest(query);
},
selectRules: function (select) {
$$("#filterDlg_Matches input[type=checkbox]").each(function (e) {
e.checked = select;
if (select)
e.parentNode.addClassName("Selected");
else
e.parentNode.removeClassName("Selected");
});
Lists.select("filterDlg_Matches", select);
},
selectActions: function (select) {
$$("#filterDlg_Actions input[type=checkbox]").each(function (e) {
e.checked = select;
if (select)
e.parentNode.addClassName("Selected");
else
e.parentNode.removeClassName("Selected");
});
Lists.select("filterDlg_Actions", select);
},
editRule: function (e) {
const li = e.parentNode;

View File

@ -153,24 +153,10 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
Filters.editFilterTest(query);
},
selectRules: function (select) {
$$("#filterDlg_Matches input[type=checkbox]").each(function (e) {
e.checked = select;
if (select)
e.parentNode.addClassName("Selected");
else
e.parentNode.removeClassName("Selected");
});
Lists.select("filterDlg_Matches", select);
},
selectActions: function (select) {
$$("#filterDlg_Actions input[type=checkbox]").each(function (e) {
e.checked = select;
if (select)
e.parentNode.addClassName("Selected");
else
e.parentNode.removeClassName("Selected");
});
Lists.select("filterDlg_Actions", select);
},
editRule: function (e) {
const li = e.parentNode;

View File

@ -56,7 +56,23 @@ const Lists = {
if (row)
checked ? row.addClassName("Selected") : row.removeClassName("Selected");
}
},
select: function(elemId, selected) {
$(elemId).select("li").each((row) => {
const checkNode = row.select(".dijitCheckBox,input[type=checkbox]")[0];
if (checkNode) {
const widget = dijit.getEnclosingWidget(checkNode);
if (widget) {
widget.attr("checked", selected);
} else {
checkNode.checked = selected;
}
this.onRowChecked(widget);
}
});
},
};
// noinspection JSUnusedGlobalSymbols