changeset 818:097d4edc2f00

Genprobenwindow can only be created once, also fixed messprogrammortewindow 'close with x and can not reopen' bug
author Dustin Demuth <dustin@intevation.de>
date Fri, 29 May 2015 09:05:06 +0200
parents 1321efe444f0
children 00072c3c926e
files app/controller/form/Messprogramm.js app/view/window/GenProbenFromMessprogramm.js app/view/window/Messprogramm.js app/view/window/MessprogrammOrt.js resources/i18n/Lada_de-DE.properties
diffstat 5 files changed, 38 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/form/Messprogramm.js	Fri May 29 08:31:19 2015 +0200
+++ b/app/controller/form/Messprogramm.js	Fri May 29 09:05:06 2015 +0200
@@ -51,7 +51,7 @@
                 change: this.synchronizeSlider,
                 blur: this.checkPeriod
             },
-             'messprogrammform probenintervall combobox': {
+            'messprogrammform probenintervall combobox': {
                 select: this.updateIntervalls
             },
             'messprogrammform panel[xtype="deskriptor] combobox': {
--- a/app/view/window/GenProbenFromMessprogramm.js	Fri May 29 08:31:19 2015 +0200
+++ b/app/view/window/GenProbenFromMessprogramm.js	Fri May 29 09:05:06 2015 +0200
@@ -21,10 +21,21 @@
     constrain: true,
 
     record: null,
+    parentWindow: null,
 
     initComponent: function() {
         var i18n = Lada.getApplication().bundle;
 
+        // add listeners to change the window appearence when it becomes inactive
+        this.on({
+            activate: function(){
+                this.getEl().removeCls('window-inactive');
+            },
+            deactivate: function(){
+                this.getEl().addCls('window-inactive');
+            }
+        });
+
         this.title = i18n.getMsg('gpfm.window.title');
         var me = this;
         this.buttons = [{
@@ -76,7 +87,7 @@
                                     'Der Server konnte die Anfrage nicht authentifizieren.<br/>'+
                                     'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' +
                                     'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
-                                    'Soll die Anwendung jetzt neu geladen werden?', this.reload);
+                                    'Soll die Anwendung jetzt neu geladen werden?', me.reload); //TODO Scope?
                             }
                             else if(json.message){
                                 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title')
@@ -104,6 +115,9 @@
             },
             deactivate: function(){
                 this.getEl().addCls('window-inactive');
+            },
+            close: function () {
+                this.parentWindow.probenWindow = null;
             }
         });
 
--- a/app/view/window/Messprogramm.js	Fri May 29 08:31:19 2015 +0200
+++ b/app/view/window/Messprogramm.js	Fri May 29 09:05:06 2015 +0200
@@ -25,6 +25,7 @@
     autoScroll: true,
     layout: 'fit',
     constrain: true,
+    probenWindow: null,
 
     record: null,
 
@@ -37,18 +38,26 @@
         else {
             this.title = i18n.getMsg('messprogramm.window.edit.title');
         }
-
         this.buttons = [{
             text: i18n.getMsg('generateproben'),
             scope: this,
             disabled: this.record? false : true, //disable button if no record is set.
             handler: function() {
-                var winname = 'Lada.view.window.GenProbenFromMessprogramm';
-                var win = Ext.create(winname, {
-                    record: this.record
-                });
-                win.show();
-                win.initData();
+                //Make the Window a "singleton"
+                if (! this.probenWindow) {
+                    var winname = 'Lada.view.window.GenProbenFromMessprogramm';
+                    var win = Ext.create(winname, {
+                        record: this.record,
+                        parentWindow: this
+                    });
+                    win.show();
+                    win.initData();
+                    this.probenWindow = win;
+               }
+               else {
+                    this.probenWindow.focus();
+                    this.probenWindow.setActive(true);
+               }
             }
         },
         '->',
--- a/app/view/window/MessprogrammOrt.js	Fri May 29 08:31:19 2015 +0200
+++ b/app/view/window/MessprogrammOrt.js	Fri May 29 09:05:06 2015 +0200
@@ -41,7 +41,7 @@
             text: i18n.getMsg('cancel'),
             scope: this,
             handler: function() {
-                this.close()
+                this.close();
                 this.parentWindow.down('messprogrammform')
                     .ortWindow = null;
            }
@@ -57,6 +57,10 @@
             },
             deactivate: function(){
                 this.getEl().addCls('window-inactive');
+            },
+            close: function () {
+                this.parentWindow.down('messprogrammform')
+                    .ortWindow = null;
             }
         });
 
--- a/resources/i18n/Lada_de-DE.properties	Fri May 29 08:31:19 2015 +0200
+++ b/resources/i18n/Lada_de-DE.properties	Fri May 29 09:05:06 2015 +0200
@@ -12,6 +12,7 @@
 611:Wert nicht eindeutig
 631:Wert nicht gesetzt
 632:Werte passen nicht zusammen
+633:
 651:Punkt nicht in Polygon
 652:Werte passen nicht zusammen
 661:Der Zeitpunkt liegt in der Zukunft

http://lada.wald.intevation.org