diff app/view/proben/Edit.js @ 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 73bc17de6ff2
children 95b08b96f5c9
line wrap: on
line diff
--- 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();
     }
 });
 

http://lada.wald.intevation.org