← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rharding/launchpad/fix_bug_constrain into lp:launchpad

 

Richard Harding has proposed merging lp:~rharding/launchpad/fix_bug_constrain into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rharding/launchpad/fix_bug_constrain/+merge/88065

= Summary =
In order to remove mochikit, the activateConstrainBugExpiration needs to be moved and ported to YUI.

== Proposed Fix ==
Remove the mochikit code and add it as YUI code to the page.

== Implementation Details ==
The JS is only used on the bugtracker configure ui, so it's moved to be part of a new template that adds the JS to the head with head_epilogue.

== Tests ==

== Demo and Q/A ==
Load up https://launchpad.XXX/launchpad/+configure-bugtracker and make sure that as you uncheck and check where bugs are tracked, the checkbox for "Expire "Incomplete" bug reports when they become inactive" should become disabled when bugs are not tracked in Launchpad and checked by default when bugs are set to be in Launchpad.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/browser/configure.zcml
  lib/lp/bugs/templates/bugtracker-configure.pt

-- 
https://code.launchpad.net/~rharding/launchpad/fix_bug_constrain/+merge/88065
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rharding/launchpad/fix_bug_constrain into lp:launchpad.
=== modified file 'lib/lp/app/javascript/lp-mochi.js'
--- lib/lp/app/javascript/lp-mochi.js	2011-06-30 17:38:28 +0000
+++ lib/lp/app/javascript/lp-mochi.js	2012-01-10 15:02:49 +0000
@@ -148,41 +148,6 @@
     }
 }
 
-function activateConstrainBugExpiration() {
-    // Constrain enable_bug_expiration to the Launchpad Bugs radio input.
-    // The Launchpad bug tracker is either the first item in a product's
-    // bugtracker field, or it is a distribution's official_malone field.
-    var bug_tracker_input = getElement('field.bugtracker.0');
-    if (! bug_tracker_input) {
-        bug_tracker_input = getElement('field.official_malone');
-    }
-    var bug_expiration_input = getElement('field.enable_bug_expiration');
-    if (! bug_tracker_input || ! bug_expiration_input) {
-        return;
-    }
-    // Disable enable_bug_expiration onload if Launchpad is not the
-    // bug tracker.
-    if (! bug_tracker_input.checked) {
-        bug_expiration_input.disabled = true;
-    }
-    constraint = function (e) {
-        if (bug_tracker_input.checked) {
-            bug_expiration_input.disabled = false;
-            bug_expiration_input.checked = true;
-        } else {
-            bug_expiration_input.checked = false;
-            bug_expiration_input.disabled = true;
-        }
-    };
-    var inputs = document.getElementsByTagName('input');
-    for (var i = 0; i < inputs.length; i++) {
-        if (inputs[i].name == 'field.bugtracker' ||
-            inputs[i].name == 'field.official_malone') {
-            inputs[i].onclick = constraint;
-        }
-    }
-}
-
 function collapseRemoteCommentReply(comment_index) {
     var prefix = 'remote_comment_reply_';
     $(prefix + 'tree_icon_' + comment_index).src = '/@@/treeCollapsed';

=== modified file 'lib/lp/bugs/browser/configure.zcml'
--- lib/lp/bugs/browser/configure.zcml	2011-12-24 17:49:30 +0000
+++ lib/lp/bugs/browser/configure.zcml	2012-01-10 15:02:49 +0000
@@ -369,7 +369,7 @@
         for="lp.registry.interfaces.product.IProduct"
         permission="launchpad.BugSupervisor"
         name="+configure-bugtracker"
-        template="../../app/templates/generic-edit.pt"
+        template="../templates/bugtracker-configure.pt"
         class="lp.bugs.browser.bugtarget.ProductConfigureBugTrackerView"/>
     <browser:page
         for="lp.registry.interfaces.product.IProduct"

=== added file 'lib/lp/bugs/templates/bugtracker-configure.pt'
--- lib/lp/bugs/templates/bugtracker-configure.pt	1970-01-01 00:00:00 +0000
+++ lib/lp/bugs/templates/bugtracker-configure.pt	2012-01-10 15:02:49 +0000
@@ -0,0 +1,59 @@
+<html
+  xmlns="http://www.w3.org/1999/xhtml";
+  xmlns:tal="http://xml.zope.org/namespaces/tal";
+  xmlns:metal="http://xml.zope.org/namespaces/metal";
+  xmlns:i18n="http://xml.zope.org/namespaces/i18n";
+  metal:use-macro="view/macro:page/main_only"
+  i18n:domain="launchpad">
+
+    <metal:block fill-slot="head_epilogue">
+        <script type="text/javascript">
+            LPS.use('node', function(Y) {
+                // Constrain enable_bug_expiration to the Launchpad Bugs radio input.
+                // The Launchpad bug tracker is either the first item in a product's
+                // bugtracker field, or it is a distribution's official_malone field.
+                Y.on('load', function (e) {
+                    debugger;
+                    var bug_tracker_input = Y.one('[id=field.bugtracker.0]');
+                    if (!bug_tracker_input) {
+                        bug_tracker_input = Y.one('[id=field.official_malone]');
+                    }
+                    var bug_expiration_input = Y.one('[id=field.enable_bug_expiration]');
+                    if (!bug_tracker_input || !bug_expiration_input) {
+                        return;
+                    }
+                    // Disable enable_bug_expiration onload if Launchpad is not the
+                    // bug tracker.
+                    if (!bug_tracker_input.get('checked')) {
+                        bug_expiration_input.get('disabled') = true;
+                    }
+
+                    var constraint = function (e) {
+                        if (bug_tracker_input.get('checked')) {
+                            bug_expiration_input.disabled = false;
+                            bug_expiration_input.checked = true;
+                        } else {
+                            bug_expiration_input.checked = false;
+                            bug_expiration_input.disabled = true;
+                        }
+                    };
+
+                    var inputs = Y.all('input');
+                    inputs.each(function (input) {
+                        var name = input.get('name');
+                        if (name == 'field.bugtracker' ||
+                            name == 'field.official_malone') {
+                            input.on('click', constraint);
+                        }
+                    });
+                });
+            });
+        </script>
+    </metal:block>
+
+    <body>
+        <div metal:fill-slot="main">
+          <div metal:use-macro="context/@@launchpad_form/form" />
+        </div>
+    </body>
+</html>