diff app/controller/form/Messprogramm.js @ 797:b8fd43021c29

Added a Window to alter Orte of a Messprogramm
author Dustin Demuth <dustin@intevation.de>
date Wed, 20 May 2015 16:48:03 +0200
parents f0b26df02157
children ff4330d4aba1
line wrap: on
line diff
--- a/app/controller/form/Messprogramm.js	Wed May 20 14:19:12 2015 +0200
+++ b/app/controller/form/Messprogramm.js	Wed May 20 16:48:03 2015 +0200
@@ -12,6 +12,10 @@
 Ext.define('Lada.controller.form.Messprogramm', {
     extend: 'Ext.app.Controller',
 
+    requires: [
+        'Lada.view.window.MessprogrammOrt'
+    ],
+
     /**
      * Initialize the Controller
      */
@@ -23,9 +27,15 @@
             'messprogrammform button[action=discard]': {
                 click: this.discard
             },
+            'messprogrammform button[action=ort]': {
+                click: this.editOrtWindow
+            },
             'messprogrammform': {
                 dirtychange: this.dirtyForm
             },
+            'messprogrammform location combobox': {
+                select: this.syncOrtWindow
+            },
             'messprogrammform datetime textfield': {
                 blur: this.checkDatePeriod
             },
@@ -55,6 +65,43 @@
         var record = form.getRecord();
         form.populateIntervall(record, field.getValue());
     },
+    /**
+     * The function will open a new Window to edit the Ort of a Messprogramm
+     */
+    editOrtWindow: function(button) {
+        var formPanel = button.up('form');
+        //Only Open if the WIndow does not exist, else focus
+        if (!formPanel.ortWindow) {
+            var data = formPanel.getForm().getFieldValues(true);
+            formPanel.ortWindow = Ext.create('Lada.view.window.MessprogrammOrt', {
+                record: formPanel.getRecord(),
+                parentWindow: formPanel.up('window')
+            });
+            formPanel.ortWindow.show();
+            formPanel.ortWindow.initData();
+       }
+       else {
+            formPanel.ortWindow.focus();
+            formPanel.ortWindow.setActive(true);
+       }
+    },
+
+    /**
+     * When a OrtWindow exist, and the value of the location combobox is changed, update the window.
+     */
+    syncOrtWindow: function(combo, record){
+        var formPanel = combo.up('messprogrammform');
+        if (formPanel.ortWindow) {
+            var ortwindowlocation = formPanel
+                .ortWindow.down('location')
+            var ortwindowcombo = ortwindowlocation
+                .down('combobox');
+
+            ortwindowcombo.select(combo.getValue());
+            ortwindowlocation.fireEvent('select',
+                ortwindowcombo, ortwindowcombo.record);
+       }
+    },
 
     /**
      * When the Slider was used,

http://lada.wald.intevation.org