[Bps-public-commit] rt-extension-ajaxpreviewscrips branch, master, updated. 0.03
Alex Vandiver
alexmv at bestpractical.com
Fri Aug 22 16:56:32 EDT 2014
The branch, master has been updated
via 6fcef09672a38cc9b1384d6b5034de859efdad4c (commit)
via 0cb6e9e8fcf1556c5f5e6714ffc3968833715021 (commit)
from 920002050bb82ca2d516e00d5aaeb22b9de5703e (commit)
Summary of changes:
META.yml | 2 +-
.../AjaxPreviewScrips/Ticket/Update.html/AfterForm | 19 ++++++++--
html/Helpers/PreviewScrips | 13 +++----
html/Helpers/ShowSimplifiedRecipients | 13 +++----
lib/RT/Extension/AjaxPreviewScrips.pm | 2 +-
static/js/checkboxes.js | 41 ++++++++++++++++------
6 files changed, 58 insertions(+), 32 deletions(-)
- Log -----------------------------------------------------------------
commit 0cb6e9e8fcf1556c5f5e6714ffc3968833715021
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Aug 22 16:29:04 2014 -0400
Updates from 4.4/squelching-all
diff --git a/html/Callbacks/AjaxPreviewScrips/Ticket/Update.html/AfterForm b/html/Callbacks/AjaxPreviewScrips/Ticket/Update.html/AfterForm
index 4c6c0af..f1d317b 100644
--- a/html/Callbacks/AjaxPreviewScrips/Ticket/Update.html/AfterForm
+++ b/html/Callbacks/AjaxPreviewScrips/Ticket/Update.html/AfterForm
@@ -10,15 +10,28 @@ jQuery( function() {
var updateScrips = function() {
CKEDITOR.instances['UpdateContent'].updateElement();
var syncCheckboxes = function(ev) {
- jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == ev.target.value; } ).prop("checked",jQuery(ev.target).prop('checked'));
+ var target = ev.target;
+ jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == target.value; } ).prop("checked",jQuery(target).prop('checked'));
};
jQuery('#recipients div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/ShowSimplifiedRecipients',
jQuery('form[name=TicketUpdate]').serialize(),
- function() { jQuery("#recipients input[name=TxnSendMailTo]").change( syncCheckboxes ); }
+ function() {
+ 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'); } );
+ setCheckbox(txn_send_field);
+ }
);
jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
jQuery('form[name=TicketUpdate]').serialize(),
- function() { jQuery("#previewscrips input[name=TxnSendMailTo]").change( syncCheckboxes ); }
+ function() {
+ 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'); } );
+ setCheckbox(txn_send_field);
+ }
);
};
updateScrips();
diff --git a/html/Helpers/PreviewScrips b/html/Helpers/PreviewScrips
index 1a72da1..f4379d3 100644
--- a/html/Helpers/PreviewScrips
+++ b/html/Helpers/PreviewScrips
@@ -77,11 +77,8 @@ $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"';
-}
+my %submitted;
+$submitted{$_} = 1 for split /,/, $ARGS{TxnRecipients};
</%init>
<p>
<&|/l, RT->Config->Get('WebPath')."/Ticket/ModifyPeople.html?id=".$TicketObj->Id,
@@ -96,7 +93,7 @@ if ($ARGS{TxnRecipients}) {
% 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')">
+<input type="checkbox" class="checkbox" name="TxnSendMailToAll" value="1">
<label for="TxnSendMailToAll"><b><% loc('All recipients') %></b></label><br />
% }
% for my $scrip (@scrips) {
@@ -110,7 +107,7 @@ if ($ARGS{TxnRecipients}) {
<ul>
% for my $addr (@addresses) {
<li>
-% my $checked = $squelched_config // not $squelched{$addr->address};
+% my $checked = $submitted{$addr->address} ? not $squelched{$addr->address} : $squelched_config;
% $m->callback(CallbackName => 'BeforeAddress', Ticket => $TicketObj, Address => $addr, Type => $type, Checked => \$checked);
% $recips{$addr->address}++;
<b><%loc($type)%></b>:
@@ -120,7 +117,7 @@ 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} %>" onclick="checkboxSetEvent(this,'TxnSendMailTo','TxnSendMailToAll')" />
+ <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);
diff --git a/html/Helpers/ShowSimplifiedRecipients b/html/Helpers/ShowSimplifiedRecipients
index fbec446..99ff9ae 100644
--- a/html/Helpers/ShowSimplifiedRecipients
+++ b/html/Helpers/ShowSimplifiedRecipients
@@ -95,18 +95,15 @@ 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"';
-}
+my %submitted;
+$submitted{$_} = 1 for split /,/, $ARGS{TxnRecipients};
</%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')">
+<input type="checkbox" class="checkbox" name="TxnSendMailToAll" value="1">
<label for="TxnSendMailToAll"><b><% loc('All recipients') %></b></label>
</td>
</tr>
@@ -117,10 +114,10 @@ if ($ARGS{TxnRecipients}) {
<td valign="top"><% $type %>:</td>
<td valign="top">
% for my $addr (sort {$a->address cmp $b->address} values %{$headers{$type}}) {
-% my $checked = $squelched_config // not $squelched{$addr->address};
+% my $checked = $submitted{$addr->address} ? not $squelched{$addr->address} : $squelched_config;
% $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} %>" onclick="checkboxSetEvent(this,'TxnSendMailTo','TxnSendMailToAll')" />
+<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);
<br />
diff --git a/static/js/checkboxes.js b/static/js/checkboxes.js
index 681549f..e4e8523 100644
--- a/static/js/checkboxes.js
+++ b/static/js/checkboxes.js
@@ -4,10 +4,22 @@ function getClosestInputElements(input) {
return container.getElementsByTagName('input');
}
-function checkboxSetEvent(input, name, allname) {
- var myfield = getClosestInputElements(input);
+function setCheckbox(input, name, val) {
+ if (val == null) val = input.checked;
+
+ var is_set_event = false;
+ if ( !name ) {
+ name = input.name || input.attr('name');
+ is_set_event = true;
+ }
+ else {
+ var allfield = jQuery('input[name=' + input.name + ']');
+ allfield.prop('checked', val);
+ }
+
var checked_count = 0;
var field_count = 0;
+ var myfield = getClosestInputElements(input);
for ( var i = 0; i < myfield.length; i++ ) {
if ( myfield[i].type != 'checkbox' ) continue;
if ( name ) {
@@ -20,17 +32,24 @@ function checkboxSetEvent(input, name, allname) {
}
- field_count++;
- if ( myfield[i].checked ) {
- checked_count++;
+ if ( is_set_event ) {
+ field_count++;
+ if ( myfield[i].checked ) {
+ checked_count++;
+ }
+ }
+ else {
+ myfield[i].checked = val;
}
}
- var allfield = jQuery('input[name=' + allname + ']');
- if (field_count == checked_count) {
- allfield.prop('checked', true);
- }
- else {
- allfield.prop('checked', false);
+ if ( is_set_event ) {
+ var allfield = jQuery('input[name=' + name + 'All' + ']');
+ if (field_count == checked_count) {
+ allfield.prop('checked', true);
+ }
+ else {
+ allfield.prop('checked', false);
+ }
}
}
commit 6fcef09672a38cc9b1384d6b5034de859efdad4c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Aug 22 16:56:21 2014 -0400
Version 0.03 releng
diff --git a/META.yml b/META.yml
index 06a3eb1..6082831 100644
--- a/META.yml
+++ b/META.yml
@@ -23,7 +23,7 @@ requires:
perl: 5.10.1
resources:
license: http://opensource.org/licenses/gpl-license.php
-version: '0.02'
+version: '0.03'
x_module_install_rtx_version: 0.34_04
x_requires_rt: 4.2.0
x_rt_too_new: 4.4.0
diff --git a/lib/RT/Extension/AjaxPreviewScrips.pm b/lib/RT/Extension/AjaxPreviewScrips.pm
index b2727e0..7a6f691 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.02';
+our $VERSION = '0.03';
RT->AddStyleSheets("ajaxpreviewscrips.css");
RT->AddJavaScript("checkboxes.js");
RT->Config->AddOption(
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list