changeset 698:9635f4e60b13

merged
author Dustin Demuth <dustin@intevation.de>
date Thu, 26 Mar 2015 17:29:00 +0100
parents 5b2cbc6bc39a (diff) c5b8896768a2 (current diff)
children 04f266eb2fd5
files app/model/Messung.js app/model/Messwert.js app/model/Ort.js app/model/Probe.js app/model/Status.js app/model/Zusatzwert.js
diffstat 21 files changed, 210 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/form/Location.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/form/Location.js	Thu Mar 26 17:29:00 2015 +0100
@@ -61,7 +61,15 @@
                 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
                 var json = response.request.scope.reader.jsonData;
                 if (json) {
-                    formPanel.setMessages(json.errors, json.warnings);
+                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
+                        formPanel.setMessages(json.errors, json.warnings);
+                    }
+
+                    if(json.message){
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('errmsgtitle')
+                            +' '+json.message,
+                            Lada.getApplication().bundle.getMsg(json.message));
+                    }
                 }
             }
         });
--- a/app/controller/form/Messung.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/form/Messung.js	Thu Mar 26 17:29:00 2015 +0100
@@ -57,11 +57,18 @@
                 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
                 var json = response.request.scope.reader.jsonData;
                 if (json) {
-                    formPanel.setMessages(json.errors, json.warnings);
+                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0) {
+                        formPanel.setMessages(json.errors, json.warnings);
+                    }
+
+                    if(json.message){
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('errmsgtitle')
+                            +' '+json.message,
+                            Lada.getApplication().bundle.getMsg(json.message));
+                    }
                 }
             }
         });
-        console.log('save');
     },
 
     discard: function(button) {
--- a/app/controller/form/Ort.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/form/Ort.js	Thu Mar 26 17:29:00 2015 +0100
@@ -52,7 +52,15 @@
                 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
                 var json = response.request.scope.reader.jsonData;
                 if (json) {
-                    formPanel.setMessages(json.errors, json.warnings);
+                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
+                        formPanel.setMessages(json.errors, json.warnings);
+                    }
+
+                    if(json.message){
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('errmsgtitle')
+                            +' '+json.message,
+                            Lada.getApplication().bundle.getMsg(json.message));
+                    }
                 }
             }
         });
--- a/app/controller/form/Probe.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/form/Probe.js	Thu Mar 26 17:29:00 2015 +0100
@@ -58,11 +58,18 @@
                 formPanel.getForm().loadRecord(rec);
                 var json = response.request.scope.reader.jsonData;
                 if (json) {
-                    formPanel.setMessages(json.errors, json.warnings);
+                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
+                        formPanel.setMessages(json.errors, json.warnings);
+                    }
+
+                    if(json.message){
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('errmsgtitle')
+                            +' '+json.message,
+                            Lada.getApplication().bundle.getMsg(json.message));
+                    }
                 }
             }
         });
-        console.log('save');
     },
 
     discard: function(button) {
--- a/app/controller/grid/MKommentar.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/grid/MKommentar.js	Thu Mar 26 17:29:00 2015 +0100
@@ -26,12 +26,19 @@
 
     edit: function(editor, context) {
         context.record.save({
-            success: function() {
+            success: function(record, response) {
                 context.grid.initData();
                 context.grid.up('window').initData();
             },
-            failure: function() {
-                // TODO
+            failure: function(record, response) {
+              var json = response.request.scope.reader.jsonData;
+              if (json) {
+                if (json.message){
+                    Ext.Msg.alert(Lada.getApplication().bundle.getMsg('errmsgtitle')
+                        +' '+json.message,
+                        Lada.getApplication().bundle.getMsg(json.message));
+                    }
+                }
             }
         });
     },
--- a/app/controller/grid/Messung.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/grid/Messung.js	Thu Mar 26 17:29:00 2015 +0100
@@ -31,7 +31,10 @@
     },
 
     editItem: function(grid, record) {
+        var probe = grid.up('window').record;
         var win = Ext.create('Lada.view.window.MessungEdit', {
+            parentWindow: grid.up('window'),
+            probe: probe,
             record: record,
             grid: grid
         });
--- a/app/controller/grid/Ort.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/grid/Ort.js	Thu Mar 26 17:29:00 2015 +0100
@@ -29,7 +29,10 @@
     },
 
     open: function(grid, record) {
+        var probe = grid.up('window').record;
         var win = Ext.create('Lada.view.window.OrtEdit', {
+            parentWindow: grid.up('window'),
+            probe: probe,
             record: record,
             grid: grid
         });
--- a/app/controller/grid/Probenzusatzwert.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/controller/grid/Probenzusatzwert.js	Thu Mar 26 17:29:00 2015 +0100
@@ -30,8 +30,17 @@
                 context.grid.store.reload();
                 context.grid.up('window').initData();
             },
-            failure: function() {
-                // TODO
+            failure: function(record, response) {
+                console.log(response);
+                console.log(record);
+                var json = response.request.scope.reader.jsonData;
+                if (json) {
+                    if (json.message){
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('errmsgtitle')
+                            +' '+json.message,
+                            Lada.getApplication().bundle.getMsg(json.message));
+                    }
+                }
             }
         });
     },
