[Rt-commit] rt branch 5.0/selectize-one-time-all-recipients created. rt-5.0.4-57-ga71697ebfe
BPS Git Server
git at git.bestpractical.com
Tue Jul 11 17:52:58 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 a71697ebfebd401ee24ca18f3173292e418f431f (commit)
- Log -----------------------------------------------------------------
commit a71697ebfebd401ee24ca18f3173292e418f431f
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 d6ed35cf7d..58a9451d86 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 9f9511d861ec09978381297c7c77affc3065b31a
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Jul 12 01:27:59 2023 +0800
Update selectize when checking/unchecking one-time "All recipients"
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 4fa5bae7ae..d6ed35cf7d 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