diff app/model/Zusatzwert.js @ 122:a7bfaeb1655d

Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 21 Jun 2013 16:56:17 +0200
parents 189a93e31be9
children d78bb4ca6089
line wrap: on
line diff
--- a/app/model/Zusatzwert.js	Fri Jun 21 16:55:23 2013 +0200
+++ b/app/model/Zusatzwert.js	Fri Jun 21 16:56:17 2013 +0200
@@ -1,25 +1,35 @@
 Ext.define('Lada.model.Zusatzwert', {
     extend: 'Ext.data.Model',
+    requires: [
+        'Lada.model.Probenzusatzwert'
+    ],
     fields: [
         {name: "id"},
-        {name: "probeId"},
-        //{name: "pzsId", mapping: "id.pzsId"},
-        {name: "sprobenZusatz"},
-
-        // Hier muss die tatsächliche Nachweisgrenze eingegeben werden.
+        {name: "pzsId", mapping: "id.pzsId"},
+        {name: "probeId", mapping: "id.probeId"},
         {name: "nwgZuMesswert", type: 'float'},
         {name: "messwertPzs", type: 'float'},
         {name: "messfehler", type: 'float'},
-        {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()},
+        {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()}
 
-        // This are fields from the s_zusatzwert_table. They are currently not
-        // needed for displaying values in the grid.
-        {name: "sprobenZusatz_beschreibung", mapping: "sprobenZusatz.beschreibung"},
-        {name: "sprobenZusatz_pzsId", mapping: "sprobenZusatz.pzsId"},
-        {name: "sprobenZusatz_mehId", mapping: "sprobenZusatz.mehId"}
+        //// This are fields from the s_zusatzwert_table. They are currently not
+        //// needed for displaying values in the grid.
+        //{name: "sprobenZusatz"},
+        //{name: "sprobenZusatz_beschreibung", mapping: "sprobenZusatz.beschreibung"},
+        //{name: "sprobenZusatz_pzsId", mapping: "sprobenZusatz.pzsId"},
+        //{name: "sprobenZusatz_mehId", mapping: "sprobenZusatz.mehId"}
     ],
-    //// we can use the hasOne shortcut on the model to create a hasOne association
-    //associations: [{ type: 'hasOne', model: 'ProbenZusatzwert', foreignKey: 'pzsId'}],
+    hasOne: [
+        {
+            model: 'Lada.model.Probenzusatzwert',
+            primaryKey: 'pzsId',
+            name: 'sprobenZusatz',
+            associationKey: 'sprobenZusatz',
+            foreignKey: 'pzsId',
+            getterName: 'getProbenzusatz',
+            setterName: 'setProbenzusatz'
+        }
+    ],
     idProperty: "id",
     proxy: {
         type: 'rest',
@@ -28,31 +38,14 @@
         reader: {
             type: 'json',
             root: 'data'
+        },
+        writer: {
+            type: 'json',
+            writeEverything : true
         }
     }
 });
 
-//Ext.define('Lada.model.ProbenZusatzwert', {
-//    extend: 'Ext.data.Model',
-//    fields: [
-//        {name: "pzsId"},
-//        {name: "medId"},
-//        {name: "bschreibung"},
-//        {name: "zusatzwert"},
-//        {name: "eudfKeyword"}
-//    ],
-//    idProperty: "pzsId",
-//    proxy: {
-//        type: 'rest',
-//        appendId: true, //default
-//        url: 'server/rest/probenzusatzwert',
-//        reader: {
-//            type: 'json',
-//            root: 'data'
-//        }
-//    }
-//};
-
 function buildId(v, record){
     return record.get('probeId') + ',' + record.get('pzsId');
 }

http://lada.wald.intevation.org