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

BPS Git Server git at git.bestpractical.com
Tue Sep 12 12:22:24 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  a748b0da38f23f4fcf96df415a092b6efca727b1 (commit)

- Log -----------------------------------------------------------------
commit a748b0da38f23f4fcf96df415a092b6efca727b1
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..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