changeset 1013:75ce503ab296 stammdatengrids

Added a Ortszuordnungwindow and Form
author Dustin Demuth <dustin@intevation.de>
date Tue, 26 Jan 2016 12:29:59 +0100
parents 2adc329d90fe
children e9e974d31924
files app.js app/controller/form/Ort.js app/controller/form/Ortszuordnung.js app/controller/grid/Ortszuordnung.js app/view/form/Ortszuordnung.js app/view/window/Ortszuordnung.js resources/i18n/Lada_de-DE.properties
diffstat 7 files changed, 387 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Tue Jan 26 10:40:48 2016 +0100
+++ b/app.js	Tue Jan 26 12:29:59 2016 +0100
@@ -205,7 +205,7 @@
         'Lada.controller.Map',
         'Lada.controller.form.Probe',
         'Lada.controller.form.Messung',
-        'Lada.controller.form.Ort',
+        'Lada.controller.form.Ortszuordnung',
         'Lada.controller.form.Location',
         'Lada.controller.form.Messprogramm',
         'Lada.controller.grid.Ortszuordnung',
--- a/app/controller/form/Ort.js	Tue Jan 26 10:40:48 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-
-/*
- * This is a controller for an Ort Form
- */
-Ext.define('Lada.controller.form.Ort', {
-    extend: 'Ext.app.Controller',
-
-    /**
-     * Initialize the Controller with 4 listeners
-     */
-    init: function() {
-        this.control({
-            'ortform button[action=save]': {
-                click: this.save
-            },
-            'ortform button[action=discard]': {
-                click: this.discard
-            },
-            'ortform': {
-                dirtychange: this.dirtyForm
-            },
-            'ortform combobox[name=ort]': {
-                select: this.updateDetails
-            }
-        });
-    },
-
-     /**
-      * The save function saves the content of the Ort form.
-      * On success it will reload the Store,
-      * on failure, it will display an Errormessage
-      */
-     save: function(button) {
-        var formPanel = button.up('ortform');
-        var data = formPanel.getForm().getFieldValues(true);
-        for (var key in data) {
-            formPanel.getForm().getRecord().set(key, data[key]);
-        }
-        if (!formPanel.getForm().getRecord().get('letzteAenderung')) {
-            formPanel.getForm().getRecord().data.letzteAenderung = new Date();
-        }
-        formPanel.getForm().getRecord().save({
-            success: function(record, response) {
-                var json = Ext.decode(response.response.responseText);
-                if (json) {
-                    button.setDisabled(true);
-                    button.up('toolbar').down('button[action=discard]')
-                        .setDisabled(true);
-                    formPanel.clearMessages();
-                    formPanel.setRecord(record);
-                    formPanel.setMessages(json.errors, json.warnings);
-                    formPanel.up('window').grid.store.reload();
-                }
-            },
-            failure: function(record, response) {
-                button.setDisabled(true);
-                button.up('toolbar').down('button[action=discard]')
-                    .setDisabled(true);
-                formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
-                var json = response.request.scope.reader.jsonData;
-                if (json) {
-                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
-                        formPanel.setMessages(json.errors, json.warnings);
-                    }
-
-                    if(json.message){
-                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title')
-                            +' #'+json.message,
-                            Lada.getApplication().bundle.getMsg(json.message));
-                    } else {
-                         Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
-                            Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
-                    }
-                } else {
-                    Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
-                        Lada.getApplication().bundle.getMsg('err.msg.response.body'));
-                }
-            }
-        });
-    },
-
-   /**
-    * The discard function resets the Location form
-    * to its original state.
-    */
-   discard: function(button) {
-        var formPanel = button.up('form');
-        formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
-        var win = button.up('window');
-        var id = formPanel.getForm().getRecord().get('ort');
-        var toLoad = Ext.data.StoreManager.get('locations').getById(id);
-        win.down('locationform').setRecord(toLoad);
-        win.down('map').selectFeature(id);
-    },
-
-     /**
-      * The dirtyForm function enables or disables the save and discard
-      * button which are present in the toolbar of the form.
-      * The Buttons are only active if the content of the form was altered
-      * (the form is dirty).
-      */
-    dirtyForm: function(form, dirty) {
-        if (dirty) {
-            form.owner.down('button[action=save]').setDisabled(false);
-            form.owner.down('button[action=discard]').setDisabled(false);
-        }
-        else {
-            form.owner.down('button[action=save]').setDisabled(true);
-            form.owner.down('button[action=discard]').setDisabled(true);
-        }
-    },
-
-    /**
-     *  updateDetails is used when a value is selected within the ort combobox
-     *  When this function is called, the map element within the window
-     *  which is embedding this form is updated.
-     */
-    updateDetails: function(combobox, record) {
-        var win = combobox.up('window');
-        var details = win.down('locationform');
-        var id = record[0].get('id');
-        if (details) {
-            var toLoad = Ext.data.StoreManager.get('locations').getById(id);
-            win.down('locationform').setRecord(toLoad);
-            win.down('map').selectFeature(id);
-        }
-    }
-});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/form/Ortszuordnung.js	Tue Jan 26 12:29:59 2016 +0100
@@ -0,0 +1,116 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/*
+ * This is a controller for an Ortszuordnung Form
+ */
+Ext.define('Lada.controller.form.Ortszuordnung', {
+    extend: 'Ext.app.Controller',
+
+    /**
+     * Initialize the Controller with 4 listeners
+     */
+    init: function() {
+        this.control({
+            'ortszuordnungform button[action=save]': {
+                click: this.save
+            },
+            'ortszuordnungform button[action=discard]': {
+                click: this.discard
+            },
+            'ortszuordnungform': {
+                dirtychange: this.dirtyForm
+            },
+            'ortszuordnungform combobox[name=ort]': {
+                select: this.updateDetails
+            }
+        });
+    },
+
+     /**
+      * The save function saves the content of the Ort form.
+      * On success it will reload the Store,
+      * on failure, it will display an Errormessage
+      */
+     save: function(button) {
+        var formPanel = button.up('ortszuordnungform');
+        var data = formPanel.getForm().getFieldValues(true);
+        var i18n = Lada.getApplication().bundle;
+        for (var key in data) {
+            formPanel.getForm().getRecord().set(key, data[key]);
+        }
+        if (!formPanel.getForm().getRecord().get('letzteAenderung')) {
+            formPanel.getForm().getRecord().data.letzteAenderung = new Date();
+        }
+        formPanel.getForm().getRecord().save({
+            success: function(record, response) {
+                var json = Ext.decode(response.response.responseText);
+                if (json) {
+                    button.setDisabled(true);
+                    button.up('toolbar').down('button[action=discard]')
+                        .setDisabled(true);
+                    formPanel.clearMessages();
+                    formPanel.setRecord(record);
+                    formPanel.setMessages(json.errors, json.warnings);
+                    formPanel.up('window').grid.store.reload();
+                    debugger;
+                }
+            },
+            failure: function(record, response) {
+                button.setDisabled(true);
+                button.up('toolbar').down('button[action=discard]')
+                    .setDisabled(true);
+                formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
+                var json = response.request.scope.reader.jsonData;
+                if (json) {
+                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
+                        formPanel.setMessages(json.errors, json.warnings);
+                    }
+
+                    if(json.message){
+                        Ext.Msg.alert(i18n.getMsg('err.msg.save.title')
+                            +' #'+json.message,
+                            i18n.getMsg(json.message));
+                    } else {
+                         Ext.Msg.alert(i18n.getMsg('err.msg.save.title'),
+                            i18n.getMsg('err.msg.generic.body'));
+                    }
+                } else {
+                    Ext.Msg.alert(i18n.getMsg('err.msg.save.title'),
+                        i18n.getMsg('err.msg.response.body'));
+                }
+            }
+        });
+    },
+
+    /**
+     * The discard function resets the Location form
+     * to its original state.
+     */
+    discard: function(button) {
+        var formPanel = button.up('form');
+        formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
+    },
+
+    /**
+     * The dirtyForm function enables or disables the save and discard
+     * button which are present in the toolbar of the form.
+     * The Buttons are only active if the content of the form was altered
+     * (the form is dirty).
+     */
+    dirtyForm: function(form, dirty) {
+        if (dirty) {
+            form.owner.down('button[action=save]').setDisabled(false);
+            form.owner.down('button[action=discard]').setDisabled(false);
+        }
+        else {
+            form.owner.down('button[action=save]').setDisabled(true);
+            form.owner.down('button[action=discard]').setDisabled(true);
+        }
+    }
+});
--- a/app/controller/grid/Ortszuordnung.js	Tue Jan 26 10:40:48 2016 +0100
+++ b/app/controller/grid/Ortszuordnung.js	Tue Jan 26 12:29:59 2016 +0100
@@ -13,8 +13,7 @@
     extend: 'Ext.app.Controller',
 
     requires: [
-        'Lada.view.window.OrtEdit',
-        'Lada.view.window.OrtCreate'
+        'Lada.view.window.Ortszuordnung',
     ],
 
     /**
@@ -36,14 +35,14 @@
     },
 
     /**
-     * When open is called, a {@link Lada.view.window.OrtEdit}
+     * When open is called, a {@link Lada.view.window.Ortszuordnung}
      * is created which allows to edit the Orte
      */
     open: function(grid, record) {
         var probe = grid.up('window').record;
-        var win = Ext.create('Lada.view.window.OrtEdit', {
+        var win = Ext.create('Lada.view.window.Ortszuordnung', {
             parentWindow: grid.up('window'),
-            probe: probe,
+            probe: grid.up('window').down('probeform').record,
             record: record,
             grid: grid
         });
@@ -56,8 +55,10 @@
      */
     add: function(button) {
         var probe = button.up('window').record;
-        var win = Ext.create('Lada.view.window.OrtCreate', {
-            record: probe,
+        var win = Ext.create('Lada.view.window.Ortszuordnung', {
+            parentWindow: button.up('window'),
+            probe: probe,
+            record: null,
             grid: button.up('ortszuordnung')
         });
         win.show();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/form/Ortszuordnung.js	Tue Jan 26 12:29:59 2016 +0100
@@ -0,0 +1,132 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Form to edit the Ortszuordnung of a Probe
+ */
+Ext.define('Lada.view.form.Ortszuordnung', {
+    extend: 'Ext.form.Panel',
+    alias: 'widget.ortszuordnungform',
+
+    model: 'Lada.model.Ortszuordnung',
+    width: '100%',
+    margin: 5,
+    border: 0,
+
+    record: null,
+
+    trackResetOnLoad: true,
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.items = [{
+            xtype: 'fieldset',
+            title: i18n.getMsg('ortszuordnung.form.fset.title'),
+            items: [{
+                border: 0,
+                margin: '0, 0, 10, 0',
+                dockedItems: [{
+                    xtype: 'toolbar',
+                    dock: 'bottom',
+                    border: '0, 1, 1, 1',
+                    style: {
+                        borderBottom: '1px solid #b5b8c8 !important',
+                        borderLeft: '1px solid #b5b8c8 !important',
+                        borderRight: '1px solid #b5b8c8 !important'
+                    },
+                    items: ['->', {
+                        text: i18n.getMsg('save'),
+                        qtip: i18n.getMsg('save.qtip'),
+                        icon: 'resources/img/dialog-ok-apply.png',
+                        action: 'save',
+                        disabled: true
+                    }, {
+                        text: i18n.getMsg('discard'),
+                        qtip: i18n.getMsg('discard.qtip'),
+                        icon: 'resources/img/dialog-cancel.png',
+                        action: 'discard',
+                        disabled: true
+                    }]
+                }],
+                items: [{
+                    xtype: 'container',
+                    layout: {
+                        type: 'hbox'
+                    },
+                    flex: 1,
+                    items: [{
+                        xtype: 'tfield',
+                        maxLength: 100,
+                        name: 'ortszusatztext',
+                        fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszusatztext'),
+                        width: 280,
+                        labelWidth: 80
+                    }, {
+                        xtype: 'tfield',
+                        maxLength: 100,
+                        name: 'ortszuordnungTyp',
+                        fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp'),
+                        width: 280,
+                        labelWidth: 80
+                    }]
+                }]
+            }]
+        }];
+        this.callParent(arguments);
+    },
+
+    setRecord: function(record) {
+        this.getForm().loadRecord(record);
+    },
+
+    setMessages: function(errors, warnings) {
+        var key;
+        var element;
+        var content;
+        var i18n = Lada.getApplication().bundle;
+        if (warnings) {
+            for (key in warnings) {
+                element = this.down('component[name=' + key + ']');
+                if (!element) {
+                    continue;
+                }
+                content = warnings[key];
+                var warnText = '';
+                for (var i = 0; i < content.length; i++) {
+                    warnText += i18n.getMsg(content[i].toString()) + '\n';
+                }
+                element.showWarnings(warnText);
+            }
+        }
+        if (errors) {
+            for (key in errors) {
+                element = this.down('component[name=' + key + ']');
+                if (!element) {
+                    continue;
+                }
+                content = errors[key];
+                var errorText = '';
+                for (var i = 0; i < content.length; i++) {
+                    errorText += i18n.getMsg(content[i].toString()) + '\n';
+                }
+                element.showErrors(errorText);
+            }
+        }
+     },
+
+    clearMessages: function() {
+        this.down('tfield[name=ortszusatztext]').clearWarningOrError();
+        this.down('tfield[name=ortszuordnungTyp]').clearWarningOrError();
+     },
+
+    setReadOnly: function(value) {
+        this.down('tfield[name=ortszusatztext]').setReadOnly(value);
+        this.down('tfield[name=ortszuordnungTyp]').setReadOnly(value);
+    }
+});
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/window/Ortszuordnung.js	Tue Jan 26 12:29:59 2016 +0100
@@ -0,0 +1,121 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Window to create/edit the Ort / Probe Relation
+ */
+Ext.define('Lada.view.window.Ortszuordnung', {
+    extend: 'Ext.window.Window',
+    alias: 'widget.ortszuordnungwindow',
+
+    requires: [
+        'Lada.view.form.Ortszuordnung'
+    ],
+
+    collapsible: true,
+    maximizable: true,
+    autoshow: true,
+    layout: 'border',
+    constrain: true,
+
+    probe: null,
+    parentWindow: null,
+    record: null,
+    grid: null,
+
+    /**
+     * This function initialises the Window
+     */
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+
+        this.title = i18n.getMsg('ortszuordnung.window.title');
+
+        if (this.record && this.probe) {
+            // A new record will be created
+            this.title = i18n.getMsg('ortszuordnung.window.title')
+                            + ' '
+                            + i18n.getMsg('ortszuordnung.window.title2')
+                            + ' '
+                            + i18n.getMsg('probe')
+                            + ' '
+                            + probe.get('hauptprobennr')
+                            + ' '
+                            + i18n.getMsg('edit');
+        }
+        else if (this.probe) {
+            // A new record will be created
+            this.title = i18n.getMsg('ortszuordnung.window.title')
+                            + ' '
+                            + i18n.getMsg('ortszuordnung.window.title2')
+                            + ' '
+                            + i18n.getMsg('probe')
+                            + ' '
+                            + probe.get('hauptprobennr')
+                            + ' '
+                            + i18n.getMsg('create');
+        }
+
+        this.buttons = [{
+            text: i18n.getMsg('close'),
+            scope: this,
+            handler: this.close
+        }];
+        this.width = 900;
+        this.height = 515;
+        this.bodyStyle = {background: '#fff'};
+
+        // 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.items = [{
+            region: 'west',
+            border: 0,
+            layout: 'hbox',
+            items: [{
+                xtype: 'ortszuordnungform',
+                margin: 5
+            //}, {
+            //    xtype: 'ortpanel',
+            //    margin: 5
+            }]
+        }];
+        this.callParent(arguments);
+    },
+
+    /**
+     * Initialise the Data of this Window
+     */
+    initData: function() {
+        this.down('ortszuordnungform').setRecord(this.record);
+    },
+
+    /**
+     * Instructs the fields / forms listed in this method to set a message.
+     * @param errors These Errors shall be shown
+     * @param warnings These Warning shall be shown
+     */
+    setMessages: function(errors, warnings) {
+        //todo this is a stub
+    },
+
+    /**
+     * Instructs the fields / forms listed in this method to clear their messages.
+     */
+    clearMessages: function() {
+        //todo this is a stub
+    }
+});
+
--- a/resources/i18n/Lada_de-DE.properties	Tue Jan 26 10:40:48 2016 +0100
+++ b/resources/i18n/Lada_de-DE.properties	Tue Jan 26 12:29:59 2016 +0100
@@ -46,6 +46,7 @@
 proben:Proben
 stammdaten:Stammdaten
 
+probe:Probe
 name:Name
 mstId:Messstelle
 datenbasisId:Datenbasis
@@ -119,6 +120,14 @@
 about.window.text.clientversion:Clientversion:
 
 
+ortszuordnung.window.title:Ortszuordnung
+ortszuordnung.window.title2:zu
+
+ortszuordnung.form.fset.title:Ortszuordnung
+ortszuordnung.form.field.ortszusatztext:Ortszusatztext
+ortszuordnung.form.field.ortszuordnungtyp:Typ der Ortszuordnung
+
+
 load.statuswert:Lade aktuellen Statuswert...
 load.statusstufe:Lade aktuelle Statusstufe...
 load.statuswert.error:Fehler beim auflösen der Statuswerte

http://lada.wald.intevation.org