[Rt-commit] rt branch, 4.4/ajax-preview-scrips, created. rt-4.2.3-205-ge79c9a6

? sunnavy sunnavy at bestpractical.com
Sat Jul 12 04:33:04 EDT 2014


The branch, 4.4/ajax-preview-scrips has been created
        at  e79c9a623320ffb89fe8ba0204c6e95178febf86 (commit)

- Log -----------------------------------------------------------------
commit 9b4394972dc21c1e64899d69a4ca542ebe507d11
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jun 24 23:36:16 2014 +0800

    ajaxify PrviewScrips and ShowSimplifiedRecipients on ticket update page

diff --git a/share/html/Ticket/Elements/PreviewScrips b/share/html/Helpers/PreviewScrips
similarity index 89%
rename from share/html/Ticket/Elements/PreviewScrips
rename to share/html/Helpers/PreviewScrips
index 973fe0d..458f7ae 100644
--- a/share/html/Ticket/Elements/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -45,12 +45,23 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<%args>
-$TicketObj => undef
-</%args>
 <%init>
-my $Object = $m->notes("DryRun-".$TicketObj->Id) || $TicketObj->DryRun(%ARGS);
-my %recips = %{ $m->notes("DryRun-Recipients-".$TicketObj->Id) || {} };
+my $TicketObj = RT::Ticket->new($session{CurrentUser});
+$TicketObj->Load($ARGS{id});
+return unless $TicketObj->id && $ARGS{UpdateType};
+
+return unless $TicketObj->CurrentUserHasRight('ShowOutgoingEmail');
+if ( $ARGS{UpdateType} eq 'private' ) {
+    return
+      unless $TicketObj->CurrentUserHasRight( 'CommentOnTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
+}
+else {
+    return
+      unless $TicketObj->CurrentUserHasRight( 'ReplyToTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
+}
+
+my $Object = $TicketObj->DryRun(%ARGS);
+my %recips;
 return unless $Object;
 
 my %squelched = ProcessTransactionSquelching( \%ARGS );
@@ -120,4 +131,5 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 
 % $m->callback( CallbackName => 'AfterRecipients', TicketObj => $TicketObj );
 
-% $m->notes("DryRun-Recipients-".$TicketObj->Id, \%recips);
+<input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %recips %>" />
+% $m->abort();
\ No newline at end of file
diff --git a/share/html/Ticket/Elements/ShowSimplifiedRecipients b/share/html/Helpers/ShowSimplifiedRecipients
similarity index 86%
rename from share/html/Ticket/Elements/ShowSimplifiedRecipients
rename to share/html/Helpers/ShowSimplifiedRecipients
index bc662b2..17ae3c3 100644
--- a/share/html/Ticket/Elements/ShowSimplifiedRecipients
+++ b/share/html/Helpers/ShowSimplifiedRecipients
@@ -45,14 +45,23 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<%args>
-$TicketObj
-</%args>
 <%init>
 return unless RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'});
 
-my $Object = $m->notes("DryRun-".$TicketObj->Id) || $TicketObj->DryRun(%ARGS);
-$m->notes("DryRun-".$TicketObj->Id, $Object);
+my $TicketObj = RT::Ticket->new($session{CurrentUser});
+$TicketObj->Load($ARGS{id});
+return unless $TicketObj->id && $ARGS{UpdateType};
+
+if ( $ARGS{UpdateType} eq 'private' ) {
+    return
+      unless $TicketObj->CurrentUserHasRight( 'CommentOnTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
+}
+else {
+    return
+      unless $TicketObj->CurrentUserHasRight( 'ReplyToTicket' ) || $TicketObj->CurrentUserHasRight( 'ModifyTicket' );
+}
+
+my $Object = $TicketObj->DryRun(%ARGS);
 return unless $Object;
 
 my %headers = (To => {}, Cc => {}, Bcc => {});
@@ -75,7 +84,6 @@ if ($Object->Rules) {
 my %recips;
 my %squelched = ProcessTransactionSquelching( \%ARGS );
 </%init>
-<&|/Widgets/TitleBox, title => loc('Recipients'), id => 'recipients' &>
 <table>
 % for my $type (qw(To Cc Bcc)) {
 %     next unless keys %{$headers{$type}};
@@ -99,5 +107,8 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 <&|/l, RT->Config->Get('WebPath')."/Ticket/ModifyPeople.html?id=".$TicketObj->Id,
 &>Uncheck boxes to disable notifications to the listed recipients <b>for this transaction only</b>; persistent squelching is managed on the <a href="[_1]">People page</a>.</&>
 </p>
-</&>
-% $m->notes("DryRun-Recipients-".$TicketObj->Id, \%recips);
+
+% unless ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
+    <input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %recips %>" />
+% }
+% $m->abort();
\ No newline at end of file
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 3e610bc..902ebcf 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -89,11 +89,6 @@
                 .addClass("action-"+ev.target.value);
         });
     });
-    jQuery(function() {
-        jQuery("input[name=TxnSendMailTo]").change(function(ev) {
-            jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == ev.target.value; } ).prop("checked",jQuery(ev.target).prop('checked'));
-        });
-    });
 </script>
 
 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
@@ -141,7 +136,29 @@
 </div>
 
 <div id="ticket-update-message">
-  <& /Ticket/Elements/ShowSimplifiedRecipients, TicketObj => $TicketObj, %ARGS &>
+% if ( RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) ) {
+<script type="text/javascript">
+jQuery( function() {
+   jQuery('#UpdateType').change( function() {
+       jQuery('#recipients div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/ShowSimplifiedRecipients',
+           jQuery('form[name=TicketUpdate]').serialize(),
+           function() {
+% unless ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
+               jQuery("input[name=TxnSendMailTo]").change(function(ev) {
+                   jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == ev.target.value; } ).prop("checked",jQuery(ev.target).prop('checked'));
+               });
+% }
+        });
+   });
+% unless ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
+   jQuery('#UpdateType').change();
+% }
+});
+</script>
+
+    <&|/Widgets/TitleBox, title => loc('Recipients'), id => 'recipients' &>
+    </&>
+%}
 
   <&|/Widgets/TitleBox, title => loc('Message'), class => 'messagedetails' &>
   <table width="100%" border="0">
@@ -190,18 +207,29 @@
 % $m->callback( %ARGS, CallbackName => 'BeforeScrips', Ticket => $TicketObj );
 
 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
+<script type="text/javascript">
+jQuery( function() {
+   jQuery('#UpdateType').change( function() {
+       jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
+           jQuery('form[name=TicketUpdate]').serialize(),
+           function() {
+               jQuery("input[name=TxnSendMailTo]").change(function(ev) {
+                   jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == ev.target.value; } ).prop("checked",jQuery(ev.target).prop('checked'));
+               });
+           }
+       );
+   });
+   jQuery('#UpdateType').change();
+});
+</script>
+
   <&|/Widgets/TitleBox, title => loc('Scrips and Recipients'), id => 'previewscrips', rolledup => RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) &>
-    <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
   </&>
 % }
 </div>
 
 % $m->callback( %ARGS, CallbackName => 'AfterScrips', Ticket => $TicketObj );
 
-% if (my $recips = $m->notes("DryRun-Recipients-".$TicketObj->Id)) {
-<input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %{$recips} %>" />
-% }
-
 </form>
 <hr class="clear" />
 

commit 355ed02acf0b12fc8813e14b0b3fc1b9ec81a1d2
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jun 26 22:27:27 2014 +0800

    trigger ajax call for all inputs in "Ticket and Transaction"
    
    because we are gonna support those changes(e.g. "Status" and "Owner") for
    preview scrips too.

diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 902ebcf..faec518 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -139,7 +139,7 @@
 % if ( RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) ) {
 <script type="text/javascript">
 jQuery( function() {
-   jQuery('#UpdateType').change( function() {
+   jQuery("#ticket-update-metadata :input").change( function() {
        jQuery('#recipients div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/ShowSimplifiedRecipients',
            jQuery('form[name=TicketUpdate]').serialize(),
            function() {
@@ -209,7 +209,7 @@ jQuery( function() {
 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
 <script type="text/javascript">
 jQuery( function() {
-   jQuery('#UpdateType').change( function() {
+   jQuery("#ticket-update-metadata :input").change( function() {
        jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
            jQuery('form[name=TicketUpdate]').serialize(),
            function() {

commit e79c9a623320ffb89fe8ba0204c6e95178febf86
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jul 11 20:00:24 2014 +0800

    respect one-time Cc/Bcc too
    
    note that it's convenient to automatically update preview scrips when user
    selects autocomplete users, so we need to trigger the change on select.
    
    the css tweak is to make sure simplified recipients are vertical aligned,
    the normal preview scrips part doesn't have this issue.

diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
index 458f7ae..3ef3fce 100644
--- a/share/html/Helpers/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -83,7 +83,8 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
           <&|/l, loc($scrip->ConditionObj->Name), loc($scrip->ActionObj->Name), loc($scrip->Template)&>[_1] [_2] with template [_3]</&>
           <br />
 %         for my $type (qw(To Cc Bcc)) {
-%             my @addresses =  $scrip->ActionObj->Action->$type();
+%             my $action = $scrip->ActionObj->Action;
+%             my @addresses =  $action->$type();
 %             next unless @addresses;
               <ul>
 %             for my $addr (@addresses) {
@@ -91,9 +92,26 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 %                 my $checked = not $squelched{$addr->address};
 %                 $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => $addr, Type => $type, Checked => \$checked);
 %                 $recips{$addr->address}++;
-                  <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$addr->address%>" id="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>" />
+                  <b><%loc($type)%></b>:
+%                 my $show_checkbox = 1;
+%                 if ( grep {$_ eq $addr} @{$action->{NoSquelch}{$type}} ) {
+%                     $show_checkbox = 0;
+%                 }
+
+%                 if ( $show_checkbox ) {
+                      <input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$addr->address%>" id="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>" />
+%                 }
+
                   <label for="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>"><& /Elements/ShowUser, Address => $addr &></label>
 %                 $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => $addr, Type => $type);
+%                 unless ( $show_checkbox ) {
+%                     if ( $type eq 'Cc' ) {
+                          (<&|/l&>explicit one-time Cc</&>)
+%                     }
+%                     else {
+                          (<&|/l&>explicit one-time Bcc</&>)
+%                     }
+%                 }
                   </li>
 %             }
               </ul>
diff --git a/share/html/Helpers/ShowSimplifiedRecipients b/share/html/Helpers/ShowSimplifiedRecipients
index 17ae3c3..d336754 100644
--- a/share/html/Helpers/ShowSimplifiedRecipients
+++ b/share/html/Helpers/ShowSimplifiedRecipients
@@ -65,11 +65,16 @@ my $Object = $TicketObj->DryRun(%ARGS);
 return unless $Object;
 
 my %headers = (To => {}, Cc => {}, Bcc => {});
+my %no_squelch;
 if ($Object->Scrips) {
     for my $scrip (grep $_->ActionObj->Action->isa('RT::Action::SendEmail'), @{$Object->Scrips->Prepared}) {
+        my $action = $scrip->ActionObj->Action;
         for my $type (qw(To Cc Bcc)) {
             $headers{$type}{$_->address} = $_
-                for $scrip->ActionObj->Action->$type();
+                for $action->$type();
+        }
+        for my $type ( keys %{$action->{NoSquelch}} ) {
+            $no_squelch{$type}{$_} ||= 1 for @{$action->{NoSquelch}{$type}};
         }
     }
 }
@@ -98,6 +103,16 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 <label for="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>"><& /Elements/ShowUser, Address => $addr &></label>
 %         $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => $addr, Type => $type);
 <br />
+%         if ( $no_squelch{$type}{$addr} ) {
+<label><& /Elements/ShowUser, Address => $addr &></label>
+%             if ( $type eq 'Cc' ) {
+(<&|/l&>explicit one-time Cc</&>)
+%             }
+%             else {
+(<&|/l&>explicit one-time Bcc</&>)
+%             }
+<br />
+%         }
 %     }
 </td></tr>
 % }
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index faec518..e9f3cc4 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -139,7 +139,7 @@
 % if ( RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) ) {
 <script type="text/javascript">
 jQuery( function() {
-   jQuery("#ticket-update-metadata :input").change( function() {
+   jQuery("#ticket-update-metadata :input, input[name^=UpdateCc], input[name^=UpdateBcc]").change( function() {
        jQuery('#recipients div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/ShowSimplifiedRecipients',
            jQuery('form[name=TicketUpdate]').serialize(),
            function() {
@@ -209,7 +209,7 @@ jQuery( function() {
 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
 <script type="text/javascript">
 jQuery( function() {
-   jQuery("#ticket-update-metadata :input").change( function() {
+   jQuery("#ticket-update-metadata :input, input[name^=UpdateCc], input[name^=UpdateBcc]").change( function() {
        jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
            jQuery('form[name=TicketUpdate]').serialize(),
            function() {
diff --git a/share/static/css/base/ticket-form.css b/share/static/css/base/ticket-form.css
index 11d1fdd..15ce713 100644
--- a/share/static/css/base/ticket-form.css
+++ b/share/static/css/base/ticket-form.css
@@ -73,3 +73,11 @@ iframe.richtext-editor {
     float: right;
 }
 
+#recipients label {
+    padding-left: 2em;
+}
+
+#recipients input.checkbox {
+    position: absolute;
+    margin-left: 0.5em;
+}
diff --git a/share/static/js/autocomplete.js b/share/static/js/autocomplete.js
index d5a8af6..957d6f2 100644
--- a/share/static/js/autocomplete.js
+++ b/share/static/js/autocomplete.js
@@ -56,6 +56,7 @@ window.RT.Autocomplete.bind = function(from) {
                 }
                 terms.push(''); // add trailing delimeter so user can input another value directly
                 this.value = terms.join(what == 'Tickets' ? ' ' : ", ");
+                jQuery(this).change();
                 return false;
             }
         }

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


More information about the rt-commit mailing list