[Lada-commits] [PATCH] Use 'load', not 'reload' to fill the proben store if its empty

Wald Commits scm-commit at wald.intevation.org
Thu Dec 5 11:18:54 CET 2013


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1386238723 -3600
# Node ID bd2b26c249e2d0b2ecfe71a3de5322157f4c1836
# Parent  12231f31c1124552ab739fee96fa1da525f63c57
Use 'load', not 'reload' to fill the proben store if its empty.

diff -r 12231f31c112 -r bd2b26c249e2 app/controller/Proben.js
--- 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>");
-            }
+        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);
+                    }
+                }
+            });
         }
-        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>");
-            }
+        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);
+                    }
+                }
+            });
         }
-        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);
-                }
-            }
-        });
     },
     editSuccess: function(form, record, response) {
         // Reload store


More information about the Lada-commits mailing list