changeset 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 2a5d42045c63
children 1c86a259c2ac
files app/controller/grid/Datensatzerzeuger.js app/controller/grid/MessprogrammKategorie.js app/controller/grid/Probenehmer.js
diffstat 3 files changed, 70 insertions(+), 9 deletions(-) [+]
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;
         }
--- a/app/controller/grid/MessprogrammKategorie.js	Fri Apr 08 19:33:46 2016 +0200
+++ b/app/controller/grid/MessprogrammKategorie.js	Wed Apr 13 13:55:39 2016 +0200
@@ -21,7 +21,7 @@
             'messprogrammkategoriegrid': {
                 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('messprogrammkategoriegrid')[0];
+            grid.rowEditing.cancelEdit();
+            return;
+        }
+    },
+
     edit: function() {
         var grid = Ext.ComponentQuery.query('messprogrammkategoriegrid')[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('messprogrammkategoriegrid')[0];
-        if (!record) {
+        if (!record ||
+            !Ext.Array.contains(Lada.netzbetreiber,
+            record.get('netzbetreiberId'))) {
             grid.down('button[action=delete]').disable();
             return;
         }
@@ -162,5 +183,3 @@
         }
     }
 });
-
-
--- 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