diff app/controller/grid/Datensatzerzeuger.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 fa422d69940c
children 1c86a259c2ac
line wrap: on
line diff
--- a/app/controller/grid/Datensatzerzeuger.js	Fri Apr 08 19:33:46 2016 +0200
+++ b/app/controller/grid/Datensatzerzeuger.js	Wed Apr 13 13:55:39 2016 +0200
@@ -21,7 +21,7 @@
             'datensatzerzeugergrid': {
                 edit: this.gridSave,
                 canceledit: this.cancelEdit,
-                select: this.buttonToggle,
+                select: this.select,
                 deselect: this.buttonToggle,
                 itemdblclick: this.edit
             },
@@ -34,8 +34,27 @@
         });
     },
 
+    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('datensatzerzeugergrid')[0];
+            grid.rowEditing.cancelEdit();
+            return;
+        }
+    },
+
     edit: function() {
         var grid = Ext.ComponentQuery.query('datensatzerzeugergrid')[0];
+        if (!Ext.Array.contains(Lada.netzbetreiber,
+            record.get('netzbetreiberId'))) {
+            grid.rowEditing.cancelEdit();
+            return;
+        }
         grid.down('button[action=delete]').disable();
     },
 
@@ -140,7 +159,9 @@
             return;
         }
         var grid = Ext.ComponentQuery.query('datensatzerzeugergrid')[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