Add the ability to copy/paste a msgid when creating an annotation
authorMagnus Hagander <magnus@hagander.net>
Sun, 15 Feb 2015 11:23:51 +0000 (12:23 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 15 Feb 2015 11:23:51 +0000 (12:23 +0100)
pgcommitfest/commitfest/static/commitfest/js/commitfest.js
pgcommitfest/commitfest/templates/patch.html

index 4fd06e5a6a3554853636866809a56b3812976540..be143f92f6e896c920257211ade7a28527b788a2 100644 (file)
@@ -126,6 +126,7 @@ function updateAnnotationMessages(threadid) {
     }).success(function(data) {
        sel = $('#annotateMessageList')
        sel.find('option').remove();
+       sel.append('<option value="">---</option>');
        $.each(data, function(i,m) {
            sel.append('<option value="' + m.msgid + '">' + m.from + ': ' + m.subj + ' (' + m.date + ')</option>');
        });
@@ -136,7 +137,9 @@ function updateAnnotationMessages(threadid) {
 function addAnnotation(threadid) {
     $('#annotateThreadList').find('option').remove();
     $('#annotateMessage').val('');
+    $('#annotateMsgId').val('');
     $('#annotateModal').modal();
+    $('#annotateThreadList').focus();
     updateAnnotationMessages(threadid);
     $('#doAnnotateMessageButton').unbind('click');
     $('#doAnnotateMessageButton').click(function() {
@@ -144,11 +147,12 @@ function addAnnotation(threadid) {
        $('#annotateMessageBody').addClass('loading');
        $.post('/ajax/annotateMessage/', {
            't': threadid,
-           'msgid': $('#annotateMessageList').val(),
+           'msgid': $.trim($('#annotateMsgId').val()),
            'msg': $('#annotateMessage').val()
        }).success(function(data) {
            if (data != 'OK') {
                alert(data);
+               $('#annotateMessageBody').removeClass('loading');
            }
            else {
                $('#annotateModal').modal('hide');
@@ -161,9 +165,17 @@ function addAnnotation(threadid) {
     });
 }
 
+function annotateMsgPicked() {
+    var val = $('#annotateMessageList').val();
+    if (val) {
+       $('#annotateMsgId').val(val);
+       annotateChanged();
+    }
+}
+
 function annotateChanged() {
     /* Enable/disable the annotate button */
-    if ($('#annotateMessage').val() != '' && $('#annotateMessageList').val()) {
+    if ($('#annotateMessage').val() != '' && $('#annotateMsgId').val()) {
        $('#doAnnotateMessageButton').removeClass('disabled');
     }
     else {
index f18cf9d0e20e0a948c46905864ad4f67e5cc4207..36ff04405d8e8a7fa1de6a9e22f53c8dcdbb08bc 100644 (file)
   <div id="annotateMessageBody" class="modal-body">
    <div>Pick one of the messages in this thread</div>
    <div id="annotateListWrap">
-    <select id="annotateMessageList" style="width:100%;" onChange="annotateChanged()">
+    <select id="annotateMessageList" style="width:100%;" onChange="annotateMsgPicked()">
     </select>
    </div>
+   <div>Or copy/paste the message-id:</div>
+   <div id="annotateMsgidWrap">
+     <input id="annotateMsgId" type="text" style="width:100%" onKeyUp="annotateChanged()">
+   </div>
    <div><br/></div>
    <div>Enter a messages for the annotation</div>
    <div id="annotateTextWrap">