diff app/view/window/OrtEdit.js @ 690:e88381fb3bdb

Use treeModiefied timestamp to determine if working with 'old' objects.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 25 Mar 2015 16:46:48 +0100
parents 6a6d1b02a1a3
children 6f6d2df00130
line wrap: on
line diff
--- a/app/view/window/OrtEdit.js	Wed Mar 25 16:45:29 2015 +0100
+++ b/app/view/window/OrtEdit.js	Wed Mar 25 16:46:48 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

http://lada.wald.intevation.org