changeset 448:bd2b26c249e2

Use 'load', not 'reload' to fill the proben store if its empty.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 05 Dec 2013 11:18:43 +0100
parents 12231f31c112
children c22b24926500
files app/controller/Proben.js
diffstat 1 files changed, 30 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Proben.js	Thu Dec 05 09:57:57 2013 +0100
+++ b/app/controller/Proben.js	Thu Dec 05 11:18:43 2013 +0100
@@ -213,40 +213,38 @@
         // Close Createdialog
         var win = form.up('window');
         win.close();
-        var resp = Ext.decode(response.responseText);
-        var warn = Array();
-        var err = Array();
-        if (resp.warnings) {
-            warn.push("<strong>Warnungen:</strong><br>");
-            for (var key in resp.warnings) {
-                warn.push(key + ": ");
-                warn.push(Lada.getApplication().bundle.getMsg(resp.warnings[key]) + "<br>");
-            }
-        }
-        if (resp.errors) {
-            err.push("<strong>Fehler:</strong><br>");
-            for (var key in resp.errors) {
-                err.push(key + ": ");
-                err.push(Lada.getApplication().bundle.getMsg(resp.warnings[key]) + "<br>");
-            }
+        var store = this.getProbenStore();
+        //Load or reload the probenstore.
+        if (store.getCount() === 0) {
+            store.load({
+                scope: this,
+                callback: function(records, operation, success) {
+                    console.log('Loaded store');
+                    // Open Editdialog
+                    var json = Ext.decode(response.responseText);
+                    if (json) {
+                        var probeId = json.data.probeId;
+                        var probe = store.findRecord("probeId", probeId);
+                        this.editItem(null, probe);
+                    }
+                }
+            });
         }
-        var msg = warn.join("") + err.join("");
-        Ext.MessageBox.alert("Ergebnis", msg);
-        // Reload store
-        var store = this.getProbenStore();
-        store.reload({
-            scope: this,
-            callback: function(records, operation, success) {
-                console.log('Reloaded store');
-                // Open Editdialog
-                var json = Ext.decode(response.responseText);
-                if (json) {
-                    var probeId = json.data.probeId;
-                    var probe = store.findRecord("probeId", probeId);
-                    this.editItem(null, probe);
+        else {
+            store.reload({
+                scope: this,
+                callback: function(records, operation, success) {
+                    console.log('Reloaded store');
+                    // Open Editdialog
+                    var json = Ext.decode(response.responseText);
+                    if (json) {
+                        var probeId = json.data.probeId;
+                        var probe = store.findRecord("probeId", probeId);
+                        this.editItem(null, probe);
+                    }
                 }
-            }
-        });
+            });
+        }
     },
     editSuccess: function(form, record, response) {
         // Reload store

http://lada.wald.intevation.org