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

? sunnavy sunnavy at bestpractical.com
Tue Jun 24 11:43:32 EDT 2014


The branch, 4.4/ajax-preview-scrips has been created
        at  9b4394972dc21c1e64899d69a4ca542ebe507d11 (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" />
 

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


More information about the rt-commit mailing list