launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05872
[Merge] lp:~adeuring/launchpad/history-model into lp:launchpad
Abel Deuring has proposed merging lp:~adeuring/launchpad/history-model into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~adeuring/launchpad/history-model/+merge/84973
This branch add several sort options to the sorting widget of the new
bug listing pages, so that all fields that are displayed can also be
used for sorting. (@@ -669,16 +676,28 @@ in
lib/lp/bugs/templates/bugtask-macros-tableview.pt)
The second change : A sort button is displayed if the corresponding
data displayed or if it represents the current sort order. We want
to show only sort buttons for fields that are displayed, but there
is a corner case:
- A user selects for example "sort by bug ID"
- the user hides the bug ID
If we hide the "sort by bug ID" button at the same time when the
bug IDs are hidden, the currently selected sorting would be hidden
too. I think this would be confusing ("is the sort order gone?").
Instead, the button "sort by bug ID" will disappear in the example above,
when the user selects another sort order. This may still be a bit
confusing but I think it is better than hiding the current sort order.
The biggest part of the diff is this synchronisation of the set of
displayed sort buttons with the set of displayed data.
The visibility of the sort buttons is changed in a callback for the
"history changed" event (lib/lp/bugs/templates/bugtask-macros-tableview.pt),
which calls update_sort_button_visibility(), defined in
lib/lp/bugs/javascript/buglisting_utils.js. This function builds
an associative array as needed by the new method
OrderByBar.updateVisibility() from the "visibility information" for
the bug data (properties show_.*). This is just an operation
"s/show_//" (aside from ensuring that the button for current sort order
is always shown).
The names of the visibility flags as needed for the sort order buttons
originate from the value of the URL query parameter "orderby" (which
also appear in the implementation of the class BugTaskSet) -- and some
of these names differed from the corresponding show_.* flags. At first
I used a "translation table" between the orderby values and the show_.*
names in update_sort_button_visibility() -- but this turned out to be
a bit error prone, so I decided to change the show_.* names so that
all of them match the corresponding orderby values. This mecahnical
change contributes ca 50% of the lines of the diff.
As a drive-by fix, I ensured that the button for current sort order
as specified in a URL is highlighted when a page is loaded (first hunk
in the diff of lib/lp/bugs/templates/bugtask-macros-tableview.pt)
tests:
./bin/test app -vvt javascript.ordering.tests.test_orderby_widget
./bin/test bugs -vvt javascript.tests.test_buglisting_utils
./bin/test bugs -vvt browser.tests.test_bugtask
no lint
--
https://code.launchpad.net/~adeuring/launchpad/history-model/+merge/84973
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~adeuring/launchpad/history-model into lp:launchpad.
=== modified file 'lib/lp/app/javascript/ordering/ordering.js'
--- lib/lp/app/javascript/ordering/ordering.js 2011-12-05 07:00:37 +0000
+++ lib/lp/app/javascript/ordering/ordering.js 2011-12-08 15:23:25 +0000
@@ -258,6 +258,15 @@
},
/**
+ * Get the sort key for a sort button.
+ *
+ * @method _sortKey
+ */
+ _sortKey: function(node) {
+ return node.get('id').replace('sort-', '');
+ },
+
+ /**
* Handle the click of one of the li nodes.
*
* @method _handleClick
@@ -265,8 +274,7 @@
_handleClick: function(clicked_node) {
// Reverse from the node's ID to the sort key, i.e.
// "sort-foo" gives us "foo" as the sort key.
- var clicked_node_sort_key = clicked_node.get('id').replace(
- 'sort-', '');
+ var clicked_node_sort_key = this._sortKey(clicked_node);
// Get a reference to what was active before click and update
// the "active" widget state.
var preclick_sort_key = this.get('active');
@@ -278,6 +286,28 @@
this._fireSortEvent();
},
+ /**
+ * Show or hide sort buttons.
+ *
+ * @method updateVisibility
+ */
+ updateVisibility: function(visibility) {
+ var that = this;
+ if (visibility === null) {
+ Y.each(this.get('li_nodes'), function(li_node) {
+ li_node.show();
+ });
+ } else {
+ Y.each(this.get('li_nodes'), function(li_node) {
+ var sort_key = that._sortKey(li_node);
+ if (visibility[sort_key]) {
+ li_node.show();
+ } else {
+ li_node.hide();
+ }
+ });
+ }
+ },
/**
* Create the bar, the li nodes used for buttons, and
=== modified file 'lib/lp/app/javascript/ordering/tests/test_orderby_widget.js'
--- lib/lp/app/javascript/ordering/tests/test_orderby_widget.js 2011-12-05 21:17:27 +0000
+++ lib/lp/app/javascript/ordering/tests/test_orderby_widget.js 2011-12-08 15:23:25 +0000
@@ -320,6 +320,36 @@
this.orderby.render();
var config_slot = Y.one('#test-div').one('.config-widget');
Assert.areEqual(config_slot, this.orderby.get('config_node'));
+ },
+
+ test_hide_show_sort_buttons: function() {
+ // By default, all sort buttons are shown.
+ this.orderby = new Y.lp.ordering.OrderByBar();
+ this.orderby.render();
+ Y.each(this.orderby.get('li_nodes'), function(node) {
+ Assert.isFalse(node._isHidden());
+ });
+
+ var visibility_rules = {
+ 'bugnumber': true,
+ 'bugtitle': true,
+ 'status': true,
+ 'importance': false,
+ 'bug-heat-icons': false,
+ 'package': false,
+ 'milestone': false,
+ 'assignee': false,
+ 'bug-age': false
+ };
+ this.orderby.updateVisibility(visibility_rules);
+ Y.each(this.orderby.get('li_nodes'), function(node) {
+ sort_name = node.get('id').replace('sort-', '');
+ if (visibility_rules[sort_name] === true) {
+ Assert.isFalse(node._isHidden());
+ } else {
+ Assert.isTrue(node._isHidden());
+ }
+ });
}
}));
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2011-12-07 05:31:16 +0000
+++ lib/lp/bugs/browser/bugtask.py 2011-12-08 15:23:25 +0000
@@ -2260,17 +2260,17 @@
self.target_context = target_context
self.user = getUtility(ILaunchBag).user
self.field_visibility_defaults = {
- 'show_age': False,
+ 'show_datecreated': False,
'show_assignee': False,
- 'show_bugtarget': True,
- 'show_bug_heat': True,
+ 'show_targetname': True,
+ 'show_heat': True,
'show_id': True,
'show_importance': True,
- 'show_last_updated': False,
+ 'show_date_last_updated': False,
'show_milestone_name': False,
'show_reporter': False,
'show_status': True,
- 'show_tags': False,
+ 'show_tag': False,
}
self.field_visibility = None
self._setFieldVisibility()
=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
--- lib/lp/bugs/browser/tests/test_bugtask.py 2011-12-06 19:17:39 +0000
+++ lib/lp/bugs/browser/tests/test_bugtask.py 2011-12-08 15:23:25 +0000
@@ -2031,26 +2031,26 @@
"""Cache contains cookie-matching values for field_visibiliy."""
task = self.factory.makeBugTask()
cookie = (
- 'anon-buglist-fields=show_age=true&show_reporter=true'
- '&show_id=true&show_bugtarget=true'
- '&show_milestone_name=true&show_last_updated=true'
- '&show_assignee=true&show_bug_heat=true&show_tags=true'
+ 'anon-buglist-fields=show_datecreated=true&show_reporter=true'
+ '&show_id=true&show_targetname=true'
+ '&show_milestone_name=true&show_date_last_updated=true'
+ '&show_assignee=true&show_heat=true&show_tag=true'
'&show_importance=true&show_status=true')
with self.dynamic_listings():
view = self.makeView(
task, memo=1, forwards=False, size=1, cookie=cookie)
cache = IJSONRequestCache(view.request)
field_visibility = cache.objects['field_visibility']
- self.assertTrue(field_visibility['show_tags'])
+ self.assertTrue(field_visibility['show_tag'])
def test_exclude_unsupported_cookie_values(self):
"""Cookie values not present in defaults are ignored."""
task = self.factory.makeBugTask()
cookie = (
- 'anon-buglist-fields=show_age=true&show_reporter=true'
- '&show_id=true&show_bugtarget=true'
- '&show_milestone_name=true&show_last_updated=true'
- '&show_assignee=true&show_bug_heat=true&show_tags=true'
+ 'anon-buglist-fields=show_datecreated=true&show_reporter=true'
+ '&show_id=true&show_targetname=true'
+ '&show_milestone_name=true&show_date_last_updated=true'
+ '&show_assignee=true&show_heat=true&show_tag=true'
'&show_importance=true&show_status=true&show_title=true')
with self.dynamic_listings():
view = self.makeView(
@@ -2063,10 +2063,10 @@
"""Where cookie values are missing, defaults are used"""
task = self.factory.makeBugTask()
cookie = (
- 'anon-buglist-fields=show_age=true&show_reporter=true'
- '&show_id=true&show_bugtarget=true'
- '&show_milestone_name=true&show_last_updated=true'
- '&show_assignee=true&show_bug_heat=true&show_tags=true'
+ 'anon-buglist-fields=show_datecreated=true&show_reporter=true'
+ '&show_id=true&show_targetname=true'
+ '&show_milestone_name=true&show_date_last_updated=true'
+ '&show_assignee=true&show_heat=true&show_tag=true'
'&show_importance=true&show_title=true')
with self.dynamic_listings():
view = self.makeView(
@@ -2185,7 +2185,7 @@
navigator, mustache_model = self.getNavigator()
self.assertIn('bugtarget1', navigator.mustache)
self.assertIn('bugtarget_css1', navigator.mustache)
- mustache_model['bugtasks'][0]['show_bugtarget'] = False
+ mustache_model['bugtasks'][0]['show_targetname'] = False
self.assertNotIn('bugtarget1', navigator.mustache)
self.assertNotIn('bugtarget_css1', navigator.mustache)
@@ -2194,7 +2194,7 @@
navigator, mustache_model = self.getNavigator()
self.assertIn('bug_heat_html1', navigator.mustache)
self.assertIn('bug-heat-icons', navigator.mustache)
- mustache_model['bugtasks'][0]['show_bug_heat'] = False
+ mustache_model['bugtasks'][0]['show_heat'] = False
self.assertNotIn('bug_heat_html1', navigator.mustache)
self.assertNotIn('bug-heat-icons', navigator.mustache)
@@ -2216,17 +2216,17 @@
def test_hiding_age(self):
"""Showing age shows the text."""
navigator, mustache_model = self.getNavigator()
- self.assertIn('show_age', navigator.field_visibility)
+ self.assertIn('show_datecreated', navigator.field_visibility)
self.assertNotIn('age1', navigator.mustache)
- mustache_model['bugtasks'][0]['show_age'] = True
+ mustache_model['bugtasks'][0]['show_datecreated'] = True
self.assertIn('age1', navigator.mustache)
def test_hiding_tags(self):
"""Showing tags shows the text."""
navigator, mustache_model = self.getNavigator()
- self.assertIn('show_tags', navigator.field_visibility)
+ self.assertIn('show_tag', navigator.field_visibility)
self.assertNotIn('tags1', navigator.mustache)
- mustache_model['bugtasks'][0]['show_tags'] = True
+ mustache_model['bugtasks'][0]['show_tag'] = True
self.assertIn('tags1', navigator.mustache)
def test_hiding_reporter(self):
@@ -2240,9 +2240,9 @@
def test_hiding_last_updated(self):
"""Showing last_updated shows the text."""
navigator, mustache_model = self.getNavigator()
- self.assertIn('show_last_updated', navigator.field_visibility)
+ self.assertIn('show_date_last_updated', navigator.field_visibility)
self.assertNotIn('Last updated updated1', navigator.mustache)
- mustache_model['bugtasks'][0]['show_last_updated'] = True
+ mustache_model['bugtasks'][0]['show_date_last_updated'] = True
self.assertIn('Last updated updated1', navigator.mustache)
=== modified file 'lib/lp/bugs/javascript/buglisting_utils.js'
--- lib/lp/bugs/javascript/buglisting_utils.js 2011-12-05 06:27:11 +0000
+++ lib/lp/bugs/javascript/buglisting_utils.js 2011-12-08 15:23:25 +0000
@@ -52,14 +52,14 @@
show_id: 'Bug number',
show_importance: 'Importance',
show_status: 'Status',
- show_bug_heat: 'Bug heat',
- show_bugtarget: 'Package/Project/Series name',
- show_age: 'Bug age',
- show_last_updated: 'Date bug last updated',
+ show_heat: 'Bug heat',
+ show_targetname: 'Package/Project/Series name',
+ show_datecreated: 'Bug age',
+ show_date_last_updated: 'Date bug last updated',
show_assignee: 'Assignee',
show_reporter: 'Reporter',
show_milestone_name: 'Milestone',
- show_tags: 'Bug tags'
+ show_tag: 'Bug tags'
};
BugListingConfigUtil.ATTRS = {
@@ -339,6 +339,39 @@
var buglisting_utils = Y.namespace('lp.buglisting_utils');
buglisting_utils.BugListingConfigUtil = BugListingConfigUtil;
+ /**
+ * Update the visibilty of the sort buttons.
+ *
+ * We want to display only the sort buttons for fields which
+ * are displayed. To avoid surprises for users, the current sort
+ * order is always displayed, even when the related data is not
+ * shown.
+ *
+ * @param orderbybar {Object} The order by bar.
+ * @param data_visibility {Associative Array} The visibility data
+ * as used in Y.bugs.buglisting.BugListingModel.
+ */
+ function update_sort_button_visibility(orderbybar, data_visibility) {
+ // We must translate the field names as used by
+ // BugListingConfigUtil to those used by the "order by" buttons.
+ var orderby_visibility = {};
+ var order_key;
+ var data_key;
+ for (data_key in data_visibility) {
+ if (data_visibility.hasOwnProperty(data_key) &&
+ data_key.substring(0, 5) === 'show_') {
+ order_key = data_key.replace('show_', '');
+ orderby_visibility[order_key] = data_visibility[data_key];
+ }
+ }
+ // Never hide the button for the current sort order.
+ orderby_visibility[orderbybar.get('active')] = true;
+ orderbybar.updateVisibility(orderby_visibility);
+ }
+
+ buglisting_utils.update_sort_button_visibility =
+ update_sort_button_visibility;
+
}, '0.1', {'requires': [
'cookie', 'history', 'lp.configutils', 'lazr.formoverlay',
'lp.bugs.buglisting'
=== modified file 'lib/lp/bugs/javascript/tests/test_buglisting_utils.html'
--- lib/lp/bugs/javascript/tests/test_buglisting_utils.html 2011-11-28 21:28:44 +0000
+++ lib/lp/bugs/javascript/tests/test_buglisting_utils.html 2011-12-08 15:23:25 +0000
@@ -30,6 +30,8 @@
<script type="text/javascript"
src="../../../app/javascript/expander.js"></script>
<script type="text/javascript"
+ src="../../../app/javascript/ordering/ordering.js"></script>
+ <script type="text/javascript"
src="../../../app/javascript/overlay/overlay.js"></script>
<script type="text/javascript" src="../buglisting.js"></script>
@@ -44,5 +46,6 @@
<ul id="suites">
<li>lp.buglisting_utils.test</li>
</ul>
+ <div id="bugs-orderby"></div>
</body>
</html>
=== modified file 'lib/lp/bugs/javascript/tests/test_buglisting_utils.js'
--- lib/lp/bugs/javascript/tests/test_buglisting_utils.js 2011-11-28 21:28:44 +0000
+++ lib/lp/bugs/javascript/tests/test_buglisting_utils.js 2011-12-08 15:23:25 +0000
@@ -22,14 +22,14 @@
show_id: false,
show_importance: false,
show_status: true,
- show_bug_heat: true,
- show_bugtarget: true,
- show_age: false,
- show_last_updated: false,
+ show_heat: true,
+ show_targetname: true,
+ show_datecreated: false,
+ show_date_last_updated: false,
show_assignee: false,
show_reporter: false,
show_milestone_name: false,
- show_tags: false
+ show_tag: false
},
field_visibility_defaults: {
@@ -37,14 +37,14 @@
show_id: true,
show_importance: true,
show_status: true,
- show_bug_heat: true,
- show_bugtarget: true,
- show_age: false,
- show_last_updated: false,
+ show_heat: true,
+ show_targetname: true,
+ show_datecreated: false,
+ show_date_last_updated: false,
show_assignee: false,
show_reporter: false,
show_milestone_name: false,
- show_tags: false
+ show_tag: false
}
};
// _setDoc is required for tests using cookies to pass.
@@ -130,14 +130,14 @@
show_id: true,
show_importance: true,
show_status: true,
- show_bug_heat: false,
- show_bugtarget: false,
- show_age: true,
- show_last_updated: true,
+ show_heat: false,
+ show_targetname: false,
+ show_datecreated: true,
+ show_date_last_updated: true,
show_assignee: false,
show_reporter: false,
show_milestone_name: false,
- show_tags: false
+ show_tag: false
};
Y.Cookie.setSubs(this.cookie_name, expected_config);
this.list_util = new Y.lp.buglisting_utils.BugListingConfigUtil(
@@ -166,14 +166,14 @@
'show_id',
'show_importance',
'show_status',
- 'show_bug_heat',
- 'show_bugtarget',
- 'show_age',
- 'show_last_updated',
+ 'show_heat',
+ 'show_targetname',
+ 'show_datecreated',
+ 'show_date_last_updated',
'show_assignee',
'show_reporter',
'show_milestone_name',
- 'show_tags'
+ 'show_tag'
];
var expected_checked = [
true,
@@ -200,7 +200,7 @@
var field_visibility = Y.merge(
this.defaults.field_visibility_defaults, {
show_status: false,
- show_bug_heat: false
+ show_heat: false
});
this.list_util = new Y.lp.buglisting_utils.BugListingConfigUtil({
field_visibility: field_visibility,
@@ -212,14 +212,14 @@
'show_id',
'show_importance',
'show_status',
- 'show_bug_heat',
- 'show_bugtarget',
- 'show_age',
- 'show_last_updated',
+ 'show_heat',
+ 'show_targetname',
+ 'show_datecreated',
+ 'show_date_last_updated',
'show_assignee',
'show_reporter',
'show_milestone_name',
- 'show_tags'
+ 'show_tag'
];
var expected_checked = [
true,
@@ -260,10 +260,10 @@
this.list_util.render();
var config = Y.one('.config');
config.simulate('click');
- var show_bugtarget = Y.one('.show_bugtarget');
- var show_bug_heat = Y.one('.show_bug_heat');
- show_bugtarget.simulate('click');
- show_bug_heat.simulate('click');
+ var show_targetname = Y.one('.show_targetname');
+ var show_heat = Y.one('.show_heat');
+ show_targetname.simulate('click');
+ show_heat.simulate('click');
var update = Y.one('.update-buglisting');
update.simulate('click');
var expected_config = {
@@ -271,14 +271,14 @@
show_id: false,
show_importance: false,
show_status: true,
- show_bug_heat: false,
- show_bugtarget: false,
- show_age: false,
- show_last_updated: false,
+ show_heat: false,
+ show_targetname: false,
+ show_datecreated: false,
+ show_date_last_updated: false,
show_assignee: false,
show_reporter: false,
show_milestone_name: false,
- show_tags: false
+ show_tag: false
};
var model = this.list_util.get('model');
var actual_config = model.get_field_visibility();
@@ -292,8 +292,8 @@
this.list_util.render();
var config = Y.one('.config');
config.simulate('click');
- var show_bugtarget = Y.one('.show_bugtarget');
- show_bugtarget.simulate('click');
+ var show_targetname = Y.one('.show_targetname');
+ show_targetname.simulate('click');
var update = Y.one('.update-buglisting');
update.simulate('click');
var overlay = this.list_util.get('form').get('boundingBox');
@@ -309,8 +309,8 @@
// Now poke at the page to set the cookie.
var config = Y.one('.config');
config.simulate('click');
- var show_bugtarget = Y.one('.show_bugtarget');
- show_bugtarget.simulate('click');
+ var show_targetname = Y.one('.show_targetname');
+ show_targetname.simulate('click');
var update = Y.one('.update-buglisting');
update.simulate('click');
var expected_config = {
@@ -318,14 +318,14 @@
show_id: false,
show_importance: false,
show_status: true,
- show_bug_heat: true,
- show_bugtarget: false,
- show_age: false,
- show_last_updated: false,
+ show_heat: true,
+ show_targetname: false,
+ show_datecreated: false,
+ show_date_last_updated: false,
show_assignee: false,
show_reporter: false,
show_milestone_name: false,
- show_tags: false
+ show_tag: false
};
var expected_cookie = Y.Cookie._createCookieHashString(
expected_config);
@@ -337,8 +337,8 @@
// Clicking "reset to defaults" on the form returns
// field_visibility to its default values.
var field_visibility = {
- show_bugtarget: true,
- show_bug_heat: false
+ show_targetname: true,
+ show_heat: false
};
this.list_util = new Y.lp.buglisting_utils.BugListingConfigUtil({
field_visibility: field_visibility,
@@ -358,8 +358,8 @@
test_fields_visibility_form_reset_hides_overlay: function() {
// Reseting to defaults should hide the form overlay.
var field_visibility = {
- show_bugtarget: true,
- show_bug_heat: false
+ show_targetname: true,
+ show_heat: false
};
this.list_util = new Y.lp.buglisting_utils.BugListingConfigUtil({
field_visibility: field_visibility,
@@ -378,8 +378,8 @@
// Reseting to defaults should reset the form inputs, too.
var field_visibility = Y.merge(
this.defaults.field_visibility_defaults, {
- show_bugtarget: false,
- show_bug_heat: false
+ show_targetname: false,
+ show_heat: false
});
this.list_util = new Y.lp.buglisting_utils.BugListingConfigUtil({
field_visibility: field_visibility,
@@ -391,14 +391,14 @@
'show_id',
'show_importance',
'show_status',
- 'show_bug_heat',
- 'show_bugtarget',
- 'show_age',
- 'show_last_updated',
+ 'show_heat',
+ 'show_targetname',
+ 'show_datecreated',
+ 'show_date_last_updated',
'show_assignee',
'show_reporter',
'show_milestone_name',
- 'show_tags'
+ 'show_tag'
];
var expected_checked = [
true,
@@ -432,8 +432,8 @@
// Now poke at the page to set the cookie.
var config = Y.one('.config');
config.simulate('click');
- var show_bugtarget = Y.one('.show_bugtarget');
- show_bugtarget.simulate('click');
+ var show_targetname = Y.one('.show_targetname');
+ show_targetname.simulate('click');
var update = Y.one('.update-buglisting');
update.simulate('click');
// Now reset from the form.
@@ -441,6 +441,63 @@
Y.one('.reset-buglisting').simulate('click');
var cookie = Y.Cookie.get(this.cookie_name);
Assert.areSame('', cookie);
+ },
+
+ test_update_sort_button_visibility: function() {
+ // update_sort_button_visibility() hides sort buttons for
+ // data that is not displayed and shown sort buttons for other
+ // data.
+ var orderby = new Y.lp.ordering.OrderByBar({
+ sort_keys: [
+ ['id', 'Bug number'],
+ ['title', 'Bug title'],
+ ['importance', 'Importance'],
+ ['status', 'Status'],
+ ['heat', 'Bug heat'],
+ ['reporter', 'Reporter'],
+ ['assignee', 'Assignee'],
+ ['targetname', 'Package/Project/Series name'],
+ ['milestone_name', 'Milestone'],
+ ['datecreated', 'Bug age'],
+ ['date_last_updated', 'Date bug last updated'],
+ ['tag', 'Bug Tags']
+ ],
+ active: 'importance',
+ sort_order: 'desc'
+ });
+ orderby.render();
+ var data_visibility = {
+ show_title: true,
+ show_id: false,
+ show_importance: true,
+ show_status: true,
+ show_heat: true,
+ show_targetname: true,
+ show_datecreated: false,
+ show_date_last_updated: false,
+ show_assignee: false,
+ show_reporter: false,
+ show_milestone_name: false,
+ show_tag: true
+ };
+ Y.lp.buglisting_utils.update_sort_button_visibility(
+ orderby, data_visibility);
+ Y.each(orderby.get('li_nodes'), function(li_node) {
+ var sort_key = li_node.get('id').replace('sort-', '');
+ if (data_visibility['show_' + sort_key]) {
+ Assert.isFalse(li_node._isHidden());
+ } else {
+ Assert.isTrue(li_node._isHidden());
+ }
+ });
+
+ // The current sort order (importance for this test) is
+ // never hidden, even if the bug importance is not displayed.
+ data_visibility.show_importance = false;
+ Y.lp.buglisting_utils.update_sort_button_visibility(
+ orderby, data_visibility);
+ importance_button = Y.one('#sort-importance');
+ Assert.isFalse(importance_button._isHidden());
}
}));
@@ -448,4 +505,5 @@
buglisting_utils.suite = suite;
}, '0.1', {'requires': [
- 'test', 'node-event-simulate', 'cookie', 'lp.buglisting_utils']});
+ 'test', 'node-event-simulate', 'cookie', 'lp.buglisting_utils',
+ 'lp.ordering']});
=== modified file 'lib/lp/bugs/templates/buglisting.mustache'
--- lib/lp/bugs/templates/buglisting.mustache 2011-12-06 19:17:39 +0000
+++ lib/lp/bugs/templates/buglisting.mustache 2011-12-08 15:23:25 +0000
@@ -23,11 +23,11 @@
<a href="{{bug_url}}" class="bugtitle">{{title}}</a>
</div>
<div class="buginfo-extras">
- {{#show_bugtarget}}
+ {{#show_targetname}}
<span class="{{bugtarget_css}} field">
{{bugtarget}}
</span>
- {{/show_bugtarget}}
+ {{/show_targetname}}
{{#show_milestone_name}}
<span class="sprite milestone field">
{{#milestone_name}}
@@ -38,11 +38,11 @@
{{/milestone_name}}
</span>
{{/show_milestone_name}}
- {{#show_last_updated}}
+ {{#show_date_last_updated}}
<span class="sprite milestone field">
Last updated {{last_updated}}
</span>
- {{/show_last_updated}}
+ {{/show_date_last_updated}}
{{#show_assignee}}
<span class="sprite person field">
{{#assignee}}Assignee: {{assignee}}{{/assignee}}
@@ -54,26 +54,26 @@
Reporter: {{reporter}}
</span>
{{/show_reporter}}
- {{#show_age}}
+ {{#show_datecreated}}
<span class="sprite milestone field">
{{age}}
</span>
- {{/show_age}}
- {{#show_tags}}
+ {{/show_datecreated}}
+ {{#show_tag}}
<span class="field">Tags:
{{#tags}}{{tags}}{{/tags}}
{{^tags}}None{{/tags}}
</span>
- {{/show_tags}}
+ {{/show_tag}}
</div>
</div>
<div class="buglisting-col3">
- {{#show_bug_heat}}
+ {{#show_heat}}
<span class="bug-heat-icons">
{{{bug_heat_html}}}
</span>
- {{/show_bug_heat}}
+ {{/show_heat}}
<span class="bug-related-icons">
{{{badges}}}
</span>
=== modified file 'lib/lp/bugs/templates/bugtask-macros-tableview.pt'
--- lib/lp/bugs/templates/bugtask-macros-tableview.pt 2011-12-06 16:36:16 +0000
+++ lib/lp/bugs/templates/bugtask-macros-tableview.pt 2011-12-08 15:23:25 +0000
@@ -662,6 +662,13 @@
if (Y.Lang.isNull(navigator)){
return;
}
+ var active_sort_key = LP.cache.order_by;
+ var sort_order = 'asc';
+ if (active_sort_key.charAt(0) === '-') {
+ active_sort_key = active_sort_key.substring(
+ 1, active_sort_key.length);
+ sort_order = 'desc';
+ }
var orderby = new Y.lp.ordering.OrderByBar({
srcNode: Y.one('#bugs-orderby'),
sort_keys: [
@@ -669,16 +676,28 @@
['title', 'Bug title'],
['importance', 'Importance'],
['status', 'Status'],
- ['heat', 'Bug heat']
+ ['heat', 'Bug heat'],
+ ['reporter', 'Reporter'],
+ ['assignee', 'Assignee'],
+ ['targetname', 'Package/Project/Series name'],
+ ['milestone_name', 'Milestone'],
+ ['datecreated', 'Bug age'],
+ ['date_last_updated', 'Date bug last updated'],
+ ['tag', 'Bug Tags']
],
- active: 'importance',
- sort_order: 'desc',
+ active: active_sort_key,
+ sort_order: sort_order,
config_slot: true
});
orderby.render();
Y.on('orderbybar:sort', function(e) {
navigator.first_batch(e);
});
+ navigator.get('model').get('history').after(
+ 'change', function(e) {
+ Y.lp.buglisting_utils.update_sort_button_visibility(
+ orderby, e.newVal);
+ });
var config_node = orderby.get('config_node');
var list_util = new Y.lp.buglisting_utils.BugListingConfigUtil({
srcNode: config_node,
@@ -688,6 +707,8 @@
Y.on('buglisting-config-util:fields-changed', function(e) {
navigator.change_fields(list_util.get('field_visibility'));
});
+ Y.lp.buglisting_utils.update_sort_button_visibility(
+ orderby, navigator.get('model').get_field_visibility());
});
});
</script>