[Bps-public-commit] rt-extension-selectize branch, master, updated. 686e156b4a3bf81d999d44ac6c97f064ca731d39

? sunnavy sunnavy at bestpractical.com
Wed May 8 17:17:06 EDT 2019


The branch, master has been updated
       via  686e156b4a3bf81d999d44ac6c97f064ca731d39 (commit)
      from  575efcb6fe7a3eb6ce8ab73b4807dc0bcc9e9410 (commit)

Summary of changes:
 META.yml                                           |   2 +-
 Makefile.PL                                        |   2 +-
 README                                             |   7 +-
 lib/RT/Extension/Selectize.pm                      |   7 +-
 ...recipients-update-a-little-bit-to-get-for.patch | 103 +++++++++++++++++++++
 ...me-inputs-back-to-checkboxes-on-ticket-up.patch |  73 +++++++++++++++
 6 files changed, 190 insertions(+), 4 deletions(-)
 create mode 100644 patches/Defer-AJAX-recipients-update-a-little-bit-to-get-for.patch
 create mode 100644 patches/Sync-one-time-inputs-back-to-checkboxes-on-ticket-up.patch

- Log -----------------------------------------------------------------
commit 686e156b4a3bf81d999d44ac6c97f064ca731d39
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu May 9 04:53:13 2019 +0800

    Add related fixes to ticket update page for RT 4.4.3/4.4.4 and require 4.4.3+
    
    RT 4.4.2 and prior versions have other issues of AJAX recipients update,
    which were fixed in 4.4.3.

diff --git a/META.yml b/META.yml
index 372b0fd..b2db485 100644
--- a/META.yml
+++ b/META.yml
@@ -25,5 +25,5 @@ resources:
   repository: https://github.com/bestpractical/rt-extension-selectize
 version: '0.01'
 x_module_install_rtx_version: '0.40'
-x_requires_rt: 4.2.0
+x_requires_rt: 4.4.3
 x_rt_too_new: 4.6.0
diff --git a/Makefile.PL b/Makefile.PL
index 07991c5..e2fb0f3 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,7 +4,7 @@ RTx     'RT-Extension-Selectize';
 license 'gpl_2';
 repository 'https://github.com/bestpractical/rt-extension-selectize';
 
-requires_rt '4.2.0';
+requires_rt '4.4.3';
 rt_too_new '4.6.0';
 
 sign;
diff --git a/README b/README
index 800679f..ba30def 100644
--- a/README
+++ b/README
@@ -8,7 +8,7 @@ DESCRIPTION
     drag/drop/delete delete them.
 
 RT VERSION
-    Works with RT 4.4
+    Works with RT 4.4.3+
 
 INSTALLATION
     perl Makefile.PL
@@ -21,6 +21,11 @@ INSTALLATION
             patch -p1 -d /opt/rt4 < patches/Switch-to-Selectize-for-multiple-user-inputs.patch
             patch -p1 -d /opt/rt4 < patches/Add-css-to-Theme.html-for-multiple-user-input-bubble.patch
 
+        For RT 4.4.3 - 4.4.4, apply these:
+
+               patch -p1 -d /opt/rt4 < patches/Sync-one-time-inputs-back-to-checkboxes-on-ticket-up.patch
+               patch -p1 -d /opt/rt4 < patches/Defer-AJAX-recipients-update-a-little-bit-to-get-for.patch
+
     Edit your /opt/rt4/etc/RT_SiteConfig.pm
         Add this line:
 
diff --git a/lib/RT/Extension/Selectize.pm b/lib/RT/Extension/Selectize.pm
index 2a00ba6..3f7d85b 100644
--- a/lib/RT/Extension/Selectize.pm
+++ b/lib/RT/Extension/Selectize.pm
@@ -22,7 +22,7 @@ drag/drop/delete delete them.
 
 =head1 RT VERSION
 
-Works with RT 4.4
+Works with RT 4.4.3+
 
 =head1 INSTALLATION
 
@@ -42,6 +42,11 @@ May need root permissions
     patch -p1 -d /opt/rt4 < patches/Switch-to-Selectize-for-multiple-user-inputs.patch
     patch -p1 -d /opt/rt4 < patches/Add-css-to-Theme.html-for-multiple-user-input-bubble.patch
 
