changeset 611:8a156a7fbe67

added a controller for messungforms, modified testdatensatz-widget to load a local store, removed dirtychange listeners from probe-form
author Dustin Demuth <dustin@intevation.de>
date Fri, 13 Mar 2015 15:11:12 +0100
parents f240fe19ff5d
children 027703542596
files app.js app/controller/form/Messung.js app/view/form/Messung.js app/view/form/Probe.js app/view/widget/Messmethode.js app/view/widget/Testdatensatz.js app/view/window/MessungEdit.js
diffstat 7 files changed, 175 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Fri Mar 13 13:20:49 2015 +0100
+++ b/app.js	Fri Mar 13 15:11:12 2015 +0100
@@ -104,6 +104,7 @@
         'Lada.controller.Filter',
         'Lada.controller.FilterResult',
         'Lada.controller.form.Probe',
+        'Lada.controller.form.Messung',
         'Lada.controller.form.Ort',
         'Lada.controller.grid.Ort',
         'Lada.controller.grid.Probenzusatzwert',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/form/Messung.js	Fri Mar 13 15:11:12 2015 +0100
@@ -0,0 +1,75 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+Ext.define('Lada.controller.form.Messung', {
+    extend: 'Ext.app.Controller',
+
+    init: function() {
+        this.control({
+            'messungform button[action=save]': {
+                click: this.save
+            },
+            'messungform button[action=discard]': {
+                click: this.discard
+            },
+            'messungform': {
+                dirtychange: this.dirtyForm
+            }
+        });
+    },
+
+    save: function(button) {
+        var formPanel = button.up('form');
+        var data = formPanel.getForm().getFieldValues(true);
+        for (var key in data) {
+            formPanel.getForm().getRecord().set(key, data[key]);
+        }
+        formPanel.getForm().getRecord().save({
+            success: function(record, response) {
+                var json = Ext.decode(response.response.responseText);
+                if (response.action !== 'create' &&
+                    json &&
+                    json.success) {
+                    button.setDisabled(true);
+                    button.up('toolbar').down('button[action=discard]')
+                        .setDisabled(true);
+                    formPanel.clearMessages();
+                    formPanel.setRecord(record);
+                    formPanel.setMessages(json.errors, json.warnings);
+                }
+            },
+            failure: function(record, response) {
+                button.setDisabled(true);
+                button.up('toolbar').down('button[action=discard]')
+                    .setDisabled(true);
+                formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
+                var json = response.request.scope.reader.jsonData;
+                if (json) {
+                    formPanel.setMessages(json.errors, json.warnings);
+                }
+            }
+        });
+        console.log('save');
+    },
+
+    discard: function(button) {
+        var formPanel = button.up('form');
+        formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
+    },
+
+    dirtyForm: function(form, dirty) {
+        if (dirty) {
+            form.owner.down('button[action=save]').setDisabled(false);
+            form.owner.down('button[action=discard]').setDisabled(false);
+        }
+        else {
+            form.owner.down('button[action=save]').setDisabled(true);
+            form.owner.down('button[action=discard]').setDisabled(true);
+        }
+    }
+});
--- a/app/view/form/Messung.js	Fri Mar 13 13:20:49 2015 +0100
+++ b/app/view/form/Messung.js	Fri Mar 13 15:11:12 2015 +0100
@@ -14,10 +14,10 @@
     alias: 'widget.messungform',
     requires: [
         'Lada.view.widget.Datenbasis',
+        'Lada.view.widget.base.CheckBox',
+        'Lada.view.widget.Messmethode',
         'Lada.view.widget.base.TextField',
         'Lada.view.widget.base.Datetime',
-        'Lada.view.widget.base.FieldSet',
-        'Lada.model.Messung'
     ],
 
     model: 'Lada.model.Messung',
