=== modified file 'lib/lp/app/javascript/picker/picker_patcher.js'
--- lib/lp/app/javascript/picker/picker_patcher.js 2012-09-07 14:42:48 +0000
+++ lib/lp/app/javascript/picker/picker_patcher.js 2016-07-27 17:22:45 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2011 Canonical Ltd. This software is licensed under the
+/* Copyright 2011-2016 Canonical Ltd. This software is licensed under the
* GNU Affero General Public License version 3 (see the file LICENSE).
*/
@@ -620,7 +620,9 @@
// use the context to limit the results to the same project.
var uri = '';
- if (Y.Lang.isValue(config.context)){
+ if (Y.Lang.isFunction(config.getContextPath)) {
+ uri += config.getContextPath() + '/';
+ } else if (Y.Lang.isValue(config.context)) {
uri += Y.lp.get_url_path(
config.context.get('web_link')) + '/';
}
=== modified file 'lib/lp/app/javascript/picker/tests/test_picker_patcher.js'
--- lib/lp/app/javascript/picker/tests/test_picker_patcher.js 2013-03-20 03:41:40 +0000
+++ lib/lp/app/javascript/picker/tests/test_picker_patcher.js 2016-07-27 17:22:45 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2012 Canonical Ltd. This software is licensed under the
+/* Copyright 2012-2016 Canonical Ltd. This software is licensed under the
* GNU Affero General Public License version 3 (see the file LICENSE). */
YUI.add('lp.app.picker.test', function (Y) {
@@ -33,7 +33,7 @@
}
tests.suite.add(new Y.Test.Case({
- name: 'picker_yesyno_validation',
+ name: 'picker_yesno_validation',
setUp: function() {
this.vocabulary = [
@@ -514,6 +514,39 @@
tests.suite.add(new Y.Test.Case({
+ name: 'picker_custom_context_path',
+
+ create_picker: function(yio, extra_config) {
+ var config = {yio: yio};
+ if (extra_config !== undefined) {
+ config = Y.merge(extra_config, config);
+ }
+ return Y.lp.app.picker.addPickerPatcher(
+ "Foo",
+ "foo/bar",
+ "test_link",
+ "picker_id",
+ config);
+ },
+
+ test_custom_context_path_honoured: function() {
+ var mock_io = new Y.lp.testing.mockio.MockIo();
+ var extra_config = {
+ "getContextPath": function() { return "/gentoo"; }
+ };
+ var picker = this.create_picker(mock_io, extra_config);
+ picker.fire('search', 'package');
+ Assert.areEqual(1, mock_io.requests.length);
+ Assert.areEqual(
+ '/gentoo/@@+huge-vocabulary?name=Foo&search_text=package&' +
+ 'batch=6&start=0', mock_io.requests[0].url);
+ cleanup_widget(picker);
+ }
+
+ }));
+
+ tests.suite.add(new Y.Test.Case({
+
name: 'picker_error_handling',
setUp: function() {
=== modified file 'lib/lp/app/widgets/popup.py'
--- lib/lp/app/widgets/popup.py 2013-04-10 08:01:20 +0000
+++ lib/lp/app/widgets/popup.py 2016-07-27 17:22:45 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Single selection widget using a popup to select one item from many."""
@@ -275,3 +275,16 @@
"looking for? "
'Register it.'
% canonical_url(self.context.context))
+
+
+class DistributionSourcePackagePickerWidget(VocabularyPickerWidget):
+ """Custom popup widget for choosing distribution/package combinations."""
+
+ __call__ = ViewPageTemplateFile(
+ 'templates/distributionsourcepackage-picker.pt')
+
+ @property
+ def distribution_id(self):
+ return self._prefix + 'distribution'
+
+ distribution_name = ''
=== added file 'lib/lp/app/widgets/templates/distributionsourcepackage-picker.pt'
--- lib/lp/app/widgets/templates/distributionsourcepackage-picker.pt 1970-01-01 00:00:00 +0000
+++ lib/lp/app/widgets/templates/distributionsourcepackage-picker.pt 2016-07-27 17:22:45 +0000
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
=== modified file 'lib/lp/app/widgets/templates/form-picker-macros.pt'
--- lib/lp/app/widgets/templates/form-picker-macros.pt 2012-02-01 23:47:54 +0000
+++ lib/lp/app/widgets/templates/form-picker-macros.pt 2016-07-27 17:22:45 +0000
@@ -29,7 +29,7 @@
-