[Lada-commits] [PATCH] Implemented creating and editing new l_ort. Created editing orte

Wald Commits scm-commit at wald.intevation.org
Tue Jul 2 15:29:34 CEST 2013


# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1372771721 -7200
# Node ID 16ba7e2465fddf8fbec4cb605d57853d2cd0bb29
# Parent  e9fb4814153a04f1e773ab1618dbdb3c9eb3bc6c
Implemented creating and editing new l_ort. Created editing orte.

diff -r e9fb4814153a -r 16ba7e2465fd app/controller/Orte.js
--- a/app/controller/Orte.js	Tue Jul 02 14:08:18 2013 +0200
+++ b/app/controller/Orte.js	Tue Jul 02 15:28:41 2013 +0200
@@ -43,7 +43,44 @@
     saveOrt: function(button) {
         console.log('Saving Ort');
         var form = button.up('window').down('form');
-        form.commit();
+        var fform = form.getForm();
+
+        var ortdetail = null;
+        var ortdetailstore = Ext.getStore('Ortedetails');
+        var newortdetail = true;
+
+        var ortid = fform.findField('ortId').getValue();
+        if (ortid === null) {
+            console.log('New Ortdetail');
+            ortdetail = Ext.create('Lada.model.Ortdetail');
+            ortdetailstore.add(ortdetail);
+            newortdetail = true;
+        } else {
+            console.log('Editing Ortdetail');
+            ortdetail = ortdetailstore.getById(ortid);
+        }
+
+        var fields = ['beschreibung', 'bezeichnung', 'hoeheLand',
+                      'latitude', 'longitude', 'staatId', 'gemId'];
+        for (var i = fields.length - 1; i >= 0; i--){
+            ffield = fform.findField("ort_"+fields[i]);
+            ortdetail.set(fields[i], ffield.getValue());
+        }
+        // Create a new Ortedetail if nessecary
+        ortdetailstore.sync({
+            success: function() {
+                if (newortdetail) {
+                    // TODO: Get ID from new created ortdetail and set it to the ort
+                    ortid = 1;
+                    form.model.set('ortId', ortid);
+                }
+                form.commit();
+            },
+            failure: function() {
+                console.log('Error on saving Ortdetails');
+            }
+        });
+
     },
     addOrt: function(button) {
         console.log('Adding new Ort for Probe ' + button.probeId);
diff -r e9fb4814153a -r 16ba7e2465fd app/model/Ort.js
--- a/app/model/Ort.js	Tue Jul 02 14:08:18 2013 +0200
+++ b/app/model/Ort.js	Tue Jul 02 15:28:41 2013 +0200
@@ -6,7 +6,7 @@
         {name: "ortId", type: 'int'},
         {name: "probeId"},
         {name: "ortsTyp"},
-        {name: "ortzusatztext"},
+        {name: "ortszusatztext"},
         {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()}
     ],
     idProperty: "portId",
diff -r e9fb4814153a -r 16ba7e2465fd app/model/Ortdetail.js
--- a/app/model/Ortdetail.js	Tue Jul 02 14:08:18 2013 +0200
+++ b/app/model/Ortdetail.js	Tue Jul 02 15:28:41 2013 +0200
@@ -4,7 +4,7 @@
         {name: "ortId"},
         {name: "bezeichnung"},
         {name: "beschreibung"},
-        {name: "usnscharf"},
+        {name: "unscharf"},
         {name: "nutsCode"},
         {name: "koordXExtern"},
         {name: "koordYExtern"},
@@ -14,7 +14,7 @@
         {name: "latitude", type: 'float'},
         {name: "staatId"},
         {name: "gemId"},
-        {name: "oTyp"}
+        {name: "otyp"}
     ],
     idProperty: "ortId",
     proxy: {
diff -r e9fb4814153a -r 16ba7e2465fd app/view/orte/Create.js
--- a/app/view/orte/Create.js	Tue Jul 02 14:08:18 2013 +0200
+++ b/app/view/orte/Create.js	Tue Jul 02 15:28:41 2013 +0200
@@ -11,7 +11,7 @@
         'Lada.view.orte.CreateForm'
     ],
     initComponent: function() {
-        var form = Ext.create('Lada.view.orte.CreateForm');
+        var form = Ext.create('Lada.view.orte.CreateForm', this.initialConfig);
         this.items = [form];
         this.buttons = [
             {
diff -r e9fb4814153a -r 16ba7e2465fd app/view/orte/CreateForm.js
--- a/app/view/orte/CreateForm.js	Tue Jul 02 14:08:18 2013 +0200
+++ b/app/view/orte/CreateForm.js	Tue Jul 02 15:28:41 2013 +0200
@@ -26,10 +26,7 @@
                             for (var i = fields.length - 1; i >= 0; i--){
                                 ffield = form.findField("ort_"+fields[i]);
                                 ffield.setValue(ort.get(fields[i]));
-                                ffield.setReadOnly(true);
                             }
-                        } else {
-                            this.setReadOnly(false);
                         }
                     }
                 }
@@ -38,7 +35,7 @@
                 xtype: 'textfield',
                 name: 'ortsTyp',
                 maxLength: 1,
-                fieldLabel: 'Type'
+                fieldLabel: 'Typ'
             },
             {
                 xtype: 'textareafield',
diff -r e9fb4814153a -r 16ba7e2465fd app/view/proben/EditForm.js
--- a/app/view/proben/EditForm.js	Tue Jul 02 14:08:18 2013 +0200
+++ b/app/view/proben/EditForm.js	Tue Jul 02 15:28:41 2013 +0200
@@ -159,7 +159,8 @@
                 padding: '10 10',
                 items: [
                     {
-                        xtype: 'ortelist'
+                        xtype: 'ortelist',
+                        probeId: this.modelId
                     }
                 ]
             },


More information about the Lada-commits mailing list