save multiple comments at once

Jan Heylen heyleke at gmail.com
Mon Jan 26 12:37:13 EST 2015


Hi,

I've been working on a change that a user would allow to open multiple
comments on a commit, and 'post' (save) them all at once to the
kallithea database. Currently this is client side only change, but
with the proper changes on the server side end, this could result in a
one-mail-per-commit-review instead of a one-mail-per-comment setup
now.

But the main reason I was working on this is the fact that if you add
2 or more comments to a commit, and you choose to save them as preview
first (you are still reviewing the rest of the commit), you have to go
over all the comments and press the save button.

Where I want to take this is even one step further:

We have now:
  For inline comments:  save - cancel - preview
  And below the commit: approved/rejected/close/... and comment - preview

I would change this to:
  For inline comments: comment - cancel
  Below the commit: submit all comments - cancel all

The inline 'comment' buttons would actually do what is now a preview
(and may still indicate comment preview), cancel remains the same.
The 'submit all comments' would do an AJAXPost of all the comments (no
backend change required) at once.

What do you think?

I've made a little POC patch that does the submit-all-open-comments
thing, it does it for open comments for know, but probably not that
difficult (and even better, it won't require the remove-class hack
probably) to change that to a for all preview comments way of working.
I'll inline the POC patch for your reference, but forgive me my basic
javascript knowledge...

regards,

Jan

the patch:

diff -r bfc304687f1c kallithea/public/js/base.js
--- a/kallithea/public/js/base.js Wed Jan 21 17:35:11 2015 +0100
+++ b/kallithea/public/js/base.js Mon Jan 26 18:36:00 2015 +0100
@@ -667,6 +667,9 @@
     $form.submit(function(e){
         e.preventDefault();

+        if(!$tr.hasClass('form-open')){
+          return;
+        }
         if(lineno === undefined){
             alert('Error submitting, line ' + lineno + ' not found.');
             return;
@@ -694,6 +697,10 @@
                 'line': lineno
         };
         ajaxPOST(submit_url, postData, success);
+        //proof of concept, preemptive remove the form from the open
list, not good, but only for POC
+        $tr.removeClass('form-open');
+        var allOpenForms = $( '.form-open' ).next();
+        allOpenForms.find( ".inline-form" ).submit();
     });

     $('#preview-btn_'+lineno).click(function(e){


More information about the kallithea-general mailing list