[Lada-commits] [PATCH] Fixed edit status. Only the last record is editable

Wald Commits scm-commit at wald.intevation.org
Thu Nov 12 17:38:55 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1447346337 -3600
# Node ID d4603049cd4231eb7bdf49f48940993ef56d28a5
# Parent  8fabf9a3fee7b73f551fd207c5b0bf120680c949
Fixed edit status. Only the last record is editable.

diff -r 8fabf9a3fee7 -r d4603049cd42 app/controller/grid/Status.js
--- a/app/controller/grid/Status.js	Thu Nov 12 16:15:37 2015 +0100
+++ b/app/controller/grid/Status.js	Thu Nov 12 17:38:57 2015 +0100
@@ -93,23 +93,17 @@
     toggleAllowedPermissions: function(context, record, index){
 
         //retrieve the readOnly parameters
-        var readonlyWin = context.view.up('window').record.get('readonly');
-        //var statusEdit = context.view.up('window').record.get('statusEdit');
+        var statusEdit = context.view.up('window').record.get('statusEdit');
 
-        var readonlyRec = record.get('readonly');
         var grid = context.view.up('grid');
 
         //retrieve the last record of the store
-        var lastRecord = context.getStore().last()
+        var lastRecord = context.getStore().last();
 
         //Check if edit is allowed
-        if (lastRecord == record &&
-            readonlyWin == false  &&
-            readonlyRec == false) {
-            grid.getPlugin('rowedit').enable()
-        }
-        else {
-            grid.getPlugin('rowedit').disable()
+        if (lastRecord != record ||
+            statusEdit === false) {
+            grid.getPlugin('rowedit').cancelEdit();
         }
     }
 
diff -r 8fabf9a3fee7 -r d4603049cd42 app/view/grid/Status.js
--- a/app/view/grid/Status.js	Thu Nov 12 16:15:37 2015 +0100
+++ b/app/view/grid/Status.js	Thu Nov 12 17:38:57 2015 +0100
@@ -38,20 +38,7 @@
             clicksToMoveEditor: 1,
             autoCancel: false,
             disabled: true,
-            pluginId: 'rowedit',
-            listeners:{
-                // Make row ineditable when readonly is set to true
-                // Normally this would belong into a controller an not the view.
-                // But the RowEditPlugin is not handled there.
-                beforeedit: function(e, o) {
-                var readonlywin = o.grid.up('window').record.get('readonly');
-                    var readonlygrid = o.record.get('readonly');
-                    if (readonlywin == true || readonlygrid == true || this.disabled)  {
-                        return false;
-                    }
-                    return true;
-                }
-            }
+            pluginId: 'rowedit'
         });
         this.plugins = [this.rowEditing];
 
@@ -172,16 +159,9 @@
     setReadOnly: function(b) {
         if (b == true){
             //Readonly
-            if (this.getPlugin('rowedit')){
-                this.getPlugin('rowedit').disable();
-            }
             this.down('button[action=add]').disable();
         }else{
             //Writable
-            if (this.getPlugin('rowedit')){
-                this.getPlugin('rowedit').enable();
-            }
-            //this.down('button[action=delete]').enable();
             this.down('button[action=add]').enable();
         }
     }


More information about the Lada-commits mailing list