# HG changeset patch # User Steve Losh # Date 1278168685 14400 # Node ID 014df093430e9fd0b93091f7f299db1fed72fcf6 # Parent d90c957b5b1a31a8a463db2c65b19b6efa170a89 web: add review-level comment editing support diff -r d90c957b5b1a -r 014df093430e review/static/comments.js --- a/review/static/comments.js Thu Jul 01 19:47:48 2010 -0400 +++ b/review/static/comments.js Sat Jul 03 10:51:25 2010 -0400 @@ -36,12 +36,26 @@ return false; }); + $(".activate-edit a").click(function(event) { + $(event.target).closest(".activate-edit").hide(); + $(event.target).closest(".comment").find(".message").hide(); + $(event.target).closest("div").children("form").fadeIn("fast"); + return false; + }); + $("a.cancel").click(function(event) { $(event.target).closest(".togglebox").children(".activate").show(); $(event.target).parents("form").hide(); return false; }); + $("a.cancel-edit").click(function(event) { + $(event.target).closest(".toggleinline").children(".activate-edit").show(); + $(event.target).closest(".comment").find(".message").show(); + $(event.target).parents("form").hide(); + return false; + }); + $("a.cancel-line").live('click', function(event) { $(event.target).closest(".diff").find(".chosen").removeClass("chosen"); $(event.target).closest("tr.comment-form").remove(); diff -r d90c957b5b1a -r 014df093430e review/static/style.css --- a/review/static/style.css Thu Jul 01 19:47:48 2010 -0400 +++ b/review/static/style.css Sat Jul 03 10:51:25 2010 -0400 @@ -306,7 +306,7 @@ #changeset .content a.submit:hover span { background-color: #eaeaea; } -#changeset .content a.cancel, #changeset .content a.cancel-line { +#changeset .content a.cancel, #changeset .content a.cancel-line, #changeset .content a.cancel-edit { cursor: pointer; font: bold 12px "Helvetica Neue", HelveticaNeue, Arial, Helvetica, sans-serif; color: #1e1e1e; @@ -326,12 +326,12 @@ border-left: 1px solid #a6a6a6; border-bottom: 1px solid #959595; } -#changeset .content a.cancel:focus, #changeset .content a.cancel-line:focus { +#changeset .content a.cancel:focus, #changeset .content a.cancel-line:focus, #changeset .content a.cancel-edit:focus { box-shadow: 0px 0px 4px rgba(100, 100, 100, 0.9); -moz-box-shadow: 0px 0px 4px rgba(100, 100, 100, 0.9); -webkit-box-shadow: 0px 0px 4px rgba(100, 100, 100, 0.9); } -#changeset .content a.cancel span, #changeset .content a.cancel-line span { +#changeset .content a.cancel span, #changeset .content a.cancel-line span, #changeset .content a.cancel-edit span { display: inline-block; padding: 0 6px; text-shadow: 0px 1px 1px #e2e2e2; @@ -339,14 +339,14 @@ -moz-border-radius: 3px; border-radius: 3px; } -#changeset .content a.cancel:hover, #changeset .content a.cancel-line:hover { +#changeset .content a.cancel:hover, #changeset .content a.cancel-line:hover, #changeset .content a.cancel-edit:hover { border-top: 1px solid #d3d3d3; border-right: 1px solid #bbbbbb; border-left: 1px solid #bbbbbb; border-bottom: 1px solid #a4a4a4; background-color: #eaeaea; } -#changeset .content a.cancel:hover span, #changeset .content a.cancel-line:hover span { +#changeset .content a.cancel:hover span, #changeset .content a.cancel-line:hover span, #changeset .content a.cancel-edit:hover span { background-color: #eaeaea; } #changeset .content .navigation .middle { @@ -407,6 +407,9 @@ #changeset .content .review-level-comments { margin-top: 30px; } +#changeset .content .edit-review-comment { + margin-top: 3px; +} #changeset .content .activate a { cursor: pointer; font: bold 12px "Helvetica Neue", HelveticaNeue, Arial, Helvetica, sans-serif; diff -r d90c957b5b1a -r 014df093430e review/static/style.less --- a/review/static/style.less Thu Jul 01 19:47:48 2010 -0400 +++ b/review/static/style.less Sat Jul 03 10:51:25 2010 -0400 @@ -329,7 +329,7 @@ &:hover { .button-hover(@c-metal, #000, 12px, 1.45); } &:hover span { .button-hover-span(@c-metal, #000, 12px, 1.45); } } - a.cancel, a.cancel-line { + a.cancel, a.cancel-line, a.cancel-edit { .button(@c-metal, #000, 12px, 1.45); span { .button-span(@c-metal, #000, 12px, 1.45); } &:hover { .button-hover(@c-metal, #000, 12px, 1.45); } @@ -396,6 +396,9 @@ .review-level-comments { margin-top: 30px; } + .edit-review-comment { + margin-top: 3px; + } .activate a { .button(@c-metal, #000, 12px, 1.45); span { .button-span(@c-metal, #000, 12px, 1.45); } diff -r d90c957b5b1a -r 014df093430e review/templates/pieces/comment.html --- a/review/templates/pieces/comment.html Thu Jul 01 19:47:48 2010 -0400 +++ b/review/templates/pieces/comment.html Sat Jul 03 10:51:25 2010 -0400 @@ -45,4 +45,7 @@
{{ comment.message }}
+ {% if not read_only %} + {% include "pieces/forms/comment-change.html" %} + {% endif %} diff -r d90c957b5b1a -r 014df093430e review/templates/pieces/forms/comment-change.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/review/templates/pieces/forms/comment-change.html Sat Jul 03 10:51:25 2010 -0400 @@ -0,0 +1,29 @@ +
+ Edit +
+
+ + + +
+
+ + + +
+ + Edit Comment + Cancel +
+
diff -r d90c957b5b1a -r 014df093430e review/web.py --- a/review/web.py Thu Jul 01 19:47:48 2010 -0400 +++ b/review/web.py Sat Jul 03 10:51:25 2010 -0400 @@ -38,6 +38,7 @@ LOG_PAGE_LEN = 15 + def _item_gravatar(item, size=30): return 'http://www.gravatar.com/avatar/%s?s=%d' % (md5(email(item.author)).hexdigest(), size) @@ -135,8 +136,12 @@ style = 'markdown' if request.form.get('comment-markdown') else '' if body: - rcset = g.datastore[revhash] - rcset.add_comment(body, filename, lines, style=style) + current = request.form.get('current') + if current: + g.datastore.edit_comment(current, body, filename, lines, style) + else: + rcset = g.datastore[revhash] + rcset.add_comment(body, filename, lines, style) return redirect("%s/changeset/%s/" % (app.site_root, revhash))