[Rt-commit] rt branch, 4.2/scrips-correspond-selectall-checkbox, created. rt-4.2.6-20-g6beec0e
Wallace Reis
wreis at bestpractical.com
Wed Jul 23 10:15:27 EDT 2014
The branch, 4.2/scrips-correspond-selectall-checkbox has been created
at 6beec0e48798847738904d8de270c1d9818d8010 (commit)
- Log -----------------------------------------------------------------
commit 70c579760d433f9ddde2ad0a067a693708536d63
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/Ticket/Elements/PreviewScrips b/share/html/Ticket/Elements/PreviewScrips
index 973fe0d..51293ca 100644
--- a/share/html/Ticket/Elements/PreviewScrips
+++ b/share/html/Ticket/Elements/PreviewScrips
@@ -67,6 +67,14 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
% map { [$_, $_->ActionObj->Action->To + $_->ActionObj->Action->Cc + $_->ActionObj->Action->Bcc] }
% grep {$_->ActionObj->Action->isa('RT::Action::SendEmail')}
% @{$Object->Scrips->Prepared};
+% 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/Ticket/Elements/ShowSimplifiedRecipients b/share/html/Ticket/Elements/ShowSimplifiedRecipients
index bc662b2..4546c38 100644
--- a/share/html/Ticket/Elements/ShowSimplifiedRecipients
+++ b/share/html/Ticket/Elements/ShowSimplifiedRecipients
@@ -77,6 +77,15 @@ my %squelched = ProcessTransactionSquelching( \%ARGS );
</%init>
<&|/Widgets/TitleBox, title => loc('Recipients'), id => 'recipients' &>
<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}};
<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 6beec0e48798847738904d8de270c1d9818d8010
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/Ticket/Elements/PreviewScrips b/share/html/Ticket/Elements/PreviewScrips
index 51293ca..665269d 100644
--- a/share/html/Ticket/Elements/PreviewScrips
+++ b/share/html/Ticket/Elements/PreviewScrips
@@ -88,7 +88,7 @@ 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>: <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);
</li>
diff --git a/share/html/Ticket/Elements/ShowSimplifiedRecipients b/share/html/Ticket/Elements/ShowSimplifiedRecipients
index 4546c38..20ea979 100644
--- a/share/html/Ticket/Elements/ShowSimplifiedRecipients
+++ b/share/html/Ticket/Elements/ShowSimplifiedRecipients
@@ -95,7 +95,7 @@ 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}++;
-<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