]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1349769 - takebug should only be default for patch attachments
authorDylan William Hardison <dylan@hardison.net>
Tue, 28 Mar 2017 13:08:56 +0000 (09:08 -0400)
committerDylan William Hardison <dylan@hardison.net>
Tue, 28 Mar 2017 13:09:20 +0000 (09:09 -0400)
template/en/default/attachment/create.html.tmpl
template/en/default/attachment/createformcontents.html.tmpl

index 63bf14b3769b9d0ef2cc947a0cc9f59b450f0d35..eae63adf13b843ee13868d2f8aa0073c7c18d277 100644 (file)
@@ -84,7 +84,10 @@ TUI_hide_default('attachment_text_field');
         <td>
           <em>If you want to assign this [% terms.bug %] to yourself,
               check the box below.</em><br>
-          <input type="checkbox" id="takebug" name="takebug" value="1" [% IF bug.assigned_to.login == "nobody@mozilla.org" || bug.assigned_to.login.search('.bugs$') %] checked [% END %]>
+          [% IF bug.assigned_to.login == "nobody@mozilla.org" || bug.assigned_to.login.search('.bugs$') %]
+            [% take_if_patch = 1 %]
+          [% END %]
+          <input type="checkbox" id="takebug" name="takebug" value="1" [% IF take_if_patch %] data-take-if-patch="1" [% END %]>
           <label for="takebug">take [% terms.bug %]</label>
           [% bug_statuses = [] %]
           [% FOREACH bug_status = bug.status.can_change_to %]
index 7f738c07fdd8994afd75e0a1763edebacd2bc5fc..1ab3893cd9528f16053a1b197f95eee997d77a3c 100644 (file)
@@ -28,7 +28,7 @@
     <a id="attachment_data_controller" href="javascript:TUI_toggle_class('attachment_text_field');
                                              javascript:TUI_toggle_class('attachment_data')"
     >paste text as attachment</a>).<br>
-    <input type="file" id="data" name="data" size="50" onchange="DataFieldHandler()">
+    <input type="file" id="data" name="data" size="50" >
   </td>
 </tr>
 <tr class="attachment_text_field">
   <td>
     <em>If the attachment is a patch, check the box below.</em><br>
     [% Hook.process("patch_notes") %]
-    <input type="checkbox" id="ispatch" name="ispatch" value="1"
-           onchange="setContentTypeDisabledState(this.form);">
+    <input type="checkbox" id="ispatch" name="ispatch" value="1">
     <label for="ispatch">patch</label><br><br>
     [%# Reset this whenever the page loads so that the JS state is up to date %]
-    <script type="text/javascript">
-      YAHOO.util.Event.onDOMReady(function() {
-          bz_fireEvent(document.getElementById('ispatch'), 'change');
+    <script type="text/javascript" [% csp_nonce FILTER none %]>
+      $(function() {
+        $("#file").on("change", function() {
+          DataFieldHandler();
+          // Fire event to keep take-bug in sync.
+          $("#ispatch").change();
+        });
+        $("#ispatch").on("change", function() {
+          setContentTypeDisabledState(this.form);
+          var takebug = $("#takebug");
+          if (takebug.is(":visible") && takebug.data("take-if-patch") && $("#ispatch").prop("checked")) {
+            $("#takebug").prop("checked", true);
+          }
+        }).change();
       });
     </script>