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

BPS Git Server git at git.bestpractical.com
Fri Jul 14 15:32:56 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  35b3e27ee86110a4a40649d63f0599116a66016f (commit)

- Log -----------------------------------------------------------------
commit 35b3e27ee86110a4a40649d63f0599116a66016f
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 4fa5bae7ae..78c3349f76 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -237,6 +237,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