Mercurial > lada > lada-client
comparison 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 |
comparison
equal
deleted
inserted
replaced
1260:96f9417c105e | 1261:d19170280a23 |
---|---|
157 case "printsheet" : | 157 case "printsheet" : |
158 // The Data is loaded from the server again, so we need | 158 // The Data is loaded from the server again, so we need |
159 // to be a little bit asynchronous here... | 159 // to be a little bit asynchronous here... |
160 callback = function(response) { | 160 callback = function(response) { |
161 var data = response.responseText; | 161 var data = response.responseText; |
162 data = this.prepareData(data); // Wraps all messstellen and deskriptoren objects into an array | |
162 var printData = '{"layout": "A4 portrait", "outputFormat": "pdf",' | 163 var printData = '{"layout": "A4 portrait", "outputFormat": "pdf",' |
163 + '"attributes": { "proben": ' + data | 164 + '"attributes": { "proben": ' + data |
164 + '}}'; | 165 + '}}'; |
165 this.printpdf(printData, 'lada_erfassungsbogen', | 166 this.printpdf(printData, 'lada_erfassungsbogen', |
166 'lada-erfassungsbogen.pdf', button); | 167 'lada-erfassungsbogen.pdf', button); |
167 } | 168 } |
168 | 169 |
169 this.createSheetData(button, callback, this); | 170 this.createSheetData(button, callback, this); |
170 break; | 171 break; |
171 } | 172 } |
173 }, | |
174 | |
175 prepareData: function(data) { | |
176 // Copy data | |
177 prep = JSON.parse(data); | |
178 data = JSON.parse(data); | |
179 // ensure data and prep are equal, not sure | |
180 // if json.parse changes order of things | |
181 console.log(data); | |
182 for (i in data) { | |
183 probe = data[i]; | |
184 console.log(probe); | |
185 deskriptoren = probe.deskriptoren; | |
186 messstelle = probe.messstelle; | |
187 console.log(deskriptoren); | |
188 console.log(messstelle); | |
189 prep[i].messstelle = []; | |
190 prep[i].messstelle[0] = messstelle; | |
191 prep[i].deskriptoren = []; | |
192 prep[i].deskriptoren[0] = deskriptoren; | |
193 } | |
194 return JSON.stringify(prep); | |
172 }, | 195 }, |
173 | 196 |
174 /** | 197 /** |
175 * Toggles the buttons in the toolbar | 198 * Toggles the buttons in the toolbar |
176 **/ | 199 **/ |