[Lada-commits] [PATCH 2 of 2] Use user 'funktionen' attribute to set read/write status for stammdaten

Wald Commits scm-commit at wald.intevation.org
Fri Feb 19 13:59:31 CET 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1455886764 -3600
# Node ID 77e22ad5cc84d985d64722a5bca9960e708bce39
# Parent  1251094e750050d0afee4245ed86078afdfc02c9
Use user 'funktionen' attribute to set read/write status for stammdaten.

diff -r 1251094e7500 -r 77e22ad5cc84 app.js
--- a/app.js	Fri Feb 19 13:58:43 2016 +0100
+++ b/app.js	Fri Feb 19 13:59:24 2016 +0100
@@ -113,6 +113,7 @@
         Lada.userroles = json.data.roles;
         Lada.logintime = json.data.servertime;
         Lada.mst = json.data.mst; //Store Messstellen this user may select
+        Lada.funktionen = json.data.funktionen;
         //Lada.serverVersion
         this.getServerVersion();
 
diff -r 1251094e7500 -r 77e22ad5cc84 app/controller/grid/Datensatzerzeuger.js
--- a/app/controller/grid/Datensatzerzeuger.js	Fri Feb 19 13:58:43 2016 +0100
+++ b/app/controller/grid/Datensatzerzeuger.js	Fri Feb 19 13:59:24 2016 +0100
@@ -21,8 +21,9 @@
             'datensatzerzeugergrid': {
                 edit: this.gridSave,
                 canceledit: this.cancelEdit,
-                select: this.activateButtons,
-                deselect: this.deactivateButtons
+                select: this.buttonToggle,
+                deselect: this.buttonToggle,
+                itemdblclick: this.edit
             },
             'datensatzerzeugergrid button[action=add]': {
                 click: this.add
@@ -33,6 +34,11 @@
         });
     },
 
+    edit: function() {
+        var grid = Ext.ComponentQuery.query('datensatzerzeugergrid')[0];
+        grid.down('button[action=delete]').disable();
+    },
+
     /**
      * This function is called when the grids roweditor saves
      * the record.
@@ -69,8 +75,11 @@
         if (!context.record.get('id') ||
             context.record.get('id') === '') {
             editor.getCmp().store.remove(context.record);
+            this.buttonToggle();
         }
-        context.grid.getSelectionModel().deselect(context.record);
+        else {
+            this.buttonToggle(context.grid.getSelectionModel(), context.record);
+        }
     },
 
     /**
@@ -122,42 +131,30 @@
         });
         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('datensatzerzeugergrid')[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);
-            }
         }
     }
 });
-
diff -r 1251094e7500 -r 77e22ad5cc84 app/controller/grid/MessprogrammKategorie.js
--- 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);
-            }
         }
-    },
+    }
 });
 
 
diff -r 1251094e7500 -r 77e22ad5cc84 app/controller/grid/Probenehmer.js
--- a/app/controller/grid/Probenehmer.js	Fri Feb 19 13:58:43 2016 +0100
+++ b/app/controller/grid/Probenehmer.js	Fri Feb 19 13:59:24 2016 +0100
@@ -21,8 +21,9 @@
             'probenehmergrid': {
                 edit: this.gridSave,
                 canceledit: this.cancelEdit,
-                select: this.activateButtons,
-                deselect: this.deactivateButtons
+                select: this.buttonToggle,
+                deselect: this.buttonToggle,
+                itemdblclick: this.edit
             },
             'probenehmergrid button[action=add]': {
                 click: this.add
@@ -33,6 +34,11 @@
         });
     },
 
+    edit: function() {
+        var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
+        grid.down('button[action=delete]').disable();
+    },
+
     /**
      * This function is called when the grids roweditor saves
      * the record.
@@ -69,8 +75,11 @@
         if (!context.record.get('id') ||
             context.record.get('id') === '') {
             editor.getCmp().store.remove(context.record);
+            this.buttonToggle();
         }
-        context.grid.getSelectionModel().deselect(context.record);
+        else {
+            this.buttonToggle(context.grid.getSelectionModel(), context.record);
+        }
     },
 
     /**
@@ -121,42 +130,30 @@
         });
         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('probenehmergrid')[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);
-            }
         }
-    },
+    }
 });
-
diff -r 1251094e7500 -r 77e22ad5cc84 app/view/grid/DatensatzErzeuger.js
--- a/app/view/grid/DatensatzErzeuger.js	Fri Feb 19 13:58:43 2016 +0100
+++ b/app/view/grid/DatensatzErzeuger.js	Fri Feb 19 13:59:24 2016 +0100
@@ -29,15 +29,15 @@
     initComponent: function() {
         var i18n = Lada.getApplication().bundle;
         this.emptyText = i18n.getMsg('de.emptyGrid');
-
-        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
-            clicksToMoveEditor: 1,
-            autoCancel: false,
-            disabled: false,
-            pluginId: 'rowedit'
-        });
-        this.plugins = [this.rowEditing];
-
+        if (Ext.Array.contains(Lada.funktionen, 4)) {
+            this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+                clicksToMoveEditor: 1,
+                autoCancel: false,
+                disabled: false,
+                pluginId: 'rowedit'
+            });
+            this.plugins = [this.rowEditing];
+        }
         // TODO: Which docked Items are required?
         this.dockedItems = [{
             xtype: 'toolbar',
@@ -138,13 +138,15 @@
     /**
      * This sets the Store of this Grid
      */
