Merge lp:~bac/launchpad/productseries-js into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Curtis Hovey on 2010-03-19 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | not available |
| Proposed branch: | lp:~bac/launchpad/productseries-js |
| Merge into: | lp:launchpad |
| Diff against target: |
590 lines (+571/-0) 4 files modified
lib/lp/code/javascript/productseries-setbranch.js (+88/-0) lib/lp/code/javascript/tests/test_productseries-setbranch.html (+213/-0) lib/lp/code/javascript/tests/test_productseries_setbranch.js (+249/-0) lib/lp/code/windmill/tests/test_yuitests.py (+21/-0) |
| To merge this branch: | bzr merge lp:~bac/launchpad/productseries-js |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Curtis Hovey (community) | js and code | 2010-03-16 | Approve on 2010-04-02 |
|
Review via email:
|
|||
Commit Message
Provide javascript to control the behavior on the new productseries/
Description of the Change
= Summary =
While fixing bug 524302 functionality from several pages will be combined to provide
an unified view of branch creation/
to control the select enabling of the various fields based on the state of radiobuttons.
This branch provides that JS and the tests for it only.
== Proposed fix ==
Create a new JS module to control the status of the page elements based on the
radiobuttons.
== Pre-implementation notes ==
Long discussions with Curtis during our sprint.
== Implementation details ==
As above.
== Tests ==
Load lib/canonical/
into a browser and ensure all tests pass.
== Demo and Q/A ==
N/A
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/canonical
lib/canonical
lib/canonical
== JSLint notices ==
jslint: Lint found in
'/home/
Line 84 character 22: 'rcs_types' is already defined.
var rcs_types = module.
jslint: No problem found in
'/home/
jslint: 2 files to lint.
I'll take care of these lint issues before landing.
| Brad Crittenden (bac) wrote : | # |
Thanks for the review Curtis and your help with the testing issues.
I've incorporated all of your suggestions, cleaned up the testing, and added support for two new fields: branch_name and branch_owner.
Incremental diff at http://
| Curtis Hovey (sinzui) wrote : | # |
This looks good to land, but I ask that you refrain until YUI unittests run automatically.
> === renamed file 'lib/canonical/
> --- lib/canonical/
> +++ lib/canonical/
...
> + module.setup = function() {
> + Y.all('
> + field.on('click', module.
> + Y.all('
> + field.on('click', module.
I think these could use the ListNode.on() method to make the code a little
easier to read.
...
> === renamed file 'lib/canonical/
> --- lib/canonical/
> +++ lib/canonical/
...
> @@ -48,31 +50,50 @@
>
> tearDown: function() {
> delete this.tbody;
> - },
> + },
>
> test_handlers_
> - Y.Assert.
> - this.link_
> - 'branch type onclick handler not correct');
> - Y.Assert.
> - this.create_
> - 'branch type onclick handler not correct');
> - Y.Assert.
> - this.import_
> - 'branch type onclick handler not correct');
> -
> + // Manually invoke the setup function to ensure the handlers are set.+ module.setup();
Wrap the code at 78 characters.
...
@@ -202,7 +234,8 @@
var console = new Y.Console(
console.
- Y.on('domready', function() {
+ // Start the test runner on Y.after to ensure all setup has had a chance to complete.
Wrap the code at 78 characters.
...

This is a very good start Brad. I have some concerns about using the underlying js engine. I
have some proposals that use YUI to minimise engine problems. There are some style issue I think
need fixing too. The test is very nice, and it will prove useful when refactoring some of this
library.
> === added file 'lib/canonical/ launchpad/ javascript/ registry/ productseries- setbranch. js' launchpad/ javascript/ registry/ productseries- setbranch. js 1970-01-01 00:00:00 +0000 launchpad/ javascript/ registry/ productseries- setbranch. js 2010-03-16 20:32:39 +0000 +setbranch page. productseries_ setbranch
> --- lib/canonical/
> +++ lib/canonical/
> @@ -0,0 +1,93 @@
> +/* Copyright 2010 Canonical Ltd. This software is licensed under the
> + * GNU Affero General Public License version 3 (see the file LICENSE).
> + *
> + * Control enabling/disabling of complex form on the
> + * productseries/
> + *
> + * @module Y.registry.
> + * @requires node
> + */
This module require DOM too.
Is registry the correct location for this script? I think the code module
may be better. Consider a project that will never have code/branches; this
code will never be used. I think the code and bug configurations belong in
their respective apps. My test for placing code in registry is to ask
what happens if the app is removed? If we remove Launchpad Code, this
script would have to be removed in a separate effort.
> +YUI.add( 'registry. productseries_ setbranch' , function(Y) { productseries_ setbranch' ); 'registry. productseries_ setbranch' ); _getSelectedRCS = function() {
> + Y.log('loading registry.
> + var module = Y.namespace(
> +
> + module.
We use PEP 8 for function and method names. These names should be lower
case with underscores. When you see someone setting a module method with
studlyCaps, it is probably because that method is defined in a prototype
or event.
Review all your method names.
> + var rcs_types = module. _rcs_types( ); i].checked) { getElementsByNa me('field. rcs_type' ); field_id) ; onclickRcsType = function() { _rcs_types( ); _getSelectedRCS (); setEnabled( 'field. cvs_module' , selectedRCS == 'CVS');
> + var selected = 'None';
> + for (var i = 0; i < rcs_types.length; i++) {
> + if (rcs_types[
> + selected = rcs_types[i].value;
> + break;
> + }
> + }
> + return selected;
> + };
> +
> + module.__rcs_types = null;
> +
> + module._rcs_types = function() {
> + if (module.__rcs_types === null) {
> + module.__rcs_types = document.
> + }
> + return module.__rcs_types;
> + };
> +
> + module.setEnabled = function(field_id, is_enabled) {
> + var field = Y.DOM.byId(
> + field.disabled = !is_enabled;
> + };
> +
> + module.
> + /* Which rcs type radio button has been selected? */
> + // CVS
> + var rcs_types = module.
> + var selectedRCS = module.
> + module.
> + };
Event handler functions receive an event argument, traditionally named 'e'
module. onclick_ rcs_type = function(e) {
You need to update all of these methods, though you are not required to
use e, so no other changes are needed.
> + module. onclickBranchTy pe = f...