[Bps-public-commit] rt-extension-ajaxpreviewscrips branch, master, updated. 0.01-6-g9200020
Alex Vandiver
alexmv at bestpractical.com
Tue Aug 5 18:27:46 EDT 2014
The branch, master has been updated
via 920002050bb82ca2d516e00d5aaeb22b9de5703e (commit)
via 63a46fd49dc31d0a70ea965656b5e9e9c0bbf7fc (commit)
via 98c71f1a493fe4a1e67ecddf9d9946c2db969dfe (commit)
via 60dc7f37925e624724e4b787be3ac248f46acb31 (commit)
via 8394208cdec709c4fd812cae6b50b448699a2812 (commit)
via ff0739461c2cae98d8bd78d36eb8131d677b33c9 (commit)
from c3748c29efa433bc3ffa7121cfb4e91a10afaf5f (commit)
Summary of changes:
Changes | 6 ++++
MANIFEST | 1 +
META.yml | 4 +--
Makefile.PL | 3 --
README | 6 ++--
html/Helpers/PreviewScrips | 44 ++++++++++-----------------
html/Helpers/ShowSimplifiedRecipients | 28 ++++++++++-------
html/Ticket/Elements/PreviewScrips | 4 +++
html/Ticket/Elements/ShowSimplifiedRecipients | 6 ++++
lib/RT/Extension/AjaxPreviewScrips.pm | 13 +++++++-
static/js/checkboxes.js | 36 ++++++++++++++++++++++
11 files changed, 103 insertions(+), 48 deletions(-)
create mode 100644 static/js/checkboxes.js
- Log -----------------------------------------------------------------
commit ff0739461c2cae98d8bd78d36eb8131d677b33c9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Jul 21 19:16:10 2014 -0400
Pass the just-submitted squelching information to the first AJAX request
If "Add more files" is pressed, the set of selected squelched recipients
is submitted; on the sebsequent page display, however, that information
does not appear in the initial form that is serialized and passed to the
helpers; as such, the state of the checkboxes is lost.
Preserve that information by ensuring that the squelching information is
present on the page during the first page load, before the AJAX
requests, by placing it within the area to be replaced. This ensures
that the form elements will not be duplicated once the initial AJAX
request returns, but provides the query parameters for the initial call
to jQuery('form[name=TicketUpdate]').serialize().
diff --git a/html/Ticket/Elements/PreviewScrips b/html/Ticket/Elements/PreviewScrips
index 8ccb064..020ba7f 100644
--- a/html/Ticket/Elements/PreviewScrips
+++ b/html/Ticket/Elements/PreviewScrips
@@ -48,3 +48,7 @@
<%args>
$TicketObj => undef
</%args>
+% for my $address (grep {defined} ref $ARGS{TxnSendMailTo} ? @{$ARGS{TxnSendMailTo}} : $ARGS{TxnSendMailTo}) {
+<input type="hidden" name="TxnSendMailTo" value="<% $address %>" />
+% }
+<input type="hidden" name="TxnRecipients" value="<% $ARGS{TxnRecipients} || '' %>" />
diff --git a/html/Ticket/Elements/ShowSimplifiedRecipients b/html/Ticket/Elements/ShowSimplifiedRecipients
index a4cec73..7d5137f 100644
--- a/html/Ticket/Elements/ShowSimplifiedRecipients
+++ b/html/Ticket/Elements/ShowSimplifiedRecipients
@@ -52,4 +52,10 @@ $TicketObj
return unless RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'});
</%INIT>
<&|/Widgets/TitleBox, title => loc('Recipients'), id => 'recipients' &>
+% unless ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
+% for my $address (grep {defined} ref $ARGS{TxnSendMailTo} ? @{$ARGS{TxnSendMailTo}} : $ARGS{TxnSendMailTo}) {
+<input type="hidden" name="TxnSendMailTo" value="<% $address %>" />
+% }
+<input type="hidden" name="TxnRecipients" value="<% $ARGS{TxnRecipients} || '' %>" />
+% }
</&>
commit 8394208cdec709c4fd812cae6b50b448699a2812
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Jul 23 13:47:42 2014 -0400
Remove mostly-duplicate code for Rules which can never trigger
PreviewScrips includes a mostly-duplicated block of code to preview
emails produced by Rules, the mechanism behind Approvals. However, this
code is unnecessary because /Ticket/Update.html is not accessible for
tickets of type 'approval' (the only objects which could currently
trigger Rules in a stock RT), because /Tickets/autohandler redirects all
but a small number of files under /Tickets/ to /Approvals/ instead.
/Ticket/Update.html is not in the whitelist, and thus cannot render for
Approvals.
Furthermore, the code checks $rule->{hints}{class} to determine if it
should display the rule; no rule ever has a ->{hints} set on it, and
never has, since the introduction of this code in 6d14f535. As such,
even if /Ticket/Update.html were accessible, or some local customization
made use of Rules for something other than Approvals, they would still
not appear in PreviewScrips.
Remove the duplicated and unused code.
diff --git a/html/Helpers/PreviewScrips b/html/Helpers/PreviewScrips
index ef7db09..a27c8f7 100644
--- a/html/Helpers/PreviewScrips
+++ b/html/Helpers/PreviewScrips
@@ -130,31 +130,6 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
% }
% }
-% my @rules = map {@{$_->Rules}} @dryrun;
-% if ( @rules ) {
-% for my $rule (@rules) {
-% next unless $rule->{hints} && $rule->{hints}{class} eq 'SendEmail';
- <b><% $rule->Describe %></b>
-% my $data = $rule->{hints}{recipients};
-% for my $type (qw(To Cc Bcc)) {
-% next unless @{$data->{$type}};
- <ul>
-% for my $address (@{$data->{$type}}) {
- <li>
-% my $checked = not $squelched{$address};
-% $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => Email::Address->parse($address), Type => $type, Checked => \$checked);
-% $recips{$address}++;
- <b><%loc($type)%></b>: <input type="checkbox" class="checkbox" name="TxnSendMailTo" <% $checked ? 'checked="checked"' : '' |n%> value="<%$address%>" id="TxnSendMailTo-<% $address %>-<% $recips{$address} %>" />
- <label for="TxnSendMailTo-<% $address %>-<% $recips{$address} %>"><%$address%></label>
-% $m->callback(CallbackName => 'AfterAddress', Ticket => $TicketObj, Address => Email::Address->parse($address), Type => $type);
- </li>
-% }
- </ul>
-% }
- <br />
-% }
-% }
-
% $m->callback( CallbackName => 'AfterRecipients', TicketObj => $TicketObj );
<input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %recips %>" />
diff --git a/html/Helpers/ShowSimplifiedRecipients b/html/Helpers/ShowSimplifiedRecipients
index 68e86cc..4c6b60c 100644
--- a/html/Helpers/ShowSimplifiedRecipients
+++ b/html/Helpers/ShowSimplifiedRecipients
@@ -92,15 +92,6 @@ if (@scrips) {
}
}
}
-my @rules = map {@{$_->Rules}} @dryrun;
-if (@rules) {
- for my $rule (grep {$_->{hints} and $_->{hints}{class} eq "SendEmail"} @rules) {
- for my $type (qw(To Cc Bcc)) {
- $headers{$type}{$_} ||= @{[Email::Address->parse($_)]}[0] # Hate list context
- for @{$rule->{hints}{recipients}{$type}};
- }
- }
-}
my %recips;
my %squelched = ProcessTransactionSquelching( \%ARGS );
</%init>
commit 60dc7f37925e624724e4b787be3ac248f46acb31
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-permanently 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/html/Helpers/PreviewScrips b/html/Helpers/PreviewScrips
index a27c8f7..f5575c4 100644
--- a/html/Helpers/PreviewScrips
+++ b/html/Helpers/PreviewScrips
@@ -76,6 +76,10 @@ my %recips;
$m->abort unless @dryrun;
my %squelched = ProcessTransactionSquelching( \%ARGS );
+my $squelched_config = !( RT->Config->Get('SquelchedRecipients', $session{'CurrentUser'}) );
+if ($ARGS{TxnRecipients}) {
+ $squelched_config = undef;
+}
</%init>
<p>
<&|/l, RT->Config->Get('WebPath')."/Ticket/ModifyPeople.html?id=".$TicketObj->Id,
@@ -96,7 +100,7 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
<ul>
% for my $addr (@addresses) {
<li>
-% my $checked = not $squelched{$addr->address};
+% my $checked = $squelched_config // not $squelched{$addr->address};
% $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => $addr, Type => $type, Checked => \$checked);
% $recips{$addr->address}++;
<b><%loc($type)%></b>:
diff --git a/html/Helpers/ShowSimplifiedRecipients b/html/Helpers/ShowSimplifiedRecipients
index 4c6b60c..49e27db 100644
--- a/html/Helpers/ShowSimplifiedRecipients
+++ b/html/Helpers/ShowSimplifiedRecipients
@@ -94,6 +94,10 @@ if (@scrips) {
}
my %recips;
my %squelched = ProcessTransactionSquelching( \%ARGS );
+my $squelched_config = !( RT->Config->Get('SquelchedRecipients', $session{'CurrentUser'}) );
+if ($ARGS{TxnRecipients}) {
+ $squelched_config = undef;
+}
</%init>
<table>
% for my $type (qw(To Cc Bcc)) {
@@ -102,7 +106,7 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
<td valign="top"><% $type %>:</td>
<td valign="top">
% for my $addr (sort {$a->address cmp $b->address} values %{$headers{$type}}) {
-% my $checked = not $squelched{$addr->address};
+% my $checked = $squelched_config // not $squelched{$addr->address};
% $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} %>" />
diff --git a/lib/RT/Extension/AjaxPreviewScrips.pm b/lib/RT/Extension/AjaxPreviewScrips.pm
index ae51fad..c1b96b3 100644
--- a/lib/RT/Extension/AjaxPreviewScrips.pm
+++ b/lib/RT/Extension/AjaxPreviewScrips.pm
@@ -4,6 +4,16 @@ package RT::Extension::AjaxPreviewScrips;
our $VERSION = '0.01';
RT->AddStyleSheets("ajaxpreviewscrips.css");
+RT->Config->AddOption(
+ Name => "SquelchedRecipients",
+ Section => 'Ticket display',
+ Overridable => 1,
+ SortOrder => 8.5,
+ Widget => '/Widgets/Form/Boolean',
+ WidgetArguments => {
+ Description => "Default to squelching all outgoing email notifications (from web interface) on ticket update", #loc
+ },
+);
=head1 NAME
commit 98c71f1a493fe4a1e67ecddf9d9946c2db969dfe
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/html/Helpers/PreviewScrips b/html/Helpers/PreviewScrips
index f5575c4..84c0ad5 100644
--- a/html/Helpers/PreviewScrips
+++ b/html/Helpers/PreviewScrips
@@ -77,8 +77,10 @@ $m->abort unless @dryrun;
my %squelched = ProcessTransactionSquelching( \%ARGS );
my $squelched_config = !( RT->Config->Get('SquelchedRecipients', $session{'CurrentUser'}) );
+my $all_checkbox = $squelched_config ? 'checked="checked"' : "";
if ($ARGS{TxnRecipients}) {
$squelched_config = undef;
+ $all_checkbox = scalar(grep {$_} values %squelched) ? "" : 'checked="checked"';
}
</%init>
<p>
@@ -89,6 +91,14 @@ if ($ARGS{TxnRecipients}) {
% 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" class="checkbox" name="TxnSendMailToAll" value="1" <% $all_checkbox | n %> onclick="jQuery('input[name=TxnSendMailToAll]').prop('checked',this.checked);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/html/Helpers/ShowSimplifiedRecipients b/html/Helpers/ShowSimplifiedRecipients
index 49e27db..4bc48ee 100644
--- a/html/Helpers/ShowSimplifiedRecipients
+++ b/html/Helpers/ShowSimplifiedRecipients
@@ -95,11 +95,22 @@ if (@scrips) {
my %recips;
my %squelched = ProcessTransactionSquelching( \%ARGS );
my $squelched_config = !( RT->Config->Get('SquelchedRecipients', $session{'CurrentUser'}) );
+my $all_checkbox = $squelched_config ? 'checked="checked"' : "";
if ($ARGS{TxnRecipients}) {
$squelched_config = undef;
+ $all_checkbox = scalar(grep {$_} values %squelched) ? "" : 'checked="checked"';
}
</%init>
<table>
+% if ( scalar(map { keys %{$headers{$_}} } qw(To Cc Bcc)) ) {
+<tr>
+<td> </td>
+<td>
+<input type="checkbox" class="checkbox" name="TxnSendMailToAll" value="1" <% $all_checkbox | n %> onclick="jQuery('input[name=TxnSendMailToAll]').prop('checked',this.checked); 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>
commit 63a46fd49dc31d0a70ea965656b5e9e9c0bbf7fc
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/html/Helpers/PreviewScrips b/html/Helpers/PreviewScrips
index 84c0ad5..1a72da1 100644
--- a/html/Helpers/PreviewScrips
+++ b/html/Helpers/PreviewScrips
@@ -120,9 +120,8 @@ if ($ARGS{TxnRecipients}) {
% }
% 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/html/Helpers/ShowSimplifiedRecipients b/html/Helpers/ShowSimplifiedRecipients
index 4bc48ee..fbec446 100644
--- a/html/Helpers/ShowSimplifiedRecipients
+++ b/html/Helpers/ShowSimplifiedRecipients
@@ -120,7 +120,7 @@ if ($ARGS{TxnRecipients}) {
% my $checked = $squelched_config // not $squelched{$addr->address};
% $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/lib/RT/Extension/AjaxPreviewScrips.pm b/lib/RT/Extension/AjaxPreviewScrips.pm
index c1b96b3..6f7cdfe 100644
--- a/lib/RT/Extension/AjaxPreviewScrips.pm
+++ b/lib/RT/Extension/AjaxPreviewScrips.pm
@@ -4,6 +4,7 @@ package RT::Extension::AjaxPreviewScrips;
our $VERSION = '0.01';
RT->AddStyleSheets("ajaxpreviewscrips.css");
+RT->AddJavaScript("checkboxes.js");
RT->Config->AddOption(
Name => "SquelchedRecipients",
Section => 'Ticket display',
diff --git a/static/js/checkboxes.js b/static/js/checkboxes.js
new file mode 100644
index 0000000..681549f
--- /dev/null
+++ b/static/js/checkboxes.js
@@ -0,0 +1,36 @@
+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 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);
+ }
+}
commit 920002050bb82ca2d516e00d5aaeb22b9de5703e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Jul 30 15:50:27 2014 -0400
Version 0.02 releng
diff --git a/Changes b/Changes
index b662cec..9957cf9 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,10 @@
Revision history for RT-Extension-AjaxPreviewScrips
+0.02 2014-07-30
+ - Pass the just-submitted squelching information to the first AJAX request
+ - Remove mostly-duplicate code for Rules which can never trigger
+ - Add squelched recipients as preference
+ - 'Select All' checkbox for scrips correspondences/comments
+
0.01 2014-07-14
- Initial version
diff --git a/MANIFEST b/MANIFEST
index 84e2e22..0c1af82 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -26,3 +26,4 @@ MANIFEST This list of files
META.yml
README
static/css/ajaxpreviewscrips.css
+static/js/checkboxes.js
diff --git a/META.yml b/META.yml
index 0098619..06a3eb1 100644
--- a/META.yml
+++ b/META.yml
@@ -9,7 +9,7 @@ configure_requires:
distribution_type: module
dynamic_config: 1
generated_by: 'Module::Install version 1.08'
-license: gplv2
+license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
@@ -23,7 +23,7 @@ requires:
perl: 5.10.1
resources:
license: http://opensource.org/licenses/gpl-license.php
-version: '0.01'
+version: '0.02'
x_module_install_rtx_version: 0.34_04
x_requires_rt: 4.2.0
x_rt_too_new: 4.4.0
diff --git a/Makefile.PL b/Makefile.PL
index 92302c7..945bc28 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,9 +1,6 @@
use inc::Module::Install;
RTx 'RT-Extension-AjaxPreviewScrips';
-all_from 'lib/RT/Extension/AjaxPreviewScrips.pm';
-readme_from 'lib/RT/Extension/AjaxPreviewScrips.pm';
-license 'gplv2';
requires_rt '4.2.0';
rt_too_new '4.4.0';
diff --git a/README b/README
index 94798ee..063c554 100644
--- a/README
+++ b/README
@@ -9,9 +9,9 @@ RT VERSION
Works with RT 4.2
INSTALLATION
- "perl Makefile.PL"
- "make"
- "make install"
+ perl Makefile.PL
+ make
+ make install
May need root permissions
Edit your /opt/rt4/etc/RT_SiteConfig.pm
diff --git a/lib/RT/Extension/AjaxPreviewScrips.pm b/lib/RT/Extension/AjaxPreviewScrips.pm
index 6f7cdfe..b2727e0 100644
--- a/lib/RT/Extension/AjaxPreviewScrips.pm
+++ b/lib/RT/Extension/AjaxPreviewScrips.pm
@@ -2,7 +2,7 @@ use strict;
use warnings;
package RT::Extension::AjaxPreviewScrips;
-our $VERSION = '0.01';
+our $VERSION = '0.02';
RT->AddStyleSheets("ajaxpreviewscrips.css");
RT->AddJavaScript("checkboxes.js");
RT->Config->AddOption(
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list