-    setStore: function(store){
+    setStore: function(store) {
         var i18n = Lada.getApplication().bundle;
+        if (Ext.Array.contains(Lada.funktionen, 4)) {
+            this.down('button[action=add]').enable();
+        }
 
         if (store) {
             this.removeDocked(Ext.getCmp('ptbar'), true);
             this.reconfigure(store);
-            this.down('button[action=add]').enable();
             this.addDocked([{
                 xtype: 'pagingtoolbar',
                 id: 'ptbar',
diff -r 1251094e7500 -r 77e22ad5cc84 app/view/grid/MessprogrammKategorie.js
--- a/app/view/grid/MessprogrammKategorie.js	Fri Feb 19 13:58:43 2016 +0100
+++ b/app/view/grid/MessprogrammKategorie.js	Fri Feb 19 13:59:24 2016 +0100
@@ -30,13 +30,15 @@
         var i18n = Lada.getApplication().bundle;
         this.emptyText = i18n.getMsg('mk.emptyGrid');
 
-        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
-            clicksToMoveEditor: 1,
-            autoCancel: false,
-            disabled: false,
-            pluginId: 'rowedit'
-        });
-        this.plugins = [this.rowEditing];
+        if (Ext.Array.contains(Lada.funktionen, 4)) {
+            this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+                clicksToMoveEditor: 1,
+                autoCancel: false,
+                disabled: false,
+                pluginId: 'rowedit'
+            });
+            this.plugins = [this.rowEditing];
+        }
 
         // TODO: Which docked Items are required?
         this.dockedItems = [{
@@ -115,8 +117,11 @@
     /**
      * This sets the Store of this Grid
      */
-    setStore: function(store){
+    setStore: function(store) {
         var i18n = Lada.getApplication().bundle;
+        if (Ext.Array.contains(Lada.funktionen, 4)) {
+            this.down('button[action=add]').enable();
+        }
 
         this.removeDocked(Ext.getCmp('ptbar'), true);
         this.reconfigure(store);
diff -r 1251094e7500 -r 77e22ad5cc84 app/view/grid/Probenehmer.js
--- a/app/view/grid/Probenehmer.js	Fri Feb 19 13:58:43 2016 +0100
+++ b/app/view/grid/Probenehmer.js	Fri Feb 19 13:59:24 2016 +0100
@@ -30,13 +30,15 @@
         var i18n = Lada.getApplication().bundle;
         this.emptyText = i18n.getMsg('pn.emptyGrid');
 
-        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
-            clicksToMoveEditor: 1,
-            autoCancel: false,
-            disabled: false,
-            pluginId: 'rowedit'
-        });
-        this.plugins = [this.rowEditing];
+        if (Ext.Array.contains(Lada.funktionen, 4)) {
+            this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+                clicksToMoveEditor: 1,
+                autoCancel: false,
+                disabled: false,
+                pluginId: 'rowedit'
+            });
+            this.plugins = [this.rowEditing];
+        }
 
         // TODO: Which docked Items are required?
         this.dockedItems = [{
@@ -167,13 +169,15 @@
     /**
      * This sets the Store of this Grid
      */
-    setStore: function(store){
+    setStore: function(store) {
         var i18n = Lada.getApplication().bundle;
+        if (Ext.Array.contains(Lada.funktionen, 4)) {
+            this.down('button[action=add]').enable();
+        }
 
         if (store) {
             this.removeDocked(Ext.getCmp('ptbar'), true);
             this.reconfigure(store);
-            this.down('button[action=add]').enable();
             this.addDocked([{
                 xtype: 'pagingtoolbar',
                 id: 'ptbar',


More information about the Lada-commits mailing list