[Rt-commit] rt branch 5.0/add-checkboxes-multiple-selection created. rt-5.0.4-217-g68247b8695

BPS Git Server git at git.bestpractical.com
Tue Sep 12 12:03:33 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  68247b8695b82b72b29f48b9890570037f63c156 (commit)

- Log -----------------------------------------------------------------
commit 68247b8695b82b72b29f48b9890570037f63c156
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Jul 14 12:30:24 2023 -0300

    Allow multiple selection of checkboxes holding shift key
    
    Improved 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..ec10f7ab37 100644
--- a/share/static/css/elevator-light/misc.css
+++ b/share/static/css/elevator-light/misc.css
@@ -183,3 +183,8 @@ ul.ui-autocomplete {
 .modal.search-results-filter .modal-dialog {
     margin: 0;
 }
+
+/* Enable checkboxes to be selected holding shift key */
+input[type="checkbox"] {
+    z-index: 1;
+}
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 1c8a1aa6aa..217ee3dfc6 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -254,6 +254,30 @@ 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
+            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