changeset 362:6a7a9267e00f

Issue56: Changed way how to set the form and window to readonly. Now all dialogs should habe proper readonly settings. Now the Save and Cancel button are displayed as needed.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 15 Aug 2013 14:07:35 +0200
parents 8a3991b5c200
children 3bed0373cf50
files app/controller/Kommentare.js app/controller/MKommentare.js app/controller/Messungen.js app/controller/Messwert.js app/controller/Orte.js app/controller/Proben.js app/controller/Status.js app/controller/Zusatzwerte.js
diffstat 8 files changed, 62 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Kommentare.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/Kommentare.js	Thu Aug 15 14:07:35 2013 +0200
@@ -44,8 +44,16 @@
     },
     editItem: function(grid, record) {
         console.log('Editing Kommentar');
+        record.getAuthInfo(this.initEditWindow)
+        console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID
+    },
+    initEditWindow: function(record, readonly, owner) {
         var view = Ext.widget('kommentarecreate', {model: record});
-        console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID
+        var ignore = Array();
+        if (readonly) {
+            var form = view.down('form');
+            form.setReadOnly(true, ignore);
+        }
     },
     createSuccess: function(form, record, operation) {
         var store = this.getKommentareStore();
--- a/app/controller/MKommentare.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/MKommentare.js	Thu Aug 15 14:07:35 2013 +0200
@@ -45,8 +45,16 @@
     },
     editItem: function(grid, record) {
         console.log('Editing Kommentar');
+        record.getAuthInfo(this.initEditWindow)
+        console.log("Loaded MKommentar with ID " + record.getId()); //outputs ID
+    },
+    initEditWindow: function(record, readonly, owner) {
         var view = Ext.widget('mkommentarecreate', {model: record});
-        console.log("Loaded MKommentar with ID " + record.getId()); //outputs ID
+        var ignore = Array();
+        if (readonly) {
+            var form = view.down('form');
+            form.setReadOnly(true, ignore);
+        }
     },
     createSuccess: function(form, record, operation) {
         // Reload store
--- a/app/controller/Messungen.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/Messungen.js	Thu Aug 15 14:07:35 2013 +0200
@@ -80,18 +80,19 @@
                 messungsId: record.get('messungsId')
             }
         });
-        var probe = this.getProbenStore().getById(record.get('probeId'));
+        record.getAuthInfo(this.initEditWindow);
+        console.log("Loaded Messung with ID " + record.getId()); //outputs ID
+    },
+    initEditWindow: function(record, readonly, owner) {
         var view = Ext.widget('messungenedit', {model: record});
-        if (probe.get('readonly') === true) {
+        var ignore = Array();
+        if (owner) {
+                ignore.push('fertig');
+        }
+        if (readonly) {
             var form = view.down('form');
-            // TODO: Field "fertig" must be editable (issue51). So we need to remove the
-            // readonly status if the user would be allowed to edit the probe
-            // if the "fertig" flag has not been set. (ti) <2013-08-08 10:24> 
-            var ignore = Array();
-            ignore.push('fertig');
             form.setReadOnly(true, ignore);
         }
-        console.log("Loaded Messung with ID " + record.getId()); //outputs ID
     },
     deleteItem: function(button) {
         // Get selected item in grid
--- a/app/controller/Messwert.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/Messwert.js	Thu Aug 15 14:07:35 2013 +0200
@@ -51,14 +51,16 @@
     },
     editItem: function(grid, record) {
         console.log('Editing Messwert');
-        var probe = this.getProbenStore().getById(record.get('probeId'));
+        record.getAuthInfo(this.initEditWindow)
+        console.log("Loaded Messwert with ID " + record.getId()); //outputs ID
+    },
+    initEditWindow: function(record, readonly, owner) {
         var view = Ext.widget('messwertecreate', {model: record});
-        if (probe.get('readonly') === true) {
+        var ignore = Array();
+        if (readonly) {
             var form = view.down('form');
-            form.setReadOnly(true);
+            form.setReadOnly(true, ignore);
         }
-
-        console.log("Loaded Messwert with ID " + record.getId()); //outputs ID
     },
     deleteItem: function(button) {
         var grid = button.up('grid');
--- a/app/controller/Orte.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/Orte.js	Thu Aug 15 14:07:35 2013 +0200
@@ -96,8 +96,16 @@
     },
     editItem: function(grid, record) {
         console.log('Editing Ort');
+        record.getAuthInfo(this.initEditWindow)
+        console.log("Loaded Ort with ID " + record.getId()); //outputs ID
+    },
+    initEditWindow: function(record, readonly, owner) {
         var view = Ext.widget('ortecreate', {model: record});
-        console.log("Loaded Ort with ID " + record.getId()); //outputs ID
+        var ignore = Array();
+        if (readonly) {
+            var form = view.down('form');
+            form.setReadOnly(true, ignore);
+        }
     },
     createSuccess: function(form, record, operation) {
         // Reload store
--- a/app/controller/Proben.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/Proben.js	Thu Aug 15 14:07:35 2013 +0200
@@ -88,8 +88,6 @@
     editItem: function(grid, record) {
         console.log('Editing Probe');
         var id = record.get('probeId');
-        var view = Ext.widget('probenedit', {modelId: id});
-
         // Load Zusatzwerte
         var pstore = this.getProbenzusatzwerteStore();
         pstore.load();
@@ -120,6 +118,7 @@
                 probeId: id
             }
         });
+        var view = Ext.widget('probenedit', {modelId: id});
         console.log("Loaded Probe with ID " + record.getId()); //outputs ID
     },
     createSuccess: function(form, record, response) {
--- a/app/controller/Status.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/Status.js	Thu Aug 15 14:07:35 2013 +0200
@@ -43,8 +43,16 @@
     },
     editItem: function(grid, record) {
         console.log('Editing Status');
+        record.getAuthInfo(this.initEditWindow)
+        console.log("Loaded Status with ID " + record.getId()); //outputs ID
+    },
+    initEditWindow: function(record, readonly, owner) {
         var view = Ext.widget('statuscreate', {model: record});
-        console.log("Loaded Status with ID " + record.getId()); //outputs ID
+        var ignore = Array();
+        if (readonly) {
+            var form = view.down('form');
+            form.setReadOnly(true, ignore);
+        }
     },
     createSuccess: function(form, record, operation) {
         // Reload store
--- a/app/controller/Zusatzwerte.js	Thu Aug 15 14:05:08 2013 +0200
+++ b/app/controller/Zusatzwerte.js	Thu Aug 15 14:07:35 2013 +0200
@@ -44,10 +44,18 @@
     },
     editZusatzwert: function(grid, record) {
         console.log('Editing Zusatzwert');
+        record.getAuthInfo(this.initEditWindow)
+        console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID
+    },
+    initEditWindow: function(record, readonly, owner) {
         var view = Ext.widget('zusatzwertecreate', {model: record});
         // Mark PZW Selection readonly.
         view.down('probenzusatzwert').disabled = true;
-        console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID
+        var ignore = Array();
+        if (readonly) {
+            var form = view.down('form');
+            form.setReadOnly(true, ignore);
+        }
     },
     createSuccess: function(form, record, operation) {
         // Reload store

http://lada.wald.intevation.org