[Rt-commit] rt branch, 4.4/preview-scrip-recipients-checkbox, repushed
Dave Goehrig
dave at bestpractical.com
Thu Mar 2 12:02:03 EST 2017
The branch 4.4/preview-scrip-recipients-checkbox was deleted and repushed:
was 0a238cea9eb98b4bf88bac4a19e4b55adb144760
now 7d11eb830bc2a19c56c712676757cb0e1afaad30
1: 26906c2 < -: ------- adding project time worked
2: 0a238ce ! 1: 7d11eb8 Disable checkbox while scrip loading
@@ -1,31 +1,18 @@
Author: Dave Goehrig <dave at bestpractical.com>
- Fix PreviewScrip checkbox toggling
+ Disable checkbox while scrip loading
- When the PreviewScrip box is reloaded for any reason,
- the POST request was passing the state of the checkbox
- but the PreviewScrips Helper wasn't respecting the state.
+ To prevent you from clicking on the checkbox
+ while the PreviewScrips widget is loading,
+ I've overridden the click handler to return false
+ preventing the click event from working.
- This change sets the checked status based on the input value
- from the AJAX load POST. This will fix the seeming race
- condition which resets the all recipients button.
+ It should be noted that "disabled" and "readonly"
+ attributres do not have the desired behavior on
+ checkboxes as they impact the value and not the
+ check state.
- In the future it would be worth rewriting this code to not
- do the DOM rendering on the server side, and move towards
- a client side rendering with a proper data model. DOM
- replacements like this code does every time any element in
- the top level form change make it difficult to maintain a
- consistent view on the client side.
-
- A better implementation would be to have the client side
- view render via DOM manipulation (for those elements which
- need to be dynamically added), and the AJAX post simply
- negotiate a data transfer (say in JSON) of the data elements
- needed to populate the form values. This would make it work
- similarly to the autocomplete helpers which uses JSON from
- a Helper to add autocomplete fields to the dropdown.
-
- Fixes: I#180703
+ Fixes: I#32290
diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
--- a/share/html/Helpers/PreviewScrips
@@ -35,15 +22,32 @@
% scalar(map { $action->$_ } qw(To Cc Bcc))
% } @scrips ) {
-<input type="checkbox" class="checkbox" id="TxnSendMailToAll" name="TxnSendMailToAll" value="1">
-+<input type="checkbox" class="checkbox" id="TxnSendMailToAll" name="TxnSendMailToAll" <% $ARGS{TxnSendMailToAll} ? 'checked="checked"' : '' %>" value="1">
++<input type="checkbox" class="checkbox" id="TxnSendMailToAll" name="TxnSendMailToAll" <% $ARGS{TxnSendMailToAll} ? 'checked="checked"' : '' %> value="1">
<label for="TxnSendMailToAll"><b><% loc('All recipients') %></b></label><br />
% }
% for my $scrip (@scrips) {
+@@
+ % }
+
+ % $m->callback( CallbackName => 'AfterRecipients', TicketObj => $TicketObj );
+-
+ <input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %recips %>" />
+ % $m->abort();
++
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@
+ }
+ }
+ );
++
++ jQuery("#previewscrips input[name=TxnSendMailToAll]").click(function() { return false; });
+ jQuery('#previewscrips div.titlebox-content').load( '<% RT->Config->Get('WebPath')%>/Helpers/PreviewScrips',
+ jQuery('form[name=TicketUpdate]').serializeArray(),
+ function() {
++ console.log("Loading preview scrips helper");
var txn_send_field = jQuery("#previewscrips input[name=TxnSendMailTo]");
txn_send_field.change( syncCheckboxes );
txn_send_field.click( function () { setCheckbox(this) } );
More information about the rt-commit
mailing list