Comment #5 on issue 794 by timw.at.work: Can not add screenshot
http://code.google.com/p/reviewboard/issues/detail?id=794

Note, this problem also prevents me from accessing "Update Diff"  
functionality, so it
seems to be consistent for all uses of formDlg (currently, only Update Diff  
and
Attach Screenshot).

The following very crude patch seems to work for me: if the  
previously-ignored
'upload' flag is set, this turns the AJAX call into a standard form post.  
The real
fix is probably to use a jQuery/YUI upload widget and/or implement iframe  
fun.

Note that form.submit was never being activated before my change (the  
existing code
trapped the submit button to do AJAX and returned false, blocking real form
submission), so I removed the 'submit' trap to allow my hack to work.

Index: htdocs/media/rb/js/common.js
===================================================================
--- htdocs/media/rb/js/common.js        (revision 1666)
+++ htdocs/media/rb/js/common.js        (working copy)
@@ -170,10 +170,8 @@

          var form = $("<form/>")
              .attr("action", options.action)
-            .submit(function(e) {
-                send();
-                return false;
-            })
+            .attr("method", "POST") // ignored for non-uploads
+            .attr("enctype", "multipart/form-data") // ignored for  
non-uploads
              .append($("<table/>")
                  .append($("<colgroup/>")
                      .append('<col/>')
@@ -235,8 +233,8 @@
                      $('<input type="button"/>')
                          .val(options.confirmLabel)
                          .click(function() {
-                            send();
-                            return false;
+if(console) console.log("submitting from box", "this", this, "self",  
self, "form",
form);
+                            return send(form);
                          })
                  ]
              });
@@ -248,15 +246,26 @@
          /*
           * Sends the form data to the server.
           */
-        function send() {
+        function send(f) {
+if(console) console.log("in send", options);
+
+            if( options.upload && f ) {
+                var a = options.url || (SITE_ROOT + "api/json" +  
options.path);
+                $(f).attr("action", a);
+if(console) console.log("submitting...", f);
+                f.submit(); // ugly: this will redirect the user to a JSON  
reply
+                return true;
+            }
              rbApiCall({
                  path: options.path,
                  buttons: $("input", self.modalBox("buttons")),
                  errorPrefix: "Saving the form failed due to a server  
error:",
                  success: function(rsp) {
+if(console) console.log("in send success", rsp);
                      checkForErrors(rsp);
                  }
              });
+            return false;
          }

I'll also note that I was blocked from uploading some valid JPEG files, but  
that is
probably a separate issue (to be filed once images can be uploaded).

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To post to this group, send email to reviewboard-issues@googlegroups.com
To unsubscribe from this group, send email to 
reviewboard-issues+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/reviewboard-issues?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to