Changeset 27365 for main


Ignore:
Timestamp:
2013-05-16T19:45:16+12:00 (11 years ago)
Author:
ak19
Message:

Bugfixes: 1. handles locked collections (as happens when GLI has opened the collection) when attempting to set metadata. And also when a comment was empty, the username field should not be zeroed.

Location:
main/trunk/greenstone2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/macros/document.dm

    r27363 r27365  
    183183
    184184        // http://stackoverflow.com/questions/498970/how-do-i-trim-a-string-in-javascript
    185         var trimmed_username=_username.replace(/^\s+|\s+$/g, '');
     185        //var trimmed_username=_username.replace(/^\s+|\s+$/g, '');
    186186        var trimmed_comment = _comment.replace(/^\s+|\s+$/g, '');
    187187       
    188         if(!trimmed_username || !trimmed_comment) \{
    189               doc.AddUserCommentForm.comment.value = "";
    190               doc.AddUserCommentForm.username.value = "";
     188        if(!trimmed_comment) \{ // || !trimmed_username
     189              doc.AddUserCommentForm.comment.value = "";             
     190              //doc.AddUserCommentForm.username.value = "";
    191191              doc.getElementById("usercommentfeedback").innerHTML = "_text-is-empty_";
    192192              return;
     
    262262
    263263        // GSAPI already knows the collection
    264         gsapi.setMetadataArray(docArray, "accumulate", "import|archives|index");
     264        var result = gsapi.setMetadataArray(docArray, "accumulate", "import|archives|index");
    265265
    266266        // clear the comment field as it has now been submitted, but not the username field
    267267        // as the user is logged in, so they should be able to commit again under their username.
    268268        doc.AddUserCommentForm.comment.value = "";
    269         doc.getElementById("usercommentfeedback").innerHTML = "_textcommentsubmitted_";
    270 
    271         // update display of existing user comments to show the newly added comment
    272         var usercommentdiv = document.getElementById("usercomments");
    273         if(usercommentdiv != undefined) \{
     269
     270        // check for locked collection error
     271        var errorIndex = result.indexOf("ERROR");
     272        if(errorIndex != -1) \{
     273           var endIndex = result.indexOf("\\n");
     274           var error = result.substring(errorIndex,endIndex);
     275           errormessage="Unable to add comment. " + error;
     276           doc.getElementById("usercommentfeedback").innerHTML = errormessage;
     277           //alert("Result: " + result);
     278        \} else \{
     279           doc.getElementById("usercommentfeedback").innerHTML = "_textcommentsubmitted_";     
     280
     281           // update display of existing user comments to show the newly added comment
     282           var usercommentdiv = document.getElementById("usercomments");
     283           if(usercommentdiv != undefined) \{
    274284             displayInUserCommentList(usercommentdiv, _username, _timestamp, _comment);
    275         \}
     285               \}
     286        \}     
    276287    \}
    277288</script>
  • main/trunk/greenstone2/web/script/gsajaxapi.js

    r27322 r27365  
    344344   
    345345    //this.urlGetSync(mdserver + "?" + params);
    346     this.urlPostSync(mdserver,params); 
     346    return this.urlPostSync(mdserver,params);   
    347347    }
    348348
Note: See TracChangeset for help on using the changeset viewer.