changeset 107:84f32c62670f

Added form to create kommentare
author Torsten Irländer <torsten.irlaender@intevation.de>
date Wed, 19 Jun 2013 11:43:25 +0200
parents b91d5376db19
children 6c69bbb61c65
files app/controller/Kommentare.js app/model/Kommentar.js app/view/kommentare/Edit.js app/view/widgets/Mst.js
diffstat 4 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Kommentare.js	Tue Jun 18 14:02:48 2013 +0200
+++ b/app/controller/Kommentare.js	Wed Jun 19 11:43:25 2013 +0200
@@ -2,7 +2,8 @@
     extend: 'Ext.app.Controller',
     views: [
         'kommentare.List',
-        'kommentare.Edit'
+        'kommentare.Edit',
+        'kommentare.Create'
     ],
     stores: [
         'Kommentare'
@@ -32,11 +33,13 @@
     },
     addKommentar: function(button) {
         console.log('Adding new Kommentar');
-        var view = Ext.widget('kommentaredit');
+        var view = Ext.create('Lada.view.kommentare.Create');
         var form = view.down('form');
-        // Create a new Kommentar
-        var record = Ext.create('Lada.model.Kommentar');
-        form.loadRecord(record);
+        // Set probeId
+        var probenform = button.up('form');
+        var probe = probenform.getRecord();
+        var probeId = probe.get('probeId');
+        form.model.set('probeId', probeId);
     },
     deleteKommentar: function(button) {
         // Get selected item in grid
--- a/app/model/Kommentar.js	Tue Jun 18 14:02:48 2013 +0200
+++ b/app/model/Kommentar.js	Wed Jun 19 11:43:25 2013 +0200
@@ -6,7 +6,7 @@
         {name: "convertedId", convert:buildId},
         {name: "probeId"},
         {name: "erzeuger"},
-        {name: "kdatum"},
+        {name: "kdatum", type: 'date', convert: ts2date, defaultValue: new Date()},
         {name: "ktext"}
     ],
     idProperty: "convertedId",
@@ -24,3 +24,8 @@
 function buildId(v, record){
     return record.get('probeId') + record.get('kid');
 }
+
+function ts2date(v, record){
+    // Converts a timestamp into a date object.
+    return new Date(v);
+}
--- a/app/view/kommentare/Edit.js	Tue Jun 18 14:02:48 2013 +0200
+++ b/app/view/kommentare/Edit.js	Wed Jun 19 11:43:25 2013 +0200
@@ -29,7 +29,7 @@
                         fieldLabel: 'Erzeuger'
                     },
                     {
-                        xtype: 'textfield',
+                        xtype: 'datefield',
                         name: 'kdatum',
                         fieldLabel: 'Datum'
                     },
--- a/app/view/widgets/Mst.js	Tue Jun 18 14:02:48 2013 +0200
+++ b/app/view/widgets/Mst.js	Wed Jun 19 11:43:25 2013 +0200
@@ -4,7 +4,8 @@
         alias: 'widget.mst',
         store: 'Mst',
         displayField:'mstId',
-        valueField: 'mstId' ,
+        valueField: 'mstId',
+        typeAhead: true,
         emptyText:'Wählen Sie eine Messstelle',
     initComponent: function() {
         this.callParent(arguments);

http://lada.wald.intevation.org