Merge lp:~bjornt/launchpad/add-comment-submit-button into lp:launchpad

Proposed by Björn Tillenius
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bjornt/launchpad/add-comment-submit-button
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~bjornt/launchpad/add-comment-submit-button
Reviewer Review Type Date Requested Status
Martin Albisetti (community) ui Approve
Paul Hummer (community) Approve
Review via email: mp+9702@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Replace the 'add comment' link with a submit button to make it more
obvious how to add a comment.

The labels are also renamed, so that the heading is "Add comment" and
the button reads "Post comment." The latter causes test failures of
course, and I intend to fix them, but I don't think it will affect the
review.

As per discussion with Martin, I also made it so that the submit button
is disabled, if there is no text in the comment box.

--
Björn Tillenius | https://launchpad.net/~bjornt

Revision history for this message
Björn Tillenius (bjornt) wrote :

The tests failures have been fixed and pushed.

Revision history for this message
Björn Tillenius (bjornt) wrote :

The test failures have been fixed and pushed.

Revision history for this message
Paul Hummer (rockstar) wrote :

Thanks for the branch! I'm happy with the changes, and I know you've discussed this with beuno, but it might be a good idea to have him sign off on this as well, so I'm going to request his UI review.

review: Approve
Revision history for this message
Martin Albisetti (beuno) wrote :

per-fect.

review: Approve (ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/javascript/bugs/bugtask-index.js'
2--- lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-08-05 09:33:08 +0000
3+++ lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-08-05 16:09:16 +0000
4@@ -1569,10 +1569,7 @@
5 * @method setup_inline_commenting
6 */
7 function setup_inline_commenting() {
8- var save_changes = Y.get('[id="field.actions.save"]');
9- var add_link = Y.Node.create(
10- '<a href="+addcomment" class="sprite add js-action">' +
11- 'Add comment</a>');
12+ var submit_button = Y.get('[id="field.actions.save"]');
13 var progress_message = Y.Node.create(
14 '<span class="update-in-progress-message">Saving...</span>');
15 var comment_input = Y.get('[id="field.comment"]');
16@@ -1582,17 +1579,32 @@
17 clearProgressUI();
18 };
19 error_handler.showError = function (error_msg) {
20- display_error(add_link, error_msg);
21+ display_error(submit_button, error_msg);
22 };
23
24 function clearProgressUI() {
25 progress_message.get('parentNode').replaceChild(
26- add_link, progress_message);
27+ submit_button, progress_message);
28 comment_input.removeAttribute('disabled');
29 }
30
31- save_changes.get('parentNode').replaceChild(add_link, save_changes);
32- add_link.on('click', function(e) {
33+ function hide_or_show_submit_button(e) {
34+ if (comment_input.get('value') === '') {
35+ submit_button.set('disabled', true);
36+ }
37+ else {
38+ submit_button.set('disabled', false);
39+ }
40+ };
41+ /* Hook up hide_or_show_submit_button on both keyup and mouseup to
42+ handle both entering text with the keyboard, and pasting with the
43+ mouse. */
44+ comment_input.on('keyup', hide_or_show_submit_button);
45+ comment_input.on('mouseup', hide_or_show_submit_button);
46+ hide_or_show_submit_button(null);
47+ submit_button.addClass('js-action');
48+ submit_button.setStyle('display', 'inline');
49+ submit_button.on('click', function(e) {
50 e.halt();
51 var comment_text = comment_input.get('value');
52 /* Don't try to add an empty comment. */
53@@ -1626,7 +1638,8 @@
54 }
55 };
56 comment_input.set('disabled', 'true');
57- add_link.get('parentNode').replaceChild(progress_message, add_link);
58+ submit_button.get('parentNode').replaceChild(
59+ progress_message, submit_button);
60 lp_client.named_post(
61 bug_repr.self_link, 'newMessage', config);
62 });
63
64=== modified file 'lib/lp/bugs/browser/bugmessage.py'
65--- lib/lp/bugs/browser/bugmessage.py 2009-06-25 00:40:31 +0000
66+++ lib/lp/bugs/browser/bugmessage.py 2009-08-05 15:05:52 +0000
67@@ -46,7 +46,7 @@
68 self.addError("Either a comment or attachment "
69 "must be provided.")
70
71- @action(u"Save Changes", name='save')
72+ @action(u"Post comment", name='save')
73 def save_action(self, action, data):
74 """Add the comment and/or attachment."""
75
76
77=== modified file 'lib/lp/bugs/templates/bugtask-index.pt'
78--- lib/lp/bugs/templates/bugtask-index.pt 2009-08-04 05:30:51 +0000
79+++ lib/lp/bugs/templates/bugtask-index.pt 2009-08-05 15:05:52 +0000
80@@ -331,7 +331,7 @@
81 Remember, this bug report is a duplicate.
82 Comment here only if you think the duplicate status is wrong.
83 </div>
84- <h2>Comment</h2>
85+ <h2>Add comment</h2>
86 <form action="+addcomment"
87 method="post"
88 enctype="multipart/form-data"