[Rt-commit] rt branch, 4.4/squelching-all, created. rt-4.2.5-192-gc87fc36

Alex Vandiver alexmv at bestpractical.com
Wed Jul 23 16:03:49 EDT 2014


The branch, 4.4/squelching-all has been created
        at  c87fc36f866a7d5941b87b08f60714fa0187a98e (commit)

- Log -----------------------------------------------------------------
commit 6f606a1d61ce7ed403d14b695823616caf38a1b6
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Mon Jul 14 17:11:32 2014 -0300

    Add squelched recipients as preference
    
    User preference to start with squelch checkboxes unchecked/checked on
    ticket reply page. This should respect the semi-permanetly squelched
    address when applying its logic. If set to true, then the page shows
    the checkboxes unchecked - which means the email addresses are *not*
    getting any kind of mail.
    Additionally, it adds a new config option called $SquelchedRecipients
    which allows to set it broadly for all users.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 38dfc52..78bdc2f 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1583,6 +1583,16 @@ detailed breakdown by scrip.
 
 Set($SimplifiedRecipients, 0);
 
+=item C<$SquelchedRecipients>
+
+If C<$SquelchedRecipients> is set, the checkbox list of who will receive
+B<any> kind of mail on the ticket reply page are displayed initially as
+B<un>checked - which means nobody in that list would get any mail.
+
+=cut
+
+Set($SquelchedRecipients, 0);
+
 =item C<$HideResolveActionsWithDependencies>
 
 If set to 1, this option will skip ticket menu actions which can't be
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 6126aad..5cb08da 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -459,10 +459,19 @@ our %META;
             Description => "Show simplified recipient list on ticket update",                #loc
         },
     },