--- a/app/model/Messung.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/model/Messung.js	Thu Mar 26 17:29:00 2015 +0100
@@ -18,6 +18,9 @@
         name: 'owner',
         type: 'boolean'
     }, {
+        name: 'readonly',
+        type: 'boolean'
+    }, {
         name: 'probeId'
     }, {
         name: 'mmtId'
@@ -52,6 +55,8 @@
         type: 'boolean'
     }, {
         name: 'messungsIdAlt'
+    }, {
+        name: 'treeModified'
     }],
 
     idProperty: 'id',
--- a/app/model/Messwert.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/model/Messwert.js	Thu Mar 26 17:29:00 2015 +0100
@@ -47,6 +47,8 @@
             return new Date(v);
         },
         defaultValue: new Date()
+    }, {
+        name: 'treeModified'
     }],
 
     idProperty: 'id',
--- a/app/model/Ort.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/model/Ort.js	Thu Mar 26 17:29:00 2015 +0100
@@ -35,6 +35,8 @@
             return new Date(v);
         },
         defaultValue: new Date()
+    }, {
+        name: 'treeModified'
     }],
 
     idProperty: 'id',
--- a/app/model/Probe.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/model/Probe.js	Thu Mar 26 17:29:00 2015 +0100
@@ -17,7 +17,8 @@
         name: 'id'
     }, {
         name: 'owner',
-        type: 'boolean'
+        type: 'boolean',
+        persist: false
     }, {
         name: 'probeIdAlt'
     }, {
@@ -116,8 +117,10 @@
         defaultValue: new Date()
     }, {
         name: 'readonly',
-        type: 'bool',
+        type: 'boolean',
         persist: false
+    }, {
+        name: 'treeModified'
     }],
 
     idProperty: 'id',
--- a/app/model/Status.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/model/Status.js	Thu Mar 26 17:29:00 2015 +0100
@@ -35,6 +35,8 @@
         defaultValue: new Date()
     }, {
         name: 'skommentar'
+    }, {
+        name: 'treeModified'
     }],
 
     idProperty: 'id',
--- a/app/model/Zusatzwert.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/model/Zusatzwert.js	Thu Mar 26 17:29:00 2015 +0100
@@ -40,6 +40,8 @@
             return new Date(v);
         },
         defaultValue: new Date()
+    }, {
+        name: 'treeModified'
     }],
 
     idProperty: 'id',
--- a/app/view/Viewport.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/view/Viewport.js	Thu Mar 26 17:29:00 2015 +0100
@@ -44,7 +44,20 @@
                             items: [{
                                 text: 'About',
                                 action: 'about'
-                            }]
+                            }, {
+                                text: 'Zeit',
+                                handler: function(){
+                                    thetime = new Date();
+                                    Ext.Msg.alert("Zeit", "Laut Ihrer lokalen Systemuhr ist es\n"+
+                                            thetime.toString() + "\n\n" +
+                                          "Das entspricht der Serverzeit:\n" +
+                                            thetime.toUTCString() + "\n\n" +
+                                          "Alle Messwerte werden in GMT/UTC auf dem Server gespeichert. " + 
+                                          "Ihr Webbrowser rechnet diese automatisch um."
+                                         );
+                                }
+                            }
+                            ]
                         }
                     }, '->', {
                         xtype: 'box',
--- a/app/view/form/Messung.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/view/form/Messung.js	Thu Mar 26 17:29:00 2015 +0100
@@ -130,7 +130,12 @@
         // TODO this is a stub
     },
 
