diff app/controller/grid/Probenehmer.js @ 1078:fe5fb960da9d

Handle edit and delete status for stammdaten objects.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 13 Apr 2016 13:55:39 +0200
parents e79403c3482e
children 5e9a674d7bb4
line wrap: on
line diff
--- a/app/controller/grid/Probenehmer.js	Fri Apr 08 19:33:46 2016 +0200
+++ b/app/controller/grid/Probenehmer.js	Wed Apr 13 13:55:39 2016 +0200
@@ -21,7 +21,7 @@
             'probenehmergrid': {
                 edit: this.gridSave,
                 canceledit: this.cancelEdit,
-                select: this.buttonToggle,
+                select: this.select,
                 deselect: this.buttonToggle,
                 itemdblclick: this.edit
             },
@@ -34,8 +34,27 @@
         });
     },
 
-    edit: function() {
+    select: function(rowModel, record) {
+        this.checkEdit(rowModel, record);
+        this.buttonToggle(rowModel, record);
+    },
+
+    checkEdit: function(rowModel, record) {
+        if (!Ext.Array.contains(Lada.netzbetreiber,
+            record.get('netzbetreiberId'))) {
+            var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
+            grid.rowEditing.cancelEdit();
+            return;
+        }
+    },
+
+    edit: function (gridView, record) {
         var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
+        if (!Ext.Array.contains(Lada.netzbetreiber,
+            record.get('netzbetreiberId'))) {
+            grid.rowEditing.cancelEdit();
+            return;
+        }
         grid.down('button[action=delete]').disable();
     },
 
@@ -143,7 +162,9 @@
             return;
         }
         var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
-        if (!record) {
+        if (!record ||
+            !Ext.Array.contains(Lada.netzbetreiber,
+            record.get('netzbetreiberId'))) {
             grid.down('button[action=delete]').disable();
             return;
         }

http://lada.wald.intevation.org