[yocto] [patchwork][PATCH v2 1/2] series.js: Get patch id and pass it to POST request

Jose Lamego jose.a.lamego at linux.intel.com
Tue Feb 7 12:17:56 PST 2017


Patch forms in series view do not pass selected patch id
as request element during a POST call, so no status/bundle
updates can be performed from such view.

This change includes the selected patch id as a request
element and pass it to POST call through a hidden input field.

[YOCTO #10973]

Signed-off-by: Jose Lamego <jose.a.lamego at linux.intel.com>
---
 htdocs/js/series.js | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/htdocs/js/series.js b/htdocs/js/series.js
index 4f4f477..bd75790 100644
--- a/htdocs/js/series.js
+++ b/htdocs/js/series.js
@@ -1,5 +1,5 @@
 $(document).ready(function(){
-    $('[data-toggle="tooltip"]').tooltip();
+    $('[data-toggle="tooltip"]').tooltip()
     revTab=document.getElementById('revs-list')
     coverView=document.getElementById('cover-letter-view'),
     patchView=document.getElementById('patch-view'),
@@ -34,10 +34,31 @@ $(document).ready(function(){
     })
 
     $('.patch-link').on('click', function(){
+        var pa=this.getAttribute("data-url")
+        var curr_rev=document.getElementById('revs-list').value
+        pa=pa.match(/\d+/)[0]
         coverView.style.display='none'
         patchView.style.display='block'
         patchView.innerHTML=
         '<p style="text-align:center;">Loading patch...</p>'
-        $("#patch-view").load(this.getAttribute("data-url") + " #patch-body")
+        $("#patch-view").load(
+            this.getAttribute("data-url") + " #patch-body", function() {
+                forms=document.forms
+                for (i=0; i<document.forms.length; i++){
+                    var n=(i + 1)
+                    var patch_field=document.createElement("input")
+                    patch_field.type="hidden"
+                    patch_field.name="patch"
+                    patch_field.value=pa
+                    var div=document.createElement("div")
+                    var this_form=document.forms.item(i)
+                    if (typeof this_form !== "undefined"){
+                        this_form.appendChild(div)
+                        div.appendChild(patch_field)
+                    }
+                }
+            }
+
+        )
     })
 })
-- 
1.9.1




More information about the yocto mailing list