changeset 71:db26aeebe521

Added new Form for editing proben. Use this form in the edit window.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Wed, 05 Jun 2013 16:20:54 +0200
parents 1a943947a7d2
children 345896d5e6b5
files app/controller/Proben.js app/view/proben/Edit.js app/view/proben/EditForm.js
diffstat 3 files changed, 339 insertions(+), 353 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Proben.js	Wed Jun 05 15:43:42 2013 +0200
+++ b/app/controller/Proben.js	Wed Jun 05 16:20:54 2013 +0200
@@ -38,27 +38,14 @@
         });
     },
     addProbe: function(button) {
-        console.log('Adding new Probe 1');
+        console.log('Adding new Probe');
         var view = Ext.widget('probencreate');
     },
     editProbe: function(grid, record) {
-        console.log('Double click on ' + record.get('probeId'));
-        // Create new window to edit the seletced record.
-        var view = Ext.widget('probenedit');
-        var form = view.down('form');
-        form.loadRecord(record);
-
-        // Load kommentare
-        var kommentare = form.down('kommentarelist'); //form.down('kommentare');
-        var kstore = kommentare.getStore();
-        kstore.load({
-            params: {
-                probe: record.data['probeId']
-            }
-        });
-
-        // Set form data
-        console.log("Loaded probe with ID " + record.getId()); //outputs ID
+        console.log('Editing Probe');
+        var id = record.get('probeId');
+        var view = Ext.widget('probenedit', {modelId: id});
+        console.log("Loaded Probe with ID " + record.getId()); //outputs ID
     },
     createSuccess: function(form, record, operation) {
         var win = form.up('window');
--- a/app/view/proben/Edit.js	Wed Jun 05 15:43:42 2013 +0200
+++ b/app/view/proben/Edit.js	Wed Jun 05 16:20:54 2013 +0200
@@ -12,6 +12,7 @@
     modal: true,
 
     requires: [
+        'Lada.view.proben.EditForm',
         'Lada.view.widgets.Uwb',
         'Lada.view.widgets.Datenbasis',
         'Lada.view.widgets.Probenart',
@@ -21,347 +22,29 @@
     ],
 
     initComponent: function() {
-        this.items = [
-            {
-                //Define the form
-                xtype: 'form',
-                bodyPadding: '10 10',
-                border: 0,
-                items: [
-                    // Probenangaben
-                    {
-                        xtype: 'fieldset',
-                        title: 'Probenangaben',
-                        defaults: {
-                                labelWidth: 150
-                        },
-                        items: [
-                            {
-                                xtype: 'textfield',
-                                name: 'mstId',
-                                fieldLabel: 'Messstelle'
-                            },
-                            {
-                                xtype: 'textfield',
-                                name: 'hauptprobenNr',
-                                fieldLabel: 'Hauptprobennr.'
-                            },
-                            {
-                                xtype: 'textfield',
-                                name: 'probeId',
-                                fieldLabel: 'Probe-ID'
-                            },
-                            {
-                                xtype: 'fieldset',
-                                title: 'Erweiterte Probenangaben',
-                                collapsible: true,
-                                collapsed: true,
-                                items: [
-                                    {
-                                        xtype: 'datenbasis',
-                                        id: 'datenbasis',
-                                        editable: false,
-                                        name: 'datenbasisId',
-                                        fieldLabel: 'Datenbasis'
-                                    },
-                                    {
-                                        xtype: 'betriebsart',
-                                        name: 'baId',
-                                        fieldLabel: 'Betriebsart'
-                                    },
-                                    {
-                                        xtype: 'testdatensatz',
-                                        name: 'test',
-                                        fieldLabel: 'Testdatensatz'
-                                    },
-                                    {
-                                        xtype: 'probenart',
-                                        id: 'probenart',
-                                        editable: false,
-                                        name: 'probenartId',
-                                        fieldLabel: 'Probenart'
-                                    },
-                                    {
-                                        xtype: 'textfield',
-                                        name: 'probenartId',
-                                        fieldLabel: 'Probennehmer'
-                                    },
-                                    {
-                                        xtype: 'textfield',
-                                        name: 'x11',
-                                        fieldLabel: 'Datensatzerzeuger'
-                                    }
-                                ]
-                            }
-                        ]
-                    },
-                    // Medium
-                    {
-                        xtype: 'fieldset',
-                        title: 'Medium',
-                        defaults: {
-                                labelWidth: 150
-                        },
-                        items: [
-                                {
-                                    xtype: 'uwb',
-                                    name: 'umwId',
-                                    fieldLabel: 'Umweltbereich'
-                                },
-                                {
-                                    xtype: 'textfield',
-                                    name: 'media',
-                                    fieldLabel: 'Medienbezeichnung'
-                                },
-                                {
-                                    xtype: 'textfield',
-                                    name: 'mediaDesk',
-                                    fieldLabel: 'Deskriptoren'
-                                },
-                                {
-                                    xtype: 'fieldset',
-                                    title: 'Details Deskriptoren',
-                                    collapsible: true,
-                                    collapsed: true,
-                                    defaultType: 'textfield',
-                                    items: this.buildDescriptors()
-                                }
-                        ]
-                    },
-                    // Zeit
-                    {
-                        xtype: 'fieldset',
-                        title: 'Zeit',
-                        defaultType: 'datefield',
-                        defaults: {
-                                labelWidth: 150
-                        },
-                        items: [
-                            {
-                                fieldLabel: 'Probennahme Beginn',
-                                name: 'probeentnahmeBeginn'
-                            },
-                            {
-                                fieldLabel: 'Probennahme Ende',
-                                name: 'probeentnahmeEnde'
-                            },
-                            {
-                                fieldLabel: 'Sollzeit Von',
-                                name: 'solldatumBeginn'
-                            },
-                            {
-                                fieldLabel: 'Sollzeit Bis',
-                                name: 'solldatumEnde'
-                            },
-                            {
-                                fieldLabel: 'Ursprungszeit',
-                                name: 'z5'
-                            }
-                        ]
-                    },
-                    // Ortsangaben
-                    {
-                        xtype: 'fieldset',
-                        title: 'Ortsangaben',
-                        padding: '10 10',
-                        items: [
-                            {
-                                xtype: 'grid',
-                                dockedItems: [
-                                    {
-                                        xtype: 'toolbar',
-                                        dock: 'top',
-                                        items: [
-                                            {
-                                                text: 'Hinzufügen',
-                                                icon: 'gfx/plus.gif'
-                                            },
-                                            {
-                                                text: 'Löschen',
-                                                icon: 'gfx/minus.gif'
-                                            }
-                                        ]
-                                    }
-                                ],
-                                columns: [
-                                    {
-                                        text: 'Typ'
-                                    },
-                                    {
-                                        text: 'Staat'
-                                    },
-                                    {
-                                        text: 'Gem-ID'
-                                    },
-                                    {
-                                        text: 'Gemeindebezeichnung',
-                                        flex: 1
-                                    },
-                                    {
-                                        text: 'Messpunkt',
-                                        flex: 1
-                                    }
-                                ]
-                            }
-                        ]
-                    },
-                    // Probenzusatzwerte
-                    {
-                        xtype: 'fieldset',
-                        title: 'Probenzusatzwerte',
-                        collapsible: true,
-                        collapsed: true,
-                        padding: '10 10',
-                        items: [
-                            {
-                                xtype: 'grid',
-                                dockedItems: [
-                                    {
-                                        xtype: 'toolbar',
-                                        dock: 'top',
-                                        items: [
-                                            {
-                                                text: 'Hinzufügen',
-                                                icon: 'gfx/plus.gif'
-                                            },
-                                            {
-                                                text: 'Löschen',
-                                                icon: 'gfx/minus.gif'
-                                            }
-                                        ]
-                                    }
-                                ],
-                                columns: [
-                                    {
-                                        text: 'PZW-ID'
-                                    },
-                                    {
-                                        text: 'PZW-Größe'
-                                    },
-                                    {
-                                        text: '&lt; NWG'
-                                    },
-                                    {
-                                        text: '&lt; PZW'
-                                    },
-                                    {
-                                        text: 'rel. Unsich.[%]'
-                                    },
-                                    {
-                                        text: 'Maßeinheit',
-                                        flex: 1
-                                    }
-                                ]
-                            }
-                        ]
-                    },
-                    // Probenkommentar
-                    {
-                        xtype: 'fieldset',
-                        title: 'Probenkommentare',
-                        collapsible: true,
-                        collapsed: true,
-                        padding: '10 10',
-                        items: [
-                            {
-                                xtype: 'kommentarelist'
-                            }
-                        ]
-                    },
-                    // Messungsangaben
-                    {
-                        xtype: 'fieldset',
-                        title: 'Messungsangaben',
-                        padding: '10 10',
-                        items: [
-                            {
-                                xtype: 'grid',
-                                dockedItems: [
-                                    {
-                                        xtype: 'toolbar',
-                                        dock: 'top',
-                                        items: [
-                                            {
-                                                text: 'Hinzufügen',
-                                                icon: 'gfx/plus.gif'
-                                            },
-                                            {
-                                                text: 'Löschen',
-                                                icon: 'gfx/minus.gif'
-                                            }
-                                        ]
-                                    }
-                                ],
-                                columns: [
-                                    {
-                                        text: 'Mess.ID',
-                                        width: 50
-                                    },
-                                    {
-                                        text: 'NPR-Nr.',
-                                        width: 50
-                                    },
-                                    {
-                                        text: 'MMT',
-                                        width: 50
-                                    },
-                                    {
-                                        text: 'Messzeit'
-                                    },
-                                    {
-                                        text: 'Status'
-                                    },
-                                    {
-                                        text: 'OK-Flag'
-                                    },
-                                    {
-                                        text: 'Anzahl Nuklide'
-                                    },
-                                    {
-                                        text: 'Anzahl Kommentare',
-                                        flex: 1
-                                    }
-                                ]
-                            }
-                        ]
-                    }
-                ]
+        // InitialConfig is the config object passed to the constructor on
+        // creation of this window. We need to pass it throuh to the form as
+        // we need the "modelId" param to load the correct item.
+        var form = Ext.create('Lada.view.proben.EditForm', this.initialConfig);
+        // Load kommentare
+        //var record = form.getRecord();
+        var kommentare = form.down('kommentarelist'); //form.down('kommentare');
+        var kstore = kommentare.getStore();
+        kstore.load({
+            params: {
+                probe: this.initialConfig['modelId']
+                //probe: record.data['probeId']
             }
-        ];
-
+        });
+        this.items = [form];
         this.buttons = [
             {
                 text: 'Speichern',
-                action: 'save'
-            },
-            {
-                text: 'Verwerfen',
-                scope: this,
-                handler: this.close
+                handler: form.commit,
+                scope: form
             }
         ];
-        this.callParent(arguments);
-    },
-    buildDescriptors: function() {
-        var fields = new Array();
-        for ($i=0; $i<12; $i++) {
-            fields[$i] = {fieldLabel: 'S'+$i, name: 's'+$i};
-        }
-        return fields;
-    },
-    listeners: {
-        afterrender: function() {
-            // FIXME: This does not work! I do not know how to set the correct
-            // value in the combobox based on the model value.
-            // Will iterate over defined comboboxes and set the value
-            var combos = ['probenart', 'datenbasis'];
-            for (var i = combos.length - 1; i >= 0; i--){
-                console.log('Searching for ' + combos[i]);
-                var element = Ext.getCmp(combos[i]);
-                // Statically set to 2. Must be the value from the model.
-                element.setValue(2);
-            }
-        }
+        this.callParent();
     }
 });
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/proben/EditForm.js	Wed Jun 05 16:20:54 2013 +0200
@@ -0,0 +1,316 @@
+Ext.define('Lada.view.proben.EditForm', {
+    extend: 'Lada.view.widgets.LadaForm',
+    model: 'Lada.model.Probe',
+
+    initComponent: function() {
+       this.items = [
+            {
+                xtype: 'fieldset',
+                title: 'Probenangaben',
+                defaults: {
+                        labelWidth: 150
+                },
+                items: [
+                    {
+                        xtype: 'textfield',
+                        name: 'mstId',
+                        fieldLabel: 'Messstelle'
+                    },
+                    {
+                        xtype: 'textfield',
+                        name: 'hauptprobenNr',
+                        fieldLabel: 'Hauptprobennr.'
+                    },
+                    {
+                        xtype: 'textfield',
+                        name: 'probeId',
+                        fieldLabel: 'Probe-ID'
+                    },
+                    {
+                        xtype: 'fieldset',
+                        title: 'Erweiterte Probenangaben',
+                        collapsible: true,
+                        collapsed: true,
+                        items: [
+                            {
+                                xtype: 'datenbasis',
+                                id: 'datenbasis',
+                                editable: false,
+                                name: 'datenbasisId',
+                                fieldLabel: 'Datenbasis'
+                            },
+                            {
+                                xtype: 'betriebsart',
+                                name: 'baId',
+                                fieldLabel: 'Betriebsart'
+                            },
+                            {
+                                xtype: 'testdatensatz',
+                                name: 'test',
+                                fieldLabel: 'Testdatensatz'
+                            },
+                            // TODO: Fix Probenart, Is sent as list which
+                            // causes an error on server side.
+                            //{
+                            //    xtype: 'probenart',
+                            //    id: 'probenart',
+                            //    editable: false,
+                            //    name: 'probenartId',
+                            //    fieldLabel: 'Probenart'
+                            //},
+                            {
+                                xtype: 'textfield',
+                                name: 'probenartId',
+                                fieldLabel: 'Probennehmer'
+                            },
+                            {
+                                xtype: 'textfield',
+                                name: 'x11',
+                                fieldLabel: 'Datensatzerzeuger'
+                            }
+                        ]
+                    }
+                ]
+            },
+            // Medium
+            {
+                xtype: 'fieldset',
+                title: 'Medium',
+                defaults: {
+                        labelWidth: 150
+                },
+                items: [
+                        {
+                            xtype: 'uwb',
+                            name: 'umwId',
+                            fieldLabel: 'Umweltbereich'
+                        },
+                        {
+                            xtype: 'textfield',
+                            name: 'media',
+                            fieldLabel: 'Medienbezeichnung'
+                        },
+                        {
+                            xtype: 'textfield',
+                            name: 'mediaDesk',
+                            fieldLabel: 'Deskriptoren'
+                        },
+                        {
+                            xtype: 'fieldset',
+                            title: 'Details Deskriptoren',
+                            collapsible: true,
+                            collapsed: true,
+                            defaultType: 'textfield',
+                            items: this.buildDescriptors()
+                        }
+                ]
+            },
+            // Zeit
+            {
+                xtype: 'fieldset',
+                title: 'Zeit',
+                defaultType: 'datefield',
+                defaults: {
+                        labelWidth: 150
+                },
+                items: [
+                    {
+                        fieldLabel: 'Probennahme Beginn',
+                        name: 'probeentnahmeBeginn'
+                    },
+                    {
+                        fieldLabel: 'Probennahme Ende',
+                        name: 'probeentnahmeEnde'
+                    },
+                    {
+                        fieldLabel: 'Sollzeit Von',
+                        name: 'solldatumBeginn'
+                    },
+                    {
+                        fieldLabel: 'Sollzeit Bis',
+                        name: 'solldatumEnde'
+                    },
+                    {
+                        fieldLabel: 'Ursprungszeit',
+                        name: 'z5'
+                    }
+                ]
+            },
+            // Ortsangaben
+            {
+                xtype: 'fieldset',
+                title: 'Ortsangaben',
+                padding: '10 10',
+                items: [
+                    {
+                        xtype: 'grid',
+                        dockedItems: [
+                            {
+                                xtype: 'toolbar',
+                                dock: 'top',
+                                items: [
+                                    {
+                                        text: 'Hinzufügen',
+                                        icon: 'gfx/plus.gif'
+                                    },
+                                    {
+                                        text: 'Löschen',
+                                        icon: 'gfx/minus.gif'
+                                    }
+                                ]
+                            }
+                        ],
+                        columns: [
+                            {
+                                text: 'Typ'
+                            },
+                            {
+                                text: 'Staat'
+                            },
+                            {
+                                text: 'Gem-ID'
+                            },
+                            {
+                                text: 'Gemeindebezeichnung',
+                                flex: 1
+                            },
+                            {
+                                text: 'Messpunkt',
+                                flex: 1
+                            }
+                        ]
+                    }
+                ]
+            },
+            // Probenzusatzwerte
+            {
+                xtype: 'fieldset',
+                title: 'Probenzusatzwerte',
+                collapsible: true,
+                collapsed: true,
+                padding: '10 10',
+                items: [
+                    {
+                        xtype: 'grid',
+                        dockedItems: [
+                            {
+                                xtype: 'toolbar',
+                                dock: 'top',
+                                items: [
+                                    {
+                                        text: 'Hinzufügen',
+                                        icon: 'gfx/plus.gif'
+                                    },
+                                    {
+                                        text: 'Löschen',
+                                        icon: 'gfx/minus.gif'
+                                    }
+                                ]
+                            }
+                        ],
+                        columns: [
+                            {
+                                text: 'PZW-ID'
+                            },
+                            {
+                                text: 'PZW-Größe'
+                            },
+                            {
+                                text: '&lt; NWG'
+                            },
+                            {
+                                text: '&lt; PZW'
+                            },
+                            {
+                                text: 'rel. Unsich.[%]'
+                            },
+                            {
+                                text: 'Maßeinheit',
+                                flex: 1
+                            }
+                        ]
+                    }
+                ]
+            },
+            // Probenkommentar
+            {
+                xtype: 'fieldset',
+                title: 'Probenkommentare',
+                collapsible: true,
+                collapsed: true,
+                padding: '10 10',
+                items: [
+                    {
+                        xtype: 'kommentarelist'
+                    }
+                ]
+            },
+            // Messungsangaben
+            {
+                xtype: 'fieldset',
+                title: 'Messungsangaben',
+                padding: '10 10',
+                items: [
+                    {
+                        xtype: 'grid',
+                        dockedItems: [
+                            {
+                                xtype: 'toolbar',
+                                dock: 'top',
+                                items: [
+                                    {
+                                        text: 'Hinzufügen',
+                                        icon: 'gfx/plus.gif'
+                                    },
+                                    {
+                                        text: 'Löschen',
+                                        icon: 'gfx/minus.gif'
+                                    }
+                                ]
+                            }
+                        ],
+                        columns: [
+                            {
+                                text: 'Mess.ID',
+                                width: 50
+                            },
+                            {
+                                text: 'NPR-Nr.',
+                                width: 50
+                            },
+                            {
+                                text: 'MMT',
+                                width: 50
+                            },
+                            {
+                                text: 'Messzeit'
+                            },
+                            {
+                                text: 'Status'
+                            },
+                            {
+                                text: 'OK-Flag'
+                            },
+                            {
+                                text: 'Anzahl Nuklide'
+                            },
+                            {
+                                text: 'Anzahl Kommentare',
+                                flex: 1
+                            }
+                        ]
+                    }
+                ]
+            }
+
+        ];
+        this.callParent();
+    },
+    buildDescriptors: function() {
+        var fields = new Array();
+        for ($i=0; $i<12; $i++) {
+            fields[$i] = {fieldLabel: 'S'+$i, name: 's'+$i};
+        }
+        return fields;
+    }
+});

http://lada.wald.intevation.org