[Lada-commits] [PATCH 1 of 4] Handle edit and delete status for stammdaten objects

Wald Commits scm-commit at wald.intevation.org
Wed Apr 13 18:41:58 CEST 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1460548539 -7200
# Node ID fe5fb960da9d013693fac388d3ea9b6de6c8d27b
# Parent  2a5d42045c63dddbdfaac2277a5c2f31b7674849
Handle edit and delete status for stammdaten objects.

diff -r 2a5d42045c63 -r fe5fb960da9d app/controller/grid/Datensatzerzeuger.js
--- 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;
         }
diff -r 2a5d42045c63 -r fe5fb960da9d app/controller/grid/MessprogrammKategorie.js
--- 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 @@
         }
     }
 });
-
-
diff -r 2a5d42045c63 -r fe5fb960da9d app/controller/grid/Probenehmer.js
--- 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;
         }


More information about the Lada-commits mailing list