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

Proposed by Guilherme Salgado on 2012-03-01
Status: Merged
Approved by: Richard Harding on 2012-03-01
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 on 2012-03-01
Richard Harding (community) code* 2012-03-01 Approve on 2012-03-01
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.
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*)
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.

Richard Harding (rharding) wrote :

Thanks, looks much better!

review: Approve (code*)
Deryck Hodge (deryck) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/inlineedit/editor.js'
2--- lib/lp/app/javascript/inlineedit/editor.js 2011-12-21 07:54:40 +0000
3+++ lib/lp/app/javascript/inlineedit/editor.js 2012-03-01 20:41:20 +0000
4@@ -405,7 +405,11 @@
5 */
6 showError: function(msg) {
7 this.hideLoadingSpinner();
8- this.get(ERROR_MSG).set('innerHTML', msg);
9+ if (this.get(MULTILINE)) {
10+ Y.lp.app.errors.display_error(this.get(BOUNDING_BOX), msg);
11+ } else {
12+ this.get(ERROR_MSG).set('innerHTML', msg);
13+ }
14 this.set(IN_ERROR, true);
15 this.get(INPUT_EL).focus();
16 },
17@@ -1385,5 +1389,5 @@
18
19 }, "0.2", {"skinnable": true,
20 "requires": ["oop", "anim", "event", "node", "widget",
21- "lp.anim", "lazr.base",
22+ "lp.anim", "lazr.base", "lp.app.errors",
23 "lp.app.formwidgets.resizing_textarea"]});
24
25=== modified file 'lib/lp/app/javascript/inlineedit/tests/test_inline_edit.html'
26--- lib/lp/app/javascript/inlineedit/tests/test_inline_edit.html 2012-02-16 20:35:40 +0000
27+++ lib/lp/app/javascript/inlineedit/tests/test_inline_edit.html 2012-03-01 20:41:20 +0000
28@@ -29,6 +29,12 @@
29 <script type="text/javascript"
30 src="../../../../../../build/js/lp/app/anim/anim.js"></script>
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"
38 src="../../../../../../build/js/lp/app/lazr/lazr.js"></script>
39 <script type="text/javascript"
40 src="../../../../../../build/js/lp/app/extras/extras.js"></script>
41
42=== modified file 'lib/lp/app/javascript/inlineedit/tests/test_inline_edit.js'
43--- lib/lp/app/javascript/inlineedit/tests/test_inline_edit.js 2012-02-06 16:50:41 +0000
44+++ lib/lp/app/javascript/inlineedit/tests/test_inline_edit.js 2012-03-01 20:41:20 +0000
45@@ -243,6 +243,28 @@
46 "if there are no errors being displayed.");
47 },
48
49+ test_multiline_calls_display_error: function() {
50+ this.editor.set('multiline', true);
51+ this.editor.render();
52+
53+ // Ensure display_error is called.
54+ var error_shown = false;
55+ var old_error_method = Y.lp.app.errors.display_error;
56+ Y.lp.app.errors.display_error = function(text) {
57+ error_shown = true;
58+ };
59+
60+ var msg = "An error has occured.";
61+ this.editor.showError(msg);
62+ Y.Assert.isTrue(error_shown);
63+
64+ // Restore original method.
65+ Y.lp.app.errors.display_error = old_error_method;
66+
67+ // Restore to previous state.
68+ this.editor.set('multiline', false);
69+ },
70+
71 test_save_input_to_editor: function() {
72 var expected_value = 'abc',
73 ed = this.editor;
74@@ -1000,7 +1022,3 @@
75 'lp.app.formwidgets.resizing_textarea', 'event',
76 'event-simulate', 'plugin']
77 });
78-
79-
80-
81-