[Lada-commits] [PATCH] added client code to wrap objects into arrays

Wald Commits scm-commit at wald.intevation.org
Thu Dec 1 14:59:50 CET 2016


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1480600531 -3600
# Node ID d19170280a23389035191ae439b5298feae9639a
# Parent  96f9417c105ea312943ddce3c1b67ed816303b0d
added client code to wrap objects into arrays

diff -r 96f9417c105e -r d19170280a23 app/controller/grid/ProbeList.js
--- 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
      **/


More information about the Lada-commits mailing list