[Rt-commit] rt branch 5.0/selectize-one-time-all-recipients created. rt-5.0.4-209-g4d6c6bb89a
BPS Git Server
git at git.bestpractical.com
Fri Sep 8 17:02:03 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/selectize-one-time-all-recipients has been created
at 4d6c6bb89ac6eb82594e353ef4e460bf62907a64 (commit)
- Log -----------------------------------------------------------------
commit 4d6c6bb89ac6eb82594e353ef4e460bf62907a64
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Jul 12 01:47:03 2023 +0800
Make the one-time input values the same order as selectize shows
This is for consistency to avoid confusion.
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 3dc83b65c6..1c8a1aa6aa 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -190,7 +190,7 @@ function checkboxToInput(target,checkbox,val){
if(box.prop('checked')){
if ( emails.indexOf(val) == -1 ) {
- emails.unshift(val);
+ emails.push(val);
}
}
else{
@@ -227,7 +227,7 @@ function checkboxesToInput(target,checkboxes) {
var val = jQuery(checkbox).attr('data-address');
if(jQuery(checkbox).prop('checked')){
if ( emails.indexOf(val) == -1 ) {
- emails.unshift(val);
+ emails.push(val);
added.push(val);
}
}
commit 882044a8918c8b6f3abe891728b3513d620fc1b9
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Jul 12 01:27:59 2023 +0800
Update selectize when checking/unchecking one-time "All recipients"
Previously if you check/uncheck one-time "All recipients" on ticket
update page, the corresponding one-time inputs wouldn't visually change.
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 2a39daa720..3dc83b65c6 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -219,20 +219,37 @@ function checkboxesToInput(target,checkboxes) {
return email.match(/\S/) ? true : false;
});
+ var selectize = tar[0].selectize;
+ var added = [];
+ var removed = [];
+
jQuery(checkboxes).each(function(index, checkbox) {
var val = jQuery(checkbox).attr('data-address');
if(jQuery(checkbox).prop('checked')){
if ( emails.indexOf(val) == -1 ) {
emails.unshift(val);
+ added.push(val);
}
}
else{
emails = jQuery.grep(emails, function(email) {
return email != val;
});
+ removed.push(val);
}
});
+ if ( selectize ) {
+
+ // Add new items in one call to avoid triggering syncOneTimeCheckboxes
+ // multiple times during the update as it could wrongly sync the
+ // incomplete input values back to checkboxes.
+ selectize.addItems(added, true);
+ for ( const item of removed ) {
+ selectize.removeItem(item, true);
+ }
+ }
+
jQuery('#UpdateIgnoreAddressCheckboxes').val(true);
tar.val(emails.join(', ')).change();
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list