[Rt-commit] rt branch 5.0/add-checkboxes-multiple-selection created. rt-5.0.4-217-g49ed8fd4e0
BPS Git Server
git at git.bestpractical.com
Tue Sep 12 18:52:46 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/add-checkboxes-multiple-selection has been created
at 49ed8fd4e08b70634a86eb1f2f572fd64f988abc (commit)
- Log -----------------------------------------------------------------
commit 49ed8fd4e08b70634a86eb1f2f572fd64f988abc
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Fri Jul 14 12:30:24 2023 -0300
Allow multiple selection of checkboxes holding shift key
Improve usability of the checkboxes in ticket bulk update form, as
well as in many administration pages, by allowing to select range of
checkboxes by holding shift key.
diff --git a/share/static/css/elevator-light/misc.css b/share/static/css/elevator-light/misc.css
index 6ed4dd5eb1..19c01c6ccf 100644
--- a/share/static/css/elevator-light/misc.css
+++ b/share/static/css/elevator-light/misc.css
@@ -183,3 +183,12 @@ ul.ui-autocomplete {
.modal.search-results-filter .modal-dialog {
margin: 0;
}
+
+/* Enable checkboxes to be selected holding shift key.
+ * On some browsers, javascript "understands" that the parent div is
+ * clicked when holding shift key and not the checkbox itself, causing
+ * the page content to be selected. Increasing the z-index of the checkbox
+ * fixes this issue. */
+input[type="checkbox"] {
+ z-index: 1;
+}
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 1c8a1aa6aa..7e740c121c 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -254,6 +254,32 @@ function checkboxesToInput(target,checkboxes) {
tar.val(emails.join(', ')).change();
}
+// Enable multiple checkbox selection holding shift key
+jQuery(function () {
+ var lastCheckedByName = {};
+ jQuery('input[type=checkbox]').click(function (event) {
+ var name = jQuery(this).attr('name');
+ if (name) {
+ // Remove text after "-" from name for better compatibility
+ // with some fields, such as users members of a group, where
+ // the input name can be DeleteMember-78, DeleteMember-79, etc.
+ name = name.replace(/-.*/, '');
+ var lastChecked = lastCheckedByName[name];
+ if (event.shiftKey && name) {
+ if (lastChecked) {
+ var checkboxes = jQuery('input[type=checkbox][name^=' + name + ']');
+ var start = checkboxes.index(this);
+ var end = checkboxes.index(lastChecked);
+ checkboxes.slice(Math.min(start, end),
+ Math.max(start, end) + 1).prop('checked',
+ this.checked);
+ }
+ }
+ lastCheckedByName[name] = this;
+ }
+ });
+});
+
// ahah for back compatibility as plugins may still use it
function ahah( url, id ) {
jQuery('#'+id).load(url);
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list