-    setReadonly: function() {
-        // TODO this is a stub
+    setReadOnly: function(value) {
+        this.down('textfield[name=nebenprobenNr]').setReadOnly(value);
+        this.down('messmethode[name=mmtId]').setReadOnly(value);
+        this.down('datetime[name=messzeitpunkt]').setReadOnly(value);
+        this.down('numberfield[name=messdauer]').setReadOnly(value);
+        this.down('chkbox[name=fertig]').setReadOnly(value);
+        this.down('chkbox[name=geplant]').setReadOnly(value);
     }
 });
--- a/app/view/window/MessungEdit.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/view/window/MessungEdit.js	Thu Mar 26 17:29:00 2015 +0100
@@ -26,6 +26,9 @@
     autoscroll: true,
     layout: 'fit',
     constrain: true,
+
+    probe: null,
+    parentWindow: null,
     record: null,
     grid: null,
 
@@ -35,6 +38,11 @@
             this.callParent(arguments);
             return;
         }
+        if (this.probe === null) {
+            Ext.Msg.alert('Zu der Messung existiert keine Probe!');
+            this.callParent(arguments);
+            return;
+        }
         this.title = 'Messung ' + this.record.get('nebenprobenNr');
         this.buttons = [{
             text: 'Schließen',
@@ -88,14 +96,40 @@
 
     initData: function() {
         this.clearMessages();
-        this.down('messungform').setRecord(this.record);
+        var that = this;
         Ext.ClassManager.get('Lada.model.Messung').load(this.record.get('id'), {
-            failure: function(record) {
+            failure: function(record, response) {
                 // TODO
+                console.log("An unhandled Failure occured. See following Response and Record");
+                console.log(response);
                 console.log(record);
             },
             success: function(record, response) {
+                var me = this;
+                if (this.probe.get('treeModified') < record.get('treeModified')) {
+                    Ext.Msg.show({
+                        title: 'Probe nicht aktuell!',
+                        msg: 'Die zugehörige Probe wurde verändert.\n'+
+                            'Möchten Sie zu der Probe zurückkehren und neu laden?\n'+
+                            'Ohne das erneute Laden der Probe wird das Speichern'+
+                            ' der Messung nicht möglich sein.',
+                        buttons: Ext.Msg.OKCANCEL,
+                        icon: Ext.Msg.WARNING,
+                        closable: false,
+                        fn: function(button) {
+                            if (button === 'ok') {
+                                me.close();
+                                me.parentWindow.initData();
+                            }
+                            else {
+                                me.record.set('treeModified', me.probe.get('treeModified'));
+                                that.disableForm();
+                            }
+                        }
+                    });
+                }
                 this.down('messungform').setRecord(record);
+                this.record = record;
                 var json = Ext.decode(response.response.responseText);
                 if (json) {
                     this.setMessages(json.errors, json.warnings);
@@ -103,12 +137,20 @@
             },
             scope: this
         });
-
         if (this.record.get('readonly') == true){
-            this.down('messungform').setReadOnly(true);
-            this.disableChildren();
+            this.disableForm();
         }
-     },
+    },
+
+    disableForm: function(){
+        this.down('messungform').setReadOnly(true);
+        this.disableChildren();
+    },
+
+    enableForm: function(){
+        this.down('messungform').setReadOnly(false);
+        this.enableChildren();
+    },
 
     disableChildren: function(){
             this.down('fset[name=messwerte]').down('messwertgrid').setReadOnly(true);
--- a/app/view/window/OrtEdit.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/view/window/OrtEdit.js	Thu Mar 26 17:29:00 2015 +0100
@@ -25,6 +25,8 @@
     layout: 'border',
     constrain: true,
 
+    parentWindow: null,
+    probe: null,
     record: null,
     grid: null,
 
@@ -34,6 +36,11 @@
             this.callParent(arguments);
             return;
         }
+        if (this.probe === null) {
+            Ext.Msg.alert('Zu dem Ort existiert keine Probe!');
+            this.callParent(arguments);
+            return;
+        }
         this.title = 'Ort';
         this.buttons = [{
             text: 'Schließen',
@@ -83,7 +90,35 @@
     },
 
     initData: function() {
-        this.down('ortform').setRecord(this.record);
+        Ext.ClassManager.get('Lada.model.Ort').load(this.record.get('id'), {
+            failure: function(record, action) {
+                // TODO
+            },
+            success: function(record, response) {
+                var me = this;
+                if (this.probe.get('treeModified') < record.get('treeModified')) {
+                    Ext.Msg.show({
+                        title: 'Probe nicht aktuell!',
+                        msg: 'Die zugehörige Probe wurde verändert.\nMöchten Sie zu der Probe zurückkehren und neu laden?\nOhne das erneute Laden der Probe wird das Speichern des Ortes nicht möglich sein.',
+                        buttons: Ext.Msg.OKCANCEL,
+                        icon: Ext.Msg.WARNING,
+                        closable: false,
+                        fn: function(button) {
+                            if (button === 'ok') {
+                                me.close();
+                                me.parentWindow.initData();
+                            }
+                            else {
+                                me.record.set('treeModified', me.probe.get('treeModified'));
+                            }
+                        }
+                    });
+                }
+                this.down('ortform').setRecord(record);
+                this.record = record;
+            },
+            scope: this
+        });
         Ext.ClassManager.get('Lada.model.Location').load(this.record.get('ort'), {
             failure: function(record, action) {
                 // TODO
--- a/app/view/window/ProbeEdit.js	Wed Mar 25 16:52:45 2015 +0100
+++ b/app/view/window/ProbeEdit.js	Thu Mar 26 17:29:00 2015 +0100
@@ -30,6 +30,7 @@
 
     record: null,
 
+
     initComponent: function() {
         if (this.record === null) {
             Ext.Msg.alert('Keine valide Probe ausgewählt!');
@@ -111,9 +112,13 @@
         Ext.ClassManager.get('Lada.model.Probe').load(this.record.get('id'), {
             failure: function(record, action) {
                 // TODO
-            },
+                console.log("An unhandled Failure occured. See following Response and Record");
+                console.log(response);
+                console.log(record);
+             },
             success: function(record, response) {
                 this.down('probeform').setRecord(record);
+                this.record = record;
                 var json = Ext.decode(response.response.responseText);
                 if (json) {
                     this.setMessages(json.errors, json.warnings);
@@ -121,9 +126,20 @@
             },
             scope: this
         });
+
+        // If the Probe is ReadOnly, disable Inputfields and grids
         if (this.record.get('readonly') == true){
             this.down('probeform').setReadOnly(true);
             this.disableChildren();
+
+            //The Owner of a Probe is always allowed to add a Messung.
+            // ToDo ist it required to check if a Status exists?
+            // ToDo this doesn't work here because the owner is unknown when this code
+            //   is executed.
+            if (this.record.get('owner') == true){
+                //allow to add Messungen
+                this.down('fset[name=messungen]').down('messunggrid').down('button[name=add]').enable();
+            }
         }
     },
 
--- a/resources/i18n/Lada.properties	Wed Mar 25 16:52:45 2015 +0100
+++ b/resources/i18n/Lada.properties	Thu Mar 26 17:29:00 2015 +0100
@@ -16,6 +16,7 @@
 652: Geo: Werte passen nicht zusammen
 661: Date: Datum liegt in der Zukunft
 662: Date: Anfang nach Ende
+697: Der zugrundeliegende Datensatz wurde in der Zwischenzeit verändert
 699: Keine Berechtigung
 
 ! Import errors
--- a/resources/i18n/Lada_de-DE.properties	Wed Mar 25 16:52:45 2015 +0100
+++ b/resources/i18n/Lada_de-DE.properties	Thu Mar 26 17:29:00 2015 +0100
@@ -16,6 +16,7 @@
 652: Werte passen nicht zusammen
 661: Datum liegt in der Zukunft
 662: Anfang nach Ende
+697: Der zugrundeliegende Datensatz wurde in der Zwischenzeit verändert
 698: Kein Zugriff
 699: Keine Berechtigung
 
@@ -31,3 +32,8 @@
 ##
 entnahmeOrt: Entnahmeort
 test: Testdatensatz
+
+##
+# Msg:
+##
+errmsgtitle: Fehler

http://lada.wald.intevation.org