diff app/controller/grid/Messung.js @ 1111:a73726bba79c

Use custom row expander in probe list grid to display messung grid.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 17 May 2016 17:12:07 +0200
parents 6a6f2c6fe8ee
children 0a032c98c3a6
line wrap: on
line diff
--- a/app/controller/grid/Messung.js	Tue May 17 17:10:39 2016 +0200
+++ b/app/controller/grid/Messung.js	Tue May 17 17:12:07 2016 +0200
@@ -39,30 +39,68 @@
      * Window.
      */
     editItem: function(grid, record) {
-        var probe = grid.up('window').record;
-        /* Only open a new Window when:
-           statusEdit = True
-           -or-
-           the value of status is not 0
-           -or-
-           the owner = True
+        // we have a window with a probe record!
+        if (grid.up('window')) {
+            var probe = grid.up('window').record;
+            /* Only open a new Window when:
+               statusEdit = True
+               -or-
+               the value of status is not 0
+               -or-
+               the owner = True
 
-           the statusWert attribute is not present in the original data.
-           it is appended, when the value and name of the status were
-           determined.
-        */
-        if (record.get('statusEdit')
-            || record.get('statusWert') > 0
-            || record.get('owner')) {
-            var win = Ext.create('Lada.view.window.MessungEdit', {
-                parentWindow: grid.up('window'),
-                probe: probe,
-                record: record,
-                grid: grid
-            });
-            win.show();
-            win.initData();
+               the statusWert attribute is not present in the original data.
+               it is appended, when the value and name of the status were
+               determined.
+            */
+            if (record.get('statusEdit')
+                || record.get('statusWert') > 0
+                || record.get('owner')) {
+                var win = Ext.create('Lada.view.window.MessungEdit', {
+                    parentWindow: grid.up('window'),
+                    probe: probe,
+                    record: record,
+                    grid: grid
+                });
+                win.show();
+                win.initData();
+            }
+            return;
         }
+        var probeRecord = Ext.create('Lada.model.ProbeList');
+        probeRecord.setId(record.get('probeId'));
+        probeRecord.set('owner', record.get('owner'));
+        probeRecord.set('readonly', record.get('readonly'));
+
+        var probeWin = Ext.create('Lada.view.window.ProbeEdit', {
+            record: probeRecord,
+            style: 'z-index: -1;' //Fixes an Issue where windows could not be created in IE8
+        });
+
+        probeWin.setPosition(30);
+        probeWin.show();
+        probeWin.initData();
+
+        Ext.ClassManager.get('Lada.model.Probe').load(record.get('probeId'), {
+            failure: function(record, action) {
+                me.setLoading(false);
+                // TODO
+                console.log('An unhandled Failure occured. See following Response and Record');
+                console.log(action);
+                console.log(record);
+            },
+            success: function(precord, response) {
+                var messungWin = Ext.create('Lada.view.window.MessungEdit', {
+                    parentWindow: grid.up('window'),
+                    probe: precord,
+                    record: record,
+                    grid: grid
+                });
+                messungWin.show();
+                messungWin.setPosition(window.innerWidth - 30 - messungWin.width);
+                messungWin.initData();
+            }
+        });
     },
 
     /**

http://lada.wald.intevation.org