Merge lp:~wallyworld/launchpad/bug-javascript-1011611 into lp:launchpad

Proposed by Ian Booth on 2012-06-13
Status: Merged
Approved by: Ian Booth on 2012-06-13
Approved revision: no longer in the source branch.
Merged at revision: 15405
Proposed branch: lp:~wallyworld/launchpad/bug-javascript-1011611
Merge into: lp:launchpad
Diff against target: 218 lines (+51/-29)
5 files modified
lib/lp/app/javascript/choice.js (+1/-1)
lib/lp/app/javascript/choiceedit/choiceedit.js (+7/-1)
lib/lp/bugs/javascript/information_type_choice.js (+33/-21)
lib/lp/bugs/javascript/tests/test_information_type_choice.js (+9/-4)
lib/lp/bugs/templates/bug-portlet-privacy.pt (+1/-2)
To merge this branch: bzr merge lp:~wallyworld/launchpad/bug-javascript-1011611
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code 2012-06-13 Approve on 2012-06-13
Review via email: mp+109966@code.launchpad.net

Commit Message

Ensure edit icons appear on file bug choice popups on Chrome, fix rendering issues on bug privacy portlet.

Description of the Change

== Implementation ==

Fix markup generated for the filebug edit icons to remove a ' ' between the span and anchor.
Ensure the bug privacy portlet lock icon is updated when the popup value is saved, like is done for description.
Fix error rendering - disable standard choice popup animation and render the success and error animations manually. These callbacks are hard wired into the widget so a few tweaks to the widget were required. Previously, nothing in the lp codebase asked the choice popup to render the error condition.

== Tests ==

Update yui tests for information type javascript.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/choice.js
  lib/lp/app/javascript/choiceedit/choiceedit.js
  lib/lp/bugs/javascript/information_type_choice.js
  lib/lp/bugs/javascript/tests/test_information_type_choice.js
  lib/lp/bugs/templates/bug-portlet-privacy.pt

To post a comment you must log in.
Steve Kowalik (stevenk) wrote :

This looks excellent. My only concern is on lines 48-49 you call ._showFailed() on the widget and then update the privacy portlet, whereas on lines 108-109, you update the privacy portlet and then call .showSuccessful().

review: Approve (code)
Ian Booth (wallyworld) wrote :

