Merge lp:~salgado/launchpad/bug-415365 into lp:launchpad

Proposed by Guilherme Salgado
Status: Merged
Approved by: Richard Harding
Approved revision: no longer in the source branch.
Merged at revision: 14892
Proposed branch: lp:~salgado/launchpad/bug-415365
Merge into: lp:launchpad
Diff against target: 81 lines (+34/-6)
3 files modified
lib/lp/app/javascript/inlineedit/editor.js (+6/-2)
lib/lp/app/javascript/inlineedit/tests/test_inline_edit.html (+6/-0)
lib/lp/app/javascript/inlineedit/tests/test_inline_edit.js (+22/-4)
To merge this branch: bzr merge lp:~salgado/launchpad/bug-415365
Reviewer Review Type Date Requested Status
Deryck Hodge (community) Approve
Richard Harding (community) code* Approve
Review via email: mp+95447@code.launchpad.net

Commit message

[r=deryck,rharding][bug=415365] Use an overlay to display errors from inline multi-line text editors.

Description of the change

This uses an overlay to show errors on multi-line text editing (i.e. Y.EditableText) as the error is currently inserted in a node which is behind the text area so never seen by the user. I'm sure there's lots of room for improvement still, but this is certainly better than not showing the error to users at all, so I'd appreciate if that was taken into consideration.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :
Revision history for this message
Richard Harding (rharding) wrote :

You need to make sure to add lp.app.errors to the requirements of the module. This means that the tests html page will have to have it added as a dependency as well.

Then since the errors is going to require the overlay code, you'll need to add
lazr.formoverlay
lazr.overlay

to the test.html dependencies as well.

review: Needs Fixing (code*)
Revision history for this message
Guilherme Salgado (salgado) wrote :

Thanks for the quick feedback, Rick! I've done the changes you suggested and added a new test to show that display_error() is called on multi-line widgets.

Revision history for this message
Richard Harding (rharding) wrote :

Thanks, looks much better!

review: Approve (code*)
Revision history for this message
Deryck Hodge (deryck) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/app/javascript/inlineedit/editor.js'
--- lib/lp/app/javascript/inlineedit/editor.js 2011-12-21 07:54:40 +0000
+++ lib/lp/app/javascript/inlineedit/editor.js 2012-03-01 20:41:20 +0000
@@ -405,7 +405,11 @@
405 */405 */
406 showError: function(msg) {406 showError: function(msg) {
407 this.hideLoadingSpinner();407 this.hideLoadingSpinner();
408 this.get(ERROR_MSG).set('innerHTML', msg);408 if (this.get(MULTILINE)) {
409 Y.lp.app.errors.display_error(this.get(BOUNDING_BOX), msg);
410 } else {
411 this.get(ERROR_MSG).set('innerHTML', msg);
412 }
409 this.set(IN_ERROR, true);413 this.set(IN_ERROR, true);
410 this.get(INPUT_EL).focus();414 this.get(INPUT_EL).focus();
411 },415 },
@@ -1385,5 +1389,5 @@
13851389
1386}, "0.2", {"skinnable": true,1390}, "0.2", {"skinnable": true,
1387 "requires": ["oop", "anim", "event", "node", "widget",1391 "requires": ["oop", "anim", "event", "node", "widget",
1388 "lp.anim", "lazr.base",1392 "lp.anim", "lazr.base", "lp.app.errors",
1389 "lp.app.formwidgets.resizing_textarea"]});1393 "lp.app.formwidgets.resizing_textarea"]});
13901394
=== modified file 'lib/lp/app/javascript/inlineedit/tests/test_inline_edit.html'
--- lib/lp/app/javascript/inlineedit/tests/test_inline_edit.html 2012-02-16 20:35:40 +0000
+++ lib/lp/app/javascript/inlineedit/tests/test_inline_edit.html 2012-03-01 20:41:20 +0000
@@ -29,6 +29,12 @@
29 <script type="text/javascript"29 <script type="text/javascript"
30 src="../../../../../../build/js/lp/app/anim/anim.js"></script>30 src="../../../../../../build/js/lp/app/anim/anim.js"></script>
31 <script type="text/javascript"31 <script type="text/javascript"
32 src="../../../../../../build/js/lp/app/errors.js"></script>
33 <script type="text/javascript"
34 src="../../../../../../build/js/lp/app/formoverlay/formoverlay.js"></script>
35 <script type="text/javascript"
36 src="../../../../../../build/js/lp/app/overlay/overlay.js"></script>
37 <script type="text/javascript"
32 src="../../../../../../build/js/lp/app/lazr/lazr.js"></script>38 src="../../../../../../build/js/lp/app/lazr/lazr.js"></script>
33 <script type="text/javascript"39 <script type="text/javascript"
34 src="../../../../../../build/js/lp/app/extras/extras.js"></script>40 src="../../../../../../build/js/lp/app/extras/extras.js"></script>
3541
=== modified file 'lib/lp/app/javascript/inlineedit/tests/test_inline_edit.js'
--- lib/lp/app/javascript/inlineedit/tests/test_inline_edit.js 2012-02-06 16:50:41 +0000
+++ lib/lp/app/javascript/inlineedit/tests/test_inline_edit.js 2012-03-01 20:41:20 +0000
@@ -243,6 +243,28 @@
243 "if there are no errors being displayed.");243 "if there are no errors being displayed.");
244 },244 },
245245
246 test_multiline_calls_display_error: function() {
247 this.editor.set('multiline', true);
248 this.editor.render();
249
250 // Ensure display_error is called.
251 var error_shown = false;
252 var old_error_method = Y.lp.app.errors.display_error;
253 Y.lp.app.errors.display_error = function(text) {
254 error_shown = true;
255 };
256
257 var msg = "An error has occured.";
258 this.editor.showError(msg);
259 Y.Assert.isTrue(error_shown);
260
261 // Restore original method.
262 Y.lp.app.errors.display_error = old_error_method;
263
264 // Restore to previous state.
265 this.editor.set('multiline', false);
266 },
267
246 test_save_input_to_editor: function() {268 test_save_input_to_editor: function() {
247 var expected_value = 'abc',269 var expected_value = 'abc',
248 ed = this.editor;270 ed = this.editor;
@@ -1000,7 +1022,3 @@
1000 'lp.app.formwidgets.resizing_textarea', 'event',1022 'lp.app.formwidgets.resizing_textarea', 'event',
1001 'event-simulate', 'plugin']1023 'event-simulate', 'plugin']
1002});1024});
1003
1004
1005
1006