+    SquelchedRecipients => {
+        Section         => 'Ticket display',                       #loc
+        Overridable     => 1,
+        SortOrder       => 8,
+        Widget          => '/Widgets/Form/Boolean',
+        WidgetArguments => {
+            Description => "Start with squelch checkboxes unchecked/checked on ticket update", #loc
+        },
+    },
     DisplayTicketAfterQuickCreate => {
         Section         => 'Ticket display',
         Overridable     => 1,
-        SortOrder       => 8,
+        SortOrder       => 9,
         Widget          => '/Widgets/Form/Boolean',
         WidgetArguments => {
             Description => 'Display ticket after "Quick Create"', #loc
@@ -471,7 +480,7 @@ our %META;
     QuoteFolding => {
         Section => 'Ticket display',
         Overridable => 1,
-        SortOrder => 9,
+        SortOrder => 10,
         Widget => '/Widgets/Form/Boolean',
         WidgetArguments => {
             Description => 'Enable quote folding?' # loc
diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
index a27c8f7..e2e344e 100644
--- a/share/html/Helpers/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -94,9 +94,11 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 %             my @addresses =  $action->$type();
 %             next unless @addresses;
               <ul>
+%             my $squelched_recipients = RT->Config->Get('SquelchedRecipients', $session{'CurrentUser'});
 %             for my $addr (@addresses) {
                   <li>
 %                 my $checked = not $squelched{$addr->address};
+%                    $checked = $checked ? not $squelched_recipients : $checked;
 %                 $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => $addr, Type => $type, Checked => \$checked);
 %                 $recips{$addr->address}++;
                   <b><%loc($type)%></b>:
diff --git a/share/html/Helpers/ShowSimplifiedRecipients b/share/html/Helpers/ShowSimplifiedRecipients
index 4c6b60c..183ab08 100644
--- a/share/html/Helpers/ShowSimplifiedRecipients
+++ b/share/html/Helpers/ShowSimplifiedRecipients
@@ -101,8 +101,10 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 <tr>
 <td valign="top"><% $type %>:</td>
 <td valign="top">
+%     my $squelched_recipients = RT->Config->Get('SquelchedRecipients', $session{'CurrentUser'});
 %     for my $addr (sort {$a->address cmp $b->address} values %{$headers{$type}}) {
 %         my $checked = not $squelched{$addr->address};
+%         $checked = $checked ? not $squelched_recipients : $checked;
 %         $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => $addr, Type => $type, Checked => \$checked);
 %         $recips{$addr->address}++;
 <input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$addr->address%>" id="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>" />

commit 526545d1b909eea953bbd302d7b84f6cfbda3691
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Tue Jul 15 18:48:09 2014 -0300

    'Select All' checkbox for scrips correspondences/comments
    
    At ticket reply page, we have the option to select/deselect who in the
    list of people should receive a copy of the reply/comment. This aims to
    add an 'all' checkbox which can select/deselect all of them at once.

diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
index e2e344e..192e409 100644
--- a/share/html/Helpers/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -85,6 +85,14 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 % my @scrips = grep {$_->ActionObj->Action->isa('RT::Action::SendEmail')}
 %              map {@{$_->Scrips->Prepared}} @dryrun;
 % if (@scrips) {
+%   if ( grep {
+%          my $s = $_;
+%          my $action = $s->ActionObj->Action;
+%          scalar(map { $action->$_ } qw(To Cc Bcc))
+%        } @scrips ) {
+<input type="checkbox" name="TxnSendMailToAll" value="1" checked="checked" onclick="setCheckbox(this,'TxnSendMailTo')">
+<label for="TxnSendMailToAll"><b><% loc('All recipients') %></b></label><br />
+%   }
 %     for my $scrip (@scrips) {
           <b><% $scrip->Description || loc('Scrip #[_1]',$scrip->id) %></b><br />
           <&|/l, loc($scrip->ConditionObj->Name), loc($scrip->ActionObj->Name), loc($scrip->Template)&>[_1] [_2] with template [_3]</&>
diff --git a/share/html/Helpers/ShowSimplifiedRecipients b/share/html/Helpers/ShowSimplifiedRecipients
index 183ab08..4bf7338 100644
--- a/share/html/Helpers/ShowSimplifiedRecipients
+++ b/share/html/Helpers/ShowSimplifiedRecipients
@@ -96,6 +96,15 @@ my %recips;
 my %squelched = ProcessTransactionSquelching( \%ARGS );
 </%init>
 <table>
+%   if ( scalar(map { keys %{$headers{$_}} } qw(To Cc Bcc)) ) {
+<tr>
+<td> </td>
+<td>
+<input type="checkbox" name="TxnSendMailToAll" value="1" checked="checked" onclick="setCheckbox(this,'TxnSendMailTo')">
+<label for="TxnSendMailToAll"><b><% loc('All recipients') %></b></label>
+</td>
+</tr>
+% }
 % for my $type (qw(To Cc Bcc)) {
 %     next unless keys %{$headers{$type}} or keys %{$no_squelch{$type}};
 <tr>
diff --git a/share/static/js/util.js b/share/static/js/util.js
index b665c0e..1636cbf 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -82,6 +82,8 @@ function set_rollup_state(e,e2,state) {
 
 function setCheckbox(input, name, val) {
     if (val == null) val = input.checked;
+    var allfield = jQuery('input[name=' + input.name + ']');
+    allfield.prop('checked', val);
 
     // Find inputs within the current form or collection list, whichever is closest.
     var container = jQuery(input).closest("form, table.collection-as-table").get(0);

commit c87fc36f866a7d5941b87b08f60714fa0187a98e
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Mon Jul 21 10:01:11 2014 -0300

    Make 'select all' check/uncheck bi-directional
    
    If I uncheck "All $thing", and then I re-check all of the items by hand,
    then "All $thing" pops back to being checked as soon as I re-checked
    the last item.

diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
index 192e409..b970371 100644
--- a/share/html/Helpers/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -116,9 +116,8 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 %                 }
 
 %                 if ( $show_checkbox ) {
-                      <input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$addr->address%>" id="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>" />
+                      <input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$addr->address%>" id="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>"  onclick="checkboxSetEvent(this,'TxnSendMailTo','TxnSendMailToAll')" />
 %                 }
-
                   <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 ) {
diff --git a/share/html/Helpers/ShowSimplifiedRecipients b/share/html/Helpers/ShowSimplifiedRecipients
index 4bf7338..d7450f5 100644
--- a/share/html/Helpers/ShowSimplifiedRecipients
+++ b/share/html/Helpers/ShowSimplifiedRecipients
@@ -116,7 +116,7 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
 %         $checked = $checked ? not $squelched_recipients : $checked;
 %         $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => $addr, Type => $type, Checked => \$checked);
 %         $recips{$addr->address}++;
-<input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$addr->address%>" id="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>" />
+<input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$addr->address%>" id="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>" onclick="checkboxSetEvent(this,'TxnSendMailTo','TxnSendMailToAll')" />
 <label for="TxnSendMailTo-<% $addr->address %>-<% $recips{$addr->address} %>"><& /Elements/ShowUser, Address => $addr &></label>
 %         $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => $addr, Type => $type);
 <br />
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 1636cbf..e2de5ad 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -80,14 +80,18 @@ function set_rollup_state(e,e2,state) {
 
 /* other utils */
 
+function getClosestInputElements(input) {
+    // Find inputs within the current form or collection list, whichever is closest.
+    var container = jQuery(input).closest("form, table.collection-as-table").get(0);
+    return container.getElementsByTagName('input');
+}
+
 function setCheckbox(input, name, val) {
     if (val == null) val = input.checked;
     var allfield = jQuery('input[name=' + input.name + ']');
     allfield.prop('checked', val);
 
-    // Find inputs within the current form or collection list, whichever is closest.
-    var container = jQuery(input).closest("form, table.collection-as-table").get(0);
-    var myfield   = container.getElementsByTagName('input');
+    var myfield = getClosestInputElements(input);
     for ( var i = 0; i < myfield.length; i++ ) {
         if ( myfield[i].type != 'checkbox' ) continue;
         if ( name ) {
@@ -104,6 +108,37 @@ function setCheckbox(input, name, val) {
     }
 }
 
+function checkboxSetEvent(input, name, allname) {
+    var myfield = getClosestInputElements(input);
+    var checked_count = 0;
+    var field_count = 0;
+    for ( var i = 0; i < myfield.length; i++ ) {
+        if ( myfield[i].type != 'checkbox' ) continue;
+        if ( name ) {
+            if ( name instanceof RegExp ) {
+                if ( ! myfield[i].name.match( name ) ) continue;
+            }
+            else {
+                if ( myfield[i].name != name ) continue;
+            }
+
+        }
+
+        field_count++;
+        if ( myfield[i].checked ) {
+            checked_count++;
+        }
+    }
+
+    var allfield = jQuery('input[name=' + allname + ']');
+    if (field_count == checked_count) {
+        allfield.prop('checked', true);
+    }
+    else {
+        allfield.prop('checked', false);
+    }
+}
+
 /* apply callback to nodes or elements */
 
 function walkChildNodes(parent, callback)

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


More information about the rt-commit mailing list