launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04483
[Merge] lp:~wallyworld/launchpad/only-one-picker-expander-open-819580 into lp:launchpad
Ian Booth has proposed merging lp:~wallyworld/launchpad/only-one-picker-expander-open-819580 into lp:launchpad with lp:~wallyworld/launchpad/expander-groups as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #819580 in Launchpad itself: "Allow a set of expanders to operate like radio buttons"
https://bugs.launchpad.net/launchpad/+bug/819580
For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/only-one-picker-expander-open-819580/+merge/70393
The branch wire up pickers to use the new expander group functionality.
== Implementation ==
Simply pass in a group_id config value when the picker expander is constructed.
== Demo and QA ==
Open a bug task assignee picker, perform a search and click an expander to show details for an entry. Click another expander and the first opened one should close as the newly selected one opens.
== Tests ==
Write 2 new picker tests:
test_expander_only_one_open
test_expander_multiple_pickers
== Lint ==
Linting changed files:
lib/lp/app/javascript/picker/picker.js
lib/lp/app/javascript/picker/tests/test_picker.js
./lib/lp/app/javascript/picker/picker.js
67: 'Picker' has not been fully defined yet.
--
https://code.launchpad.net/~wallyworld/launchpad/only-one-picker-expander-open-819580/+merge/70393
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/only-one-picker-expander-open-819580 into lp:launchpad.
=== added file 'lib/lp/answers/templates/question-portlet-subscribers.pt'
--- lib/lp/answers/templates/question-portlet-subscribers.pt 1970-01-01 00:00:00 +0000
+++ lib/lp/answers/templates/question-portlet-subscribers.pt 2011-07-29 06:58:45 +0000
@@ -0,0 +1,17 @@
+<tal:root
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ omit-tag="">
+
+<div class="portlet" id="subscribers">
+ <h2>Subscribers</h2>
+ <div id="current_user_subscription" tal:define="menu context/menu:answers">
+ <div tal:content="structure menu/subscription/render" />
+ </div>
+ <div tal:define="menu context/menu:answers">
+ <div tal:content="structure menu/addsubscriber/render" />
+ </div>
+ <div id="other-question-subscribers"></div>
+</div>
+</tal:root>
=== modified file 'lib/lp/app/javascript/picker/picker.js'
--- lib/lp/app/javascript/picker/picker.js 2011-08-04 15:47:10 +0000
+++ lib/lp/app/javascript/picker/picker.js 2011-08-04 23:58:52 +0000
@@ -504,6 +504,7 @@
Y.Event.purgeElement(this._results_box, true);
this._results_box.set('innerHTML', '');
+ var expander_id = this.get(BOUNDING_BOX).get('id');
Y.Array.each(results, function(data, i) {
// Sort out the badges div.
var li_badges = this._renderBadgesUI(data);
@@ -534,7 +535,7 @@
// Use explicit save link.
li.appendChild(li_details);
li.expander = new Y.lp.app.widgets.expander.Expander(
- summary_node, li_details);
+ summary_node, li_details, {group_id: expander_id});
li.expander.setUp();
} else {
// Attach implicit save handler.
@@ -637,17 +638,17 @@
search_box.insertBefore(this._search_button, this._search_input);
search_box.addClass(C_SEARCH_BOX);
- this._search_slot_box = Y.Node.create('<div></div');
+ this._search_slot_box = Y.Node.create('<div></div>');
this._search_slot_box.addClass(C_SEARCH_SLOT);
search_box.appendChild(this._search_slot_box);
this._results_box = Y.Node.create('<ul></ul>');
this._results_box.addClass(C_RESULTS);
- this._batches_box = Y.Node.create('<div></div');
+ this._batches_box = Y.Node.create('<div></div>');
this._batches_box.addClass(C_BATCHES);
- this._footer_slot_box = Y.Node.create('<div></div');
+ this._footer_slot_box = Y.Node.create('<div></div>');
this._footer_slot_box.addClass(C_FOOTER_SLOT);
var body = Y.Node.create('<div></div>');
=== modified file 'lib/lp/app/javascript/picker/tests/test_picker.js'
--- lib/lp/app/javascript/picker/tests/test_picker.js 2011-08-04 15:18:04 +0000
+++ lib/lp/app/javascript/picker/tests/test_picker.js 2011-08-04 23:58:52 +0000
@@ -1,7 +1,7 @@
/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
YUI().use('lp.testing.runner', 'test', 'console', 'node', 'lazr.picker',
- 'event', 'event-simulate', 'dump', function(Y) {
+ 'event', 'node-event-simulate', 'dump', function(Y) {
// Local aliases
var Assert = Y.Assert,
@@ -149,7 +149,7 @@
title_link: 'http://somewhere.com',
alt_title_link: 'http://somewhereelse.com',
link_css: 'cool-style',
- details: ['Member since 2007'],
+ details: ['Member since 2007']
}
]);
@@ -228,6 +228,74 @@
details.one('ul li:first-child a').getContent('text'));
},
+ test_expander_only_one_open: function() {
+ // Only one expanded details entry should be open at any time.
+ this.picker.render();
+ this.picker.set('results', [
+ {
+ value: 'jschmo',
+ title: 'Joe Schmo',
+ details: ['detail 1', 'detail 2']
+ },
+ {
+ value: 'jsmith',
+ title: 'Joe Smith',
+ details: ['detail 1', 'detail 2']
+ }
+ ]);
+ var bb = this.picker.get('boundingBox');
+ var first_entry = bb.one('.yui3-picker-results li');
+ var first_expander = first_entry.expander;
+ var second_entry = bb.one('.yui3-picker-results li.yui3-lazr-odd');
+ var second_expander = second_entry.expander;
+ first_expander.icon_node.simulate('click');
+ Y.Assert.isTrue(first_expander.isExpanded());
+ Y.Assert.isFalse(second_expander.isExpanded());
+
+ // Open the other expander and check that the first one has closed.
+ second_expander.icon_node.simulate('click');
+ Y.Assert.isFalse(first_expander.isExpanded());
+ Y.Assert.isTrue(second_expander.isExpanded());
+ },
+
+ test_expander_multiple_pickers: function() {
+ // Expanders for one picker should not interfere with those for
+ // another picker. ie if Picker A expander is opened, any open
+ // expanders on Picker B should remain open.
+ var results = [
+ {
+ value: 'jschmo',
+ title: 'Joe Schmo',
+ details: ['detail 1', 'detail 2']
+ },
+ {
+ value: 'jsmith',
+ title: 'Joe Smith',
+ details: ['detail 1', 'detail 2']
+ }
+ ];
+ this.picker.render();
+ this.picker.set('results', results);
+
+ var another_picker = new Y.lazr.picker.Picker();
+ another_picker.render();
+ another_picker.set('results', results);
+
+ var bb = this.picker.get('boundingBox');
+ var picker_entry = bb.one('.yui3-picker-results li');
+ var picker_expander = picker_entry.expander;
+ picker_expander.icon_node.simulate('click');
+
+ bb = another_picker.get('boundingBox');
+ var another_picker_entry = bb.one('.yui3-picker-results li');
+ var another_picker_expander = another_picker_entry.expander;
+ another_picker_expander.icon_node.simulate('click');
+
+ Y.Assert.isTrue(picker_expander.isExpanded());
+ Y.Assert.isTrue(another_picker_expander.isExpanded());
+ cleanup_widget(another_picker);
+ },
+
test_details_save_link: function () {
// The select link the li's details saves the selection.
this.picker.render();
@@ -239,7 +307,7 @@
description: 'joe@xxxxxxxxxxx',
alt_title_link: 'http://somewhereelse.com',
link_css: 'cool-style',
- details: ['Member since 2007'],
+ details: ['Member since 2007']
}
]);
var bb = this.picker.get('boundingBox');
References