The show failed comes before the update because we want to flash the displayed 'bad' text.
The show success comes after the update because we want to flash the good text.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/choice.js'
2--- lib/lp/app/javascript/choice.js 2012-06-05 10:09:35 +0000
3+++ lib/lp/app/javascript/choice.js 2012-06-13 01:32:21 +0000
4@@ -75,7 +75,7 @@
5 var choice_node = Y.Node.create([
6 '<span id="' + field_name + '-content"><span class="value"></span>',
7 '<a class="sprite edit editicon actionicon" href="#"></a></span>'
8- ].join(' '));
9+ ].join(''));
10 if (show_description) {
11 choice_node.append(Y.Node.create('<div class="formHelp"></div>'));
12 }
13
14=== modified file 'lib/lp/app/javascript/choiceedit/choiceedit.js'
15--- lib/lp/app/javascript/choiceedit/choiceedit.js 2012-05-15 16:50:00 +0000
16+++ lib/lp/app/javascript/choiceedit/choiceedit.js 2012-06-13 01:32:21 +0000
17@@ -145,6 +145,10 @@
18 }
19 },
20
21+ flashEnabled: {
22+ value: true
23+ },
24+
25 backgroundColor: {
26 value: null
27 },
28@@ -191,7 +195,9 @@
29
30 this.after("valueChange", function(e) {
31 this.syncUI();
32- this._showSucceeded();
33+ if (this.get('flashEnabled')) {
34+ this._showSucceeded();
35+ }
36 });
37 },
38
39
40=== modified file 'lib/lp/bugs/javascript/information_type_choice.js'
41--- lib/lp/bugs/javascript/information_type_choice.js 2012-06-07 17:56:00 +0000
42+++ lib/lp/bugs/javascript/information_type_choice.js 2012-06-13 01:32:21 +0000
43@@ -21,7 +21,8 @@
44 error_handler.handleError = function(ioId, response) {
45 var orig_value = LP.cache.bug.information_type;
46 widget.set('value', orig_value);
47- update_information_type_description(orig_value);
48+ widget._showFailed();
49+ update_privacy_portlet(orig_value);
50 return false;
51 };
52 var config = {
53@@ -29,7 +30,7 @@
54 start: Y.bind(widget._uiSetWaiting),
55 end: Y.bind(widget._uiClearWaiting),
56 success: function(id, response) {
57- namespace.information_type_save_success(value);
58+ namespace.information_type_save_success(widget, value);
59 },
60 failure: error_handler.getFailureHandler()
61 },
62@@ -41,12 +42,34 @@
63 LP.cache.bug.self_link, 'transitionToInformationType', config);
64 };
65
66-var update_information_type_description = function(value) {
67+var update_privacy_portlet = function(value) {
68 var description = information_type_descriptions[value];
69 var desc_node = Y.one('#information-type-description');
70 if (Y.Lang.isValue(desc_node)) {
71 desc_node.set('text', description);
72 }
73+ var summary = Y.one('#information-type-summary');
74+ var private_type = (Y.Array.indexOf(LP.cache.private_types, value) >= 0);
75+ if (private_type) {
76+ summary.replaceClass('public', 'private');
77+ } else {
78+ summary.replaceClass('private', 'public');
79+ }
80+};
81+
82+var update_privacy_banner = function(value) {
83+ var body = Y.one('body');
84+ var privacy_banner = Y.lp.app.banner.privacy.getPrivacyBanner();
85+ var private_type = (Y.Array.indexOf(LP.cache.private_types, value) >= 0);
86+ if (private_type) {
87+ body.replaceClass('public', 'private');
88+ var banner_text = namespace.get_information_type_banner_text(value);
89+ privacy_banner.updateText(banner_text);
90+ privacy_banner.show();
91+ } else {
92+ body.replaceClass('private', 'public');
93+ privacy_banner.hide();
94+ }
95 };
96
97 namespace.get_information_type_banner_text = function(value) {
98@@ -63,24 +86,12 @@
99 }
100 };
101
102-namespace.information_type_save_success = function(value) {
103- var body = Y.one('body');
104- var summary = Y.one('#information-type-summary');
105- var private_type = (Y.Array.indexOf(LP.cache.private_types, value) >= 0);
106+namespace.information_type_save_success = function(widget, value) {
107+ LP.cache.bug.information_type = value;
108+ update_privacy_banner(value);
109+ widget._showSucceeded();
110 var subscription_ns = Y.lp.bugs.bugtask_index.portlets.subscription;
111- var privacy_banner = Y.lp.app.banner.privacy.getPrivacyBanner();
112 subscription_ns.update_subscription_status(skip_animation);
113- if (private_type) {
114- var banner_text = namespace.get_information_type_banner_text(value);
115- privacy_banner.updateText(banner_text);
116- summary.replaceClass('public', 'private');
117- body.replaceClass('public', 'private');
118- privacy_banner.show();
119- } else {
120- summary.replaceClass('private', 'public');
121- body.replaceClass('private', 'public');
122- privacy_banner.hide();
123- }
124 };
125
126 namespace.setup_information_type_choice = function(privacy_link, lp_client,
127@@ -97,7 +108,8 @@
128 value: LP.cache.bug.information_type,
129 title: "Change information type",
130 items: LP.cache.information_types,
131- backgroundColor: '#FFFF99'
132+ backgroundColor: '#FFFF99',
133+ flashEnabled: false
134 });
135 Y.lp.app.choice.hook_up_choicesource_spinner(information_type_edit);
136 information_type_edit.render();
137@@ -108,7 +120,7 @@
138 if (value === 'Private') {
139 value = 'User Data';
140 }
141- update_information_type_description(value);
142+ update_privacy_portlet(value);
143 namespace.save_information_type(
144 information_type_edit, value, lp_client);
145 });
146
147=== modified file 'lib/lp/bugs/javascript/tests/test_information_type_choice.js'
148--- lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-06-07 17:56:00 +0000
149+++ lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-06-13 01:32:21 +0000
150@@ -23,7 +23,7 @@
151 self_link: '/bug/1'
152 },
153 show_information_type_in_ui: true,
154- private_types: ['Private'],
155+ private_types: ['Private', 'User Data'],
156 information_types: [
157 {'value': 'Public', 'name': 'Public',
158 'description': 'Public Description'},
159@@ -97,11 +97,12 @@
160 update_flag = true;
161 });
162
163- ns.information_type_save_success('Private');
164+ ns.information_type_save_success(this.widget, 'Private');
165 var body = Y.one('body');
166 Y.Assert.isTrue(body.hasClass('private'));
167 Y.Assert.isTrue(hide_flag);
168 Y.Assert.isTrue(update_flag);
169+ Y.Assert.areEqual('Private', LP.cache.bug.information_type);
170 this._unshim_privacy_banner(old_func);
171 },
172
173@@ -114,11 +115,11 @@
174 var summary = Y.one('#information-type-summary');
175 summary.replaceClass('public', 'private');
176
177- ns.information_type_save_success('Public');
178- Y.Assert.isTrue(summary.hasClass('public'));
179+ ns.information_type_save_success(this.widget, 'Public');
180 var body = Y.one('body');
181 Y.Assert.isTrue(body.hasClass('public'));
182 Y.Assert.isTrue(flag);
183+ Y.Assert.areEqual('Public', LP.cache.bug.information_type);
184 this._unshim_privacy_banner(old_func);
185 },
186
187@@ -136,6 +137,8 @@
188 var description_node = Y.one('#information-type-description');
189 Y.Assert.areEqual(
190 'User Data Description', description_node.get('text'));
191+ var summary = Y.one('#information-type-summary');
192+ Y.Assert.isTrue(summary.hasClass('private'));
193 Y.Assert.isTrue(function_called);
194 ns.save_information_type = orig_save_information_type;
195 },
196@@ -157,6 +160,8 @@
197 var description_node = Y.one('#information-type-description');
198 Y.Assert.areEqual(
199 'Public Description', description_node.get('text'));
200+ var summary = Y.one('#information-type-summary');
201+ Y.Assert.isTrue(summary.hasClass('public'));
202 // The error was displayed.
203 Y.Assert.isNotNull(Y.one('.yui3-lazr-formoverlay-errors'));
204 }
205
206=== modified file 'lib/lp/bugs/templates/bug-portlet-privacy.pt'
207--- lib/lp/bugs/templates/bug-portlet-privacy.pt 2012-06-07 18:27:33 +0000
208+++ lib/lp/bugs/templates/bug-portlet-privacy.pt 2012-06-13 01:32:21 +0000
209@@ -15,8 +15,7 @@
210 contains
211 <strong id="information-type" tal:content="view/information_type" />
212 information
213- </span>&nbsp;<a
214- class="sprite edit" id="privacy-link"
215+ </span>&nbsp;<a class="sprite edit" id="privacy-link"
216 tal:attributes="href link/path" tal:condition="link/enabled"></a>
217 <div id="information-type-description" style="padding-top: 5px"
218 tal:content="view/information_type_description"></div>