Mailing List Archive

rt branch 5.0/add-checkboxes-multiple-selection created. rt-5.0.4-217-g596e2ee0e1
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 596e2ee0e1018b8151ff431d3c4d0ffa8100710d (commit)

- Log -----------------------------------------------------------------
commit 596e2ee0e1018b8151ff431d3c4d0ffa8100710d
Author: Ronaldo Richieri <ronaldo@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..26c87947aa 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -1005,6 +1005,34 @@ jQuery(function() {
);
return false;
});
+
+ // Enable multiple checkbox selection holding shift key
+ var lastCheckedByName = {};
+ jQuery('input[type=checkbox]:not([onclick])').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 checkboxes = jQuery('input[type=checkbox][name^=' + name + ']');
+
+ // multiple checkbox selection is useful only when there are 3+ items
+ if ( checkboxes.length <= 2 ) {
+ return;
+ }
+
+ var lastChecked = lastCheckedByName[name];
+ if (event.shiftKey && name) {
+ if (lastChecked) {
+ 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;
+ }
+ });
});

function filterSearchResults () {

-----------------------------------------------------------------------


hooks/post-receive
--
rt
_______________________________________________
rt-commit mailing list
rt-commit@lists.bestpractical.com
https://lists.bestpractical.com/mailman/listinfo/rt-commit