@@ -30,9 +30,87 @@
     trackResetOnLoad: true,
 
     initComponent: function() {
+        var me = this;
         this.items = [{
             xtype: 'fieldset',
-            title: 'Allgemein'
+            title: 'Allgemein',
+            items: [{
+                border: 0,
+                margin: '0, 0, 10, 0',
+                layout: {
+                    type: 'table',
+                    columns: 2
+                },
+                dockedItems: [{
+                    xtype: 'toolbar',
+                    dock: 'bottom',
+                    border: '0, 1, 1, 1',
+                    style: {
+                        borderBottom: '1px solid #b5b8c8 !important',
+                        borderLeft: '1px solid #b5b8c8 !important',
+                        borderRight: '1px solid #b5b8c8 !important'
+                    },
+                    items: ['->', {
+                        text: 'Speichern',
+                        qtip: 'Daten speichern',
+                        icon: 'resources/img/dialog-ok-apply.png',
+                        action: 'save',
+                        disabled: true
+                    }, {
+                        text: 'Verwerfen',
+                        qtip: 'Ă„nderungen verwerfen',
+                        icon: 'resources/img/dialog-cancel.png',
+                        action: 'discard',
+                        disabled: true
+                    }]
+                }],
+                items: [{
+                    xtype: 'textfield',
+                    name: 'nebenprobenNr',
+                    maxLength: 10,
+                    margin: '0, 10, 5, 0',
+                    fieldLabel: 'Nebenprobennr.',
+                    width: 300,
+                    labelWidth: 100,
+                }, {
+                    xtype: 'messmethode',
+                    name: 'mmtId',
+                    margin: '0, 10, 5, 0',
+                    fieldLabel: 'Messmethode',
+                    width: 300,
+                    labelWidth: 100,
+                }, {
+                    xtype: 'datetime',
+                    name: 'messzeitpunkt',
+                    margin: '0, 10, 5, 0',
+                    fieldLabel: 'Messzeitpunkt',
+                    width: 300,
+                    labelWidth: 100,
+                }, {
+                    xtype: 'numberfield',
+                    allowDecimals: false,
+                    minValue: 0,
+                    name: 'messdauer',
+                    margin: '0, 10, 5, 0',
+                    fieldLabel: 'Messdauer',
+                    width: 300,
+                    labelWidth: 100,
+                }, {
+                    xtype: 'chkbox',
+                    name: 'fertig',
+                    margin: '0, 10, 5, 0',
+                    fieldLabel: 'Fertig',
+                    width: 300,
+                    labelWidth: 100,
+                }, {
+                    xtype: 'chkbox',
+                    name: 'geplant',
+                    margin: '0, 10, 5, 0',
+                    fieldLabel: 'Geplant',
+                    width: 300,
+                    labelWidth: 100,
+                }]
+            }]
         }];
         this.callParent(arguments);
     },
--- a/app/view/form/Probe.js	Fri Mar 13 13:20:49 2015 +0100
+++ b/app/view/form/Probe.js	Fri Mar 13 15:11:12 2015 +0100
@@ -106,35 +106,17 @@
                                 name: 'datenbasisId',
                                 fieldLabel: 'Datenbasis',
                                 labelWidth: 100,
-                                listeners: {
-                                    dirtychange: {
-                                        fn: this.updateOnChange,
-                                        scope: me
-                                    }
-                                }
                             }, {
                                 xtype: 'betriebsart',
                                 name: 'baId',
                                 fieldLabel: 'Betriebsart',
                                 labelWidth: 100,
-                                listeners: {
-                                    dirtychange: {
-                                        fn: this.updateOnChange,
-                                        scope: me
-                                    }
-                                }
                             }, {
                                 xtype: 'testdatensatz',
                                 name: 'test',
                                 fieldLabel: 'Testdatensatz',
                                 labelWidth: 100,
                                 allowBlank: false,
-                                listeners: {
-                                    dirtychange: {
-                                        fn: this.updateOnChange,
-                                        scope: me
-                                    }
-                                }
                             }, {
                                 xtype: 'probenart',
                                 editable: false,
@@ -142,24 +124,12 @@
                                 fieldLabel: 'Probenart',
                                 labelWidth: 100,
                                 allowBlank: false,
-                                listeners: {
-                                    dirtychange: {
-                                        fn: this.updateOnChange,
-                                        scope: me
-                                    }
-                                }
                             }, {
                                 xtype: 'numberfield',
                                 allowDecimals: false,
                                 name: 'probeNehmerId',
                                 fieldLabel: 'Probennehmer',
                                 labelWidth: 100,
-                                listeners: {
-                                    dirtychange: {
-                                        fn: this.updateOnChange,
-                                        scope: me
-                                    }
-                                }
                             }, {
                                 xtype: 'netzbetreiber',
                                 name: 'netzbetreiberId',
@@ -167,23 +137,11 @@
                                 fieldLabel: 'Netzbetreiber',
                                 labelWidth: 100,
                                 allowBlank: false,
-                                listeners: {
-                                    dirtychange: {
-                                        fn: this.updateOnChange,
-                                        scope: me
-                                    }
-                                }
                             }, {
                                 xtype: 'tfield',
                                 name: 'x11',
                                 fieldLabel: 'Datensatzerzeuger',
                                 labelWidth: 100,
-                                listeners: {
-                                    dirtychange: {
-                                        fn: this.updateOnChange,
-                                        scope: me
-                                    }
-                                }
                             }]
                         }]
                     }]
--- a/app/view/widget/Messmethode.js	Fri Mar 13 13:20:49 2015 +0100
+++ b/app/view/widget/Messmethode.js	Fri Mar 13 15:11:12 2015 +0100
@@ -22,7 +22,8 @@
     triggerAction: 'all',
     typeAhead: true,
     minChars: 0,
-
+    layout: 'hbox',
+    
     initComponent: function() {
         this.store = Ext.data.StoreManager.get('messmethoden');
         if (!this.store) {
--- a/app/view/widget/Testdatensatz.js	Fri Mar 13 13:20:49 2015 +0100
+++ b/app/view/widget/Testdatensatz.js	Fri Mar 13 15:11:12 2015 +0100
@@ -6,16 +6,7 @@
  * the documentation coming with IMIS-Labordaten-Application for details.
  */
 
-var testdatensatzStore = Ext.create('Ext.data.Store', {
-    fields: ['testdatensatzId', 'testdatensatz'],
-    data: [{
-        'testdatensatzId': true,
-        'testdatensatz': 'Ja'
-    }, {
-        'testdatensatzId': false,
-        'testdatensatz': 'Nein'
-    }]
-});
+
 
 /**
  * Combobox for Testdatensatz.
@@ -23,15 +14,23 @@
  */
 Ext.define('Lada.view.widget.Testdatensatz', {
     extend: 'Lada.view.widget.base.ComboBox',
-    editable: false,
     alias: 'widget.testdatensatz',
-    store: testdatensatzStore,
     queryMode: 'local',
     displayField: 'testdatensatz',
     valueField: 'testdatensatzId',
     emptyText: 'Testdatensatz?',
 
     initComponent: function() {
+        this.store = Ext.create('Ext.data.Store', {
+            fields: ['testdatensatzId', 'testdatensatz'],
+            data: [{
+                'testdatensatzId': true,
+                'testdatensatz': 'Ja'
+            }, {
+                'testdatensatzId': false,
+                'testdatensatz': 'Nein'
+            }]
+        });
         this.callParent(arguments);
     }
 });
--- a/app/view/window/MessungEdit.js	Fri Mar 13 13:20:49 2015 +0100
+++ b/app/view/window/MessungEdit.js	Fri Mar 13 15:11:12 2015 +0100
@@ -48,8 +48,9 @@
             autoScroll: true,
             items: [{
                 xtype: 'messungform',
+                margin: 5,
                 recordId: this.record.get('id')
-            }, {
+           /*}, {
                 xtype: 'fset',
                 name: 'messwerte',
                 title: 'Messwerte',
@@ -58,7 +59,7 @@
                 items: [{
                     xtype: 'messwertgrid',
                     recordId: this.record.get('id')
-                }]
+                }]*/
             }, {
                 xtype: 'fset',
                 name: 'messungstatus',
@@ -86,6 +87,7 @@
 
     initData: function() {
         this.clearMessages();
+        this.down('messungform').setRecord(this.record);
         Ext.ClassManager.get('Lada.model.Messung').load(this.record.get('id'), {
             failure: function(record) {
                 // TODO
@@ -99,8 +101,7 @@
                 }
             },
             scope: this
-        }
-        );
+        });
     },
 
     setMessages: function(errors, warnings) {

http://lada.wald.intevation.org