+For RT 4.4.3 - 4.4.4, apply these:
+
+       patch -p1 -d /opt/rt4 < patches/Sync-one-time-inputs-back-to-checkboxes-on-ticket-up.patch
+       patch -p1 -d /opt/rt4 < patches/Defer-AJAX-recipients-update-a-little-bit-to-get-for.patch
+
 =item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
 
 Add this line:
diff --git a/patches/Defer-AJAX-recipients-update-a-little-bit-to-get-for.patch b/patches/Defer-AJAX-recipients-update-a-little-bit-to-get-for.patch
new file mode 100644
index 0000000..2525e63
--- /dev/null
+++ b/patches/Defer-AJAX-recipients-update-a-little-bit-to-get-for.patch
@@ -0,0 +1,103 @@
+From 035dd991a95e6f466dde8497d488e76998a4b69e Mon Sep 17 00:00:00 2001
+From: sunnavy <sunnavy at bestpractical.com>
+Date: Thu, 21 Feb 2019 03:57:53 +0800
+Subject: [PATCH] Defer AJAX recipients update a little bit to get form's
+ latest status
+
+We fire updateScrips on input changes, including UpdateType, Status,
+Owner, UpdateCc, UpdateBcc, UpdateContent, etc. Most text input changes
+are triggered when we focus on other elements of the page, and things
+become tricky if the other elemnts are recipient checkboxes, e.g.
+
+    1. Add some text to the message body(the plain textarea)
+    2. Check or uncheck one of the checkboxes in recipient list
+
+The 2nd step not only changes the checkbox's status, but as the focus
+changes from textarea to checkbox, updateScrips is also fired.
+
+The bad thing is the focus change happens right before the checkbox
+status change, thus updateScrips is fired a little bit earlier. When we
+serialize inputs in updateScrips, we can only get the old status of the
+checkbox.
+
+This commit fixes this issue by deferring the serialization a little bit
+to get the latest status of the form.
+---
+ share/html/Ticket/Update.html | 59 +++++++++++++++++++----------------
+ 1 file changed, 32 insertions(+), 27 deletions(-)
+
+diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
+index e7dd715d38..056b11a32e 100644
+--- a/share/html/Ticket/Update.html
++++ b/share/html/Ticket/Update.html
+@@ -217,35 +217,40 @@ jQuery( function() {
+        jQuery('#recipients div.titlebox-content').addClass('refreshing');
+        jQuery('#previewscrips div.titlebox-content').addClass('refreshing');
+ 
+-       var payload = jQuery('form[name=TicketUpdate]').serializeArray();
+-
+-       jQuery('#recipients div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/ShowSimplifiedRecipients',
+-           payload,
+-           function() {
+-               jQuery('#recipients div.titlebox-content').removeClass('refreshing');
+-               var txn_send_field = jQuery("#recipients input[name=TxnSendMailTo]");
+-               txn_send_field.change( syncCheckboxes );
+-               txn_send_field.click( function () { setCheckbox(this) } );
+-               jQuery("#recipients input[name=TxnSendMailToAll]").click( function() { setCheckbox(this, 'TxnSendMailTo'); } );
+-               if (txn_send_field.length > 0) {
+-                   setCheckbox(txn_send_field[0]);
++       // Wait a little bit in case user leaves related inputs(which
++       // could fire updateScrips) by checking/unchecking recipient
++       // checkboxes, this is to get checkboxes' latest status
++       setTimeout( function() {
++           var payload = jQuery('form[name=TicketUpdate]').serializeArray();
++
++           jQuery('#recipients div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/ShowSimplifiedRecipients',
++               payload,
++               function() {
++                   jQuery('#recipients div.titlebox-content').removeClass('refreshing');
++                   var txn_send_field = jQuery("#recipients input[name=TxnSendMailTo]");
++                   txn_send_field.change( syncCheckboxes );
++                   txn_send_field.click( function () { setCheckbox(this) } );
++                   jQuery("#recipients input[name=TxnSendMailToAll]").click( function() { setCheckbox(this, 'TxnSendMailTo'); } );
++                   if (txn_send_field.length > 0) {
++                       setCheckbox(txn_send_field[0]);
++                   }
+                }
+-           }
+-       );
+-
+-       jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
+-           payload,
+-           function() {
+-               jQuery('#previewscrips div.titlebox-content').removeClass('refreshing');
+-               var txn_send_field = jQuery("#previewscrips input[name=TxnSendMailTo]");
+-               txn_send_field.change( syncCheckboxes );
+-               txn_send_field.click( function () { setCheckbox(this) } );
+-               jQuery("#previewscrips input[name=TxnSendMailToAll]").click( function() { setCheckbox(this, 'TxnSendMailTo'); } );
+-               if (txn_send_field.length > 0) {
+-                   setCheckbox(txn_send_field[0]);
++           );
++
++           jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
++               payload,
++               function() {
++                   jQuery('#previewscrips div.titlebox-content').removeClass('refreshing');
++                   var txn_send_field = jQuery("#previewscrips input[name=TxnSendMailTo]");
++                   txn_send_field.change( syncCheckboxes );
++                   txn_send_field.click( function () { setCheckbox(this) } );
++                   jQuery("#previewscrips input[name=TxnSendMailToAll]").click( function() { setCheckbox(this, 'TxnSendMailTo'); } );
++                   if (txn_send_field.length > 0) {
++                       setCheckbox(txn_send_field[0]);
++                   }
+                }
+-           }
+-       );
++           );
++       }, 100);
+    };
+    updateScrips();
+ 
+-- 
+2.20.1 (Apple Git-117)
+
diff --git a/patches/Sync-one-time-inputs-back-to-checkboxes-on-ticket-up.patch b/patches/Sync-one-time-inputs-back-to-checkboxes-on-ticket-up.patch
new file mode 100644
index 0000000..f3d592a
--- /dev/null
+++ b/patches/Sync-one-time-inputs-back-to-checkboxes-on-ticket-up.patch
@@ -0,0 +1,73 @@
+From 24818eb8396242e8573bba566a51daa8eb064a1b Mon Sep 17 00:00:00 2001
+From: sunnavy <sunnavy at bestpractical.com>
+Date: Wed, 27 Feb 2019 23:56:38 +0800
+Subject: [PATCH] Sync one time inputs back to checkboxes on ticket update page
+
+For one-time checkboxes on ticket update page, we update corresponding
+one-time text inputs accordingly when user clicking those checkboxes.
+
+Previously we didn't do it reversely, i.e we don't update those
+checkboxes on text inputs change, which could be surprising for people.
+
+This commit does this "reverse" thing to make things more consistent.
+---
+ share/html/Ticket/Update.html | 43 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 43 insertions(+)
+
+diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
+index e7dd715d38..23d79201b4 100644
+--- a/share/html/Ticket/Update.html
++++ b/share/html/Ticket/Update.html
+@@ -258,6 +258,49 @@ jQuery( function() {
+ 
+    jQuery("#ticket-update-metadata :input, #UpdateCc, #UpdateBcc").change( updateScrips );
+ 
++   var syncOneTimeCheckboxes = function() {
++        var emails = jQuery(this).val().split(/,\s*/);
++        var prefix = jQuery(this).attr('id');
++        var type = prefix.replace('Update', '');
++        var checked = 0;
++        var unchecked = 0;
++        jQuery('input:checkbox[name^=' + prefix + ']').each( function() {
++            var name = jQuery(this).attr('name');
++            name = name.replace(prefix + '-', '');
++            var filter_function = function(n,i) {
++                return n.match(new RegExp('^\\s*' + name + '\\s*$', 'i')) || n.match(new RegExp('<\\s*' + name + '\\s*>', 'i'));
++            };
++            if ( jQuery.grep(emails, filter_function).length == 0 ) {
++                unchecked++;
++                if ( jQuery(this).prop('checked') ) {
++                    jQuery(this).prop('checked', false);
++                }
++            }
++            else {
++                checked++;
++                if ( !jQuery(this).prop('checked') ) {
++                    jQuery(this).prop('checked', true);
++                    if ( jQuery('#UpdateIgnoreAddressCheckboxes').val() == 0 ) {
++                        jQuery('#UpdateIgnoreAddressCheckboxes').val(1);
++                    }
++                }
++            }
++        });
++
++        if ( unchecked > 0 ) {
++            if ( jQuery('#AllSuggested' + type).is(':checked') ) {
++                jQuery('#AllSuggested' + type).prop('checked', false);
++            }
++        }
++        else if ( checked > 0 && unchecked == 0 ) {
++            if ( !jQuery('#AllSuggested' + type).is(':checked') ) {
++                jQuery('#AllSuggested' + type).prop('checked', true);
++            }
++        }
++   };
++
++   jQuery("#UpdateCc, #UpdateBcc").change(syncOneTimeCheckboxes);
++
+ });
+ </script>
+ % }
+-- 
+2.20.1 (Apple Git-117)
+

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


More information about the Bps-public-commit mailing list