changeset 684:69cb367c0a63

When a Probeform is dirty, all child-grids are made readonly (Row Editing is not disbled correctly). When a Probe is read-only all Child-grid buttons are disabled. When a Probe is ReadOnly probeform is also readonly.
author Dustin Demuth <dustin@intevation.de>
date Wed, 25 Mar 2015 15:04:45 +0100
parents 612f4f933083
children 0391425689ed
files app/view/form/Probe.js app/view/grid/MKommentar.js app/view/grid/Messung.js app/view/grid/Messwert.js app/view/grid/Ort.js app/view/grid/PKommentar.js app/view/grid/Probenzusatzwert.js app/view/grid/Status.js app/view/window/ProbeEdit.js
diffstat 9 files changed, 144 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/app/view/form/Probe.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/form/Probe.js	Wed Mar 25 15:04:45 2015 +0100
@@ -35,7 +35,6 @@
     recordId: null,
 
     trackResetOnLoad: true,
-    readonly: false,
 
     initComponent: function() {
         var me = this;
@@ -288,10 +287,6 @@
             }]
         }];
         this.callParent(arguments);
-
-        if (this.readonly){
-            this.setReadOnly(true);
-        }
     },
 
     setRecord: function(record) {
--- a/app/view/grid/MKommentar.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/grid/MKommentar.js	Wed Mar 25 15:04:45 2015 +0100
@@ -26,6 +26,7 @@
         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false,
+            pluginId: 'rowedit',
             listeners:{
                 // Make row ineditable when readonly is set to true
                 // Normally this would belong into a controller an not the view.
@@ -106,5 +107,23 @@
                 messungsId: this.recordId
             }
         });
+    },
+
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').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();
+        }
     }
 });
--- a/app/view/grid/Messung.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/grid/Messung.js	Wed Mar 25 15:04:45 2015 +0100
@@ -195,5 +195,23 @@
         if (Ext.fly(opts.divId)) {
             Ext.fly(opts.divId).update(value);
         }
+    },
+
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').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();
+        }
     }
 });
--- a/app/view/grid/Messwert.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/grid/Messwert.js	Wed Mar 25 15:04:45 2015 +0100
@@ -32,6 +32,7 @@
         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false,
+            pluginId: 'rowedit',
             listeners:{
                 // Make row ineditable when readonly is set to true
                 // Normally this would belong into a controller an not the view.
@@ -163,5 +164,18 @@
                 messungsId: this.recordId
             }
         });
+    },
+
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').disable();
+            this.down('button[action=add]').disable();
+        }else{
+            //Writable
+        }
     }
 });
--- a/app/view/grid/Ort.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/grid/Ort.js	Wed Mar 25 15:04:45 2015 +0100
@@ -118,10 +118,21 @@
         });
     },
 
-
-    setReadOnly: function() {
-        this.getPlugin('rowedit').disable();
-        this.down('button[action=add]').disable();
-        this.down('button[action=delete]').disable();
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').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();
+        }
     }
 });
--- a/app/view/grid/PKommentar.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/grid/PKommentar.js	Wed Mar 25 15:04:45 2015 +0100
@@ -31,6 +31,7 @@
         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false,
+            pluginId: 'rowedit',
             listeners:{
                 // Make row ineditable when readonly is set to true
                 // Normally this would belong into a controller an not the view.
@@ -109,5 +110,23 @@
                 probeId: this.recordId
             }
         });
+    },
+
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').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();
+        }
     }
 });
--- a/app/view/grid/Probenzusatzwert.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/grid/Probenzusatzwert.js	Wed Mar 25 15:04:45 2015 +0100
@@ -30,6 +30,7 @@
         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false,
+            pluginId: 'rowedit',
             listeners:{
                 // Make row ineditable when readonly is set to true
                 // Normally this would belong into a controller an not the view.
@@ -156,5 +157,23 @@
                 probeId: this.recordId
             }
         });
+    },
+
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').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();
+        }
     }
 });
--- a/app/view/grid/Status.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/grid/Status.js	Wed Mar 25 15:04:45 2015 +0100
@@ -26,6 +26,7 @@
         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false,
+            pluginId: 'rowedit',
             listeners:{
                 // Make row ineditable when readonly is set to true
                 // Normally this would belong into a controller an not the view.
@@ -140,5 +141,23 @@
                 messungsId: this.recordId
             }
         });
+    },
+
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').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();
+        }
     }
 });
--- a/app/view/window/ProbeEdit.js	Wed Mar 25 09:07:20 2015 +0100
+++ b/app/view/window/ProbeEdit.js	Wed Mar 25 15:04:45 2015 +0100
@@ -53,8 +53,7 @@
             autoScroll: true,
             items: [{
                 xtype: 'probeform',
-                recordId: this.record.get('id'),
-                readonly: this.record.get('readonly')
+                recordId: this.record.get('id')
              }, {
                 xtype: 'fset',
                 name: 'messungen',
@@ -79,7 +78,7 @@
                 }]
             }, {
                 xtype: 'fset',
-                name: 'probenzusaetzwerte',
+                name: 'probenzusatzwerte',
                 title: 'Zusatzwerte',
                 padding: '5, 5',
                 margin: 5,
@@ -121,6 +120,24 @@
             },
             scope: this
         });
+        if (this.record.get('readonly') == true){
+            this.down('probeform').setReadOnly(true);
+            this.disableChildren();
+        }
+    },
+
+    disableChildren: function(){
+            this.down('fset[name=messungen]').down('messunggrid').setReadOnly(true);
+            this.down('fset[name=orte]').down('ortgrid').setReadOnly(true);
+            this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(true);
+            this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(true);
+    },
+
+    enableChildren: function(){
+            this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false);
+            this.down('fset[name=orte]').down('ortgrid').setReadOnly(false);
+            this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(false);
+            this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(false);
     },
 
     setMessages: function(errors, warnings) {

http://lada.wald.intevation.org