diff app/controller/grid/MessprogrammKategorie.js @ 1039:77e22ad5cc84

Use user 'funktionen' attribute to set read/write status for stammdaten.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 19 Feb 2016 13:59:24 +0100
parents 15d8c64049d1
children fa422d69940c
line wrap: on
line diff
--- a/app/controller/grid/MessprogrammKategorie.js	Fri Feb 19 13:58:43 2016 +0100
+++ b/app/controller/grid/MessprogrammKategorie.js	Fri Feb 19 13:59:24 2016 +0100
@@ -21,8 +21,9 @@
             'messprogrammkategoriegrid': {
                 edit: this.gridSave,
                 canceledit: this.cancelEdit,
-                select: this.activateButtons,
-                deselect: this.deactivateButtons
+                select: this.buttonToggle,
+                deselect: this.buttonToggle,
+                itemdblclick: this.edit
             },
             'messprogrammkategoriegrid button[action=add]': {
                 click: this.add
@@ -33,6 +34,11 @@
         });
     },
 
+    edit: function() {
+        var grid = Ext.ComponentQuery.query('messprogrammkategoriegrid')[0];
+        grid.down('button[action=delete]').disable();
+    },
+
     /**
      * This function is called when the grids roweditor saves
      * the record.
@@ -121,43 +127,32 @@
         });
         grid.down('button[action=delete]').disable();
     },
-    /**
-     * Toggles the buttons in the toolbar
-     **/
-    activateButtons: function(rowModel, record) {
-        var grid = rowModel.view.up('grid');
-        this.buttonToggle(true, grid);
-    },
-
-    /**
-     * Toggles the buttons in the toolbar
-     **/
-    deactivateButtons: function(rowModel, record) {
-        var grid = rowModel.view.up('grid');
-        // Only disable buttons when nothing is selected
-        if (rowModel.selected.items == 0) {
-            this.buttonToggle(false, grid);
-        }
-    },
 
     /**
      * Enables/Disables a set of buttons
      **/
-    buttonToggle: function(enabled, grid) {
-        if (!enabled) {
+    buttonToggle: function(rowModel, record) {
+        if (!Ext.Array.contains(Lada.funktionen, 4)) {
+            return;
+        }
+        var grid = Ext.ComponentQuery.query('messprogrammkategoriegrid')[0];
+        if (!record) {
+            grid.down('button[action=delete]').disable();
+        }
+        if (record.get('readonly') ||
+            rowModel.selected.items.length === 0) {
             grid.down('button[action=delete]').disable();
         }
         else {
-            if (!grid.getPlugin('rowedit').editing) {
+            if (grid.getPlugin('rowedit').editing) {
             //only enable buttons, when grid is not beeing edited
+                grid.down('button[action=delete]').disable();
+            }
+            else {
                 grid.down('button[action=delete]').enable();
             }
-            //else turn them off again!
-            else {
-                this.buttonToggle(false, grid);
-            }
         }
-    },
+    }
 });
 
 

http://lada.wald.intevation.org