diff app/controller/grid/ProbeList.js @ 1261:d19170280a23

added client code to wrap objects into arrays
author Dustin Demuth <dustin@intevation.de>
date Thu, 01 Dec 2016 14:55:31 +0100
parents f961f94495c8
children 52ecf67e9e80
line wrap: on
line diff
--- a/app/controller/grid/ProbeList.js	Mon Nov 28 08:28:53 2016 +0100
+++ b/app/controller/grid/ProbeList.js	Thu Dec 01 14:55:31 2016 +0100
@@ -159,6 +159,7 @@
                 // to be a little bit asynchronous here...
                 callback = function(response) {
                     var data = response.responseText;
+                    data = this.prepareData(data); // Wraps all messstellen and deskriptoren objects into an array
                     var printData = '{"layout": "A4 portrait", "outputFormat": "pdf",'
                             +   '"attributes": { "proben": ' +  data
                             +   '}}';
@@ -171,6 +172,28 @@
         }
     },
 
+    prepareData: function(data) {
+        // Copy data
+        prep = JSON.parse(data);
+        data = JSON.parse(data);
+        // ensure data and prep are equal, not sure
+        // if json.parse changes order of things
+        console.log(data);
+        for (i in data) {
+            probe = data[i];
+            console.log(probe);
+            deskriptoren = probe.deskriptoren;
+            messstelle = probe.messstelle;
+            console.log(deskriptoren);
+            console.log(messstelle);
+            prep[i].messstelle = [];
+            prep[i].messstelle[0] = messstelle;
+            prep[i].deskriptoren = [];
+            prep[i].deskriptoren[0] = deskriptoren;
+        }
+        return JSON.stringify(prep);
+    },
+
     /**
      * Toggles the buttons in the toolbar
      **/

http://lada.wald.intevation.org