Merge lp:~salgado/lazr-js/picker-double-search into lp:lazr-js

Proposed by Guilherme Salgado
Status: Merged
Approved by: Edwin Grubbs
Approved revision: 142
Merged at revision: not available
Proposed branch: lp:~salgado/lazr-js/picker-double-search
Merge into: lp:lazr-js
Diff against target: 85 lines (+6/-35)
2 files modified
src-js/lazrjs/picker/picker.js (+5/-9)
src-js/lazrjs/picker/tests/picker.js (+1/-26)
To merge this branch: bzr merge lp:~salgado/lazr-js/picker-double-search
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) code Approve
Review via email: mp+14830@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

Fix the bug by firing the search event in _defaultSearchUserAction
instead of upon value change on the current_search_string property.

--
Guilherme Salgado <email address hidden>

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Hi Salgado,

Thanks for fixing these problems in the picker.

merge-approved

-Edwin

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src-js/lazrjs/picker/picker.js'
2--- src-js/lazrjs/picker/picker.js 2009-11-13 15:34:09 +0000
3+++ src-js/lazrjs/picker/picker.js 2009-11-13 16:55:17 +0000
4@@ -529,12 +529,6 @@
5 this.after('errorChange', function (e) {
6 this._syncErrorUI();
7 });
8-
9- // Fire search event whenever the "current_search_string" property
10- // is changed.
11- this.after('current_search_stringChange', function(e) {
12- this.fire(SEARCH, this.get(CURRENT_SEARCH_STRING));
13- });
14 },
15
16 /**
17@@ -564,11 +558,12 @@
18 * @protected
19 */
20 _clear: function() {
21+ this.set(CURRENT_SEARCH_STRING, '');
22+ this.set(ERROR, '');
23+ this.set(RESULTS, [{}]);
24+ this.set(BATCHES, []);
25 this._search_input.set('value', '');
26- this.set('error', '');
27- this.set('results', [{}]);
28 this._results_box.set('innerHTML', '');
29- this.set('batches', []);
30 },
31
32 /**
33@@ -589,6 +584,7 @@
34 this.set(ERROR, msg);
35 } else {
36 this.set(CURRENT_SEARCH_STRING, search_string);
37+ this.fire(SEARCH, search_string);
38 }
39 },
40
41
42=== modified file 'src-js/lazrjs/picker/tests/picker.js'
43--- src-js/lazrjs/picker/tests/picker.js 2009-11-13 15:38:17 +0000
44+++ src-js/lazrjs/picker/tests/picker.js 2009-11-13 16:55:17 +0000
45@@ -240,7 +240,7 @@
46 "Search button wasn't re-enabled.");
47 },
48
49- test_hitting_enter_in_search_input_fires_save_event: function () {
50+ test_hitting_enter_in_search_input_fires_search_event: function () {
51 this.picker.render();
52
53 var bb = this.picker.get('boundingBox');
54@@ -480,31 +480,6 @@
55 "The no-results CSS class should have been removed.");
56 },
57
58- test_setting_currentsearchstring_fires_search_event: function () {
59- this.picker.render();
60-
61- Assert.areEqual(
62- '',
63- this.picker.get('current_search_string'),
64- "current_search_string should be empty.");
65-
66- this.picker.subscribe('search', function(ev) {
67- this.resume(function() {
68- Assert.areEqual(
69- 'foo search string', ev.details[0],
70- 'Search event is missing the search string.');
71- });
72- }, this);
73- this.picker.set('current_search_string', 'foo search string');
74- Assert.areEqual(
75- 'foo search string',
76- this.picker.get('current_search_string'),
77- "current_search_string should be set.");
78- this.wait(function () {
79- Assert.fail("search event wasn't fired");
80- }, 3000);
81- },
82-
83 test_setting_search_slot_updates_ui: function () {
84 this.picker.render();
85 var filler = '<span>hello</span>';

Subscribers

People subscribed via source and target branches