changeset 757:b8502964f5c3

Added missing files. Added MmtMockup
author Dustin Demuth <dustin@intevation.de>
date Wed, 06 May 2015 14:15:37 +0200
parents f2db1ae1d012
children b2fcbdc4969d
files app/controller/form/Messprogramm.js app/model/MmtMessprogramm.js app/store/MmtMessprogramm.js app/store/Probenintervall.js app/view/form/Messprogramm.js app/view/grid/Messmethoden.js app/view/widget/Probenintervall.js app/view/widget/ProbenintervallSlider.js app/view/window/MessprogrammCreate.js app/view/window/MessprogrammEdit.js resources/i18n/Lada_de-DE.properties
diffstat 11 files changed, 1178 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/form/Messprogramm.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,200 @@
+/* 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.
+ */
+
+/**
+ * A Controller for a Probe form
+ */
+Ext.define('Lada.controller.form.Messprogramm', {
+    extend: 'Ext.app.Controller',
+
+    /**
+     * Initialize the Controller
+     */
+    init: function() {
+        this.control({
+            'messprogrammform button[action=save]': {
+                click: this.save
+            },
+            'messprogrammform button[action=discard]': {
+                click: this.discard
+            },
+            'messprogrammform': {
+                dirtychange: this.dirtyForm
+            },
+            'messprogrammform [xtype="numberfield"]': {
+                change: this.synchronizeSlider,
+                blur: this.checkPeriod
+            },
+            'messprogrammform probenintervall combobox': {
+                select: this.updateIntervalls
+            }
+        });
+    },
+    /**
+     * When the Probenintervall was changed, update the Sliders
+     * and the the numberfield.
+     */
+    updateIntervalls: function(field, records) {
+        console.log('update Intervalls');
+        var form = field.up('messprogrammform');
+        var record = form.getRecord();
+        form.populateIntervall(record, field.getValue());
+    },
+
+    /**
+     * When the Slider was used,
+     * update the Value of the Teilintervallfields
+     */
+    synchronizeFields: function(slider, newValue, thumb) {
+        console.log('Synchronize Fields');
+        var formPanel = slider.up('form');
+        if (thumb.index == 0) {
+            formPanel.getForm()
+                .findField('teilintervallVon')
+                .setValue(newValue);
+        }
+        else if (thumb.index == 1) {
+            formPanel.getForm()
+                .findField('teilintervallBis')
+                .setValue(newValue);
+         }
+
+    },
+
+    /**
+     * When the IntervallFields were used,
+     * update the Slider
+     */
+    synchronizeSlider: function(field, newValue, oldValue) {
+        console.log('Synchronize Slider');
+        var formPanel = field.up('form');
+        if (field.name == 'teilintervallVon') {
+            formPanel.down('probenintervallslider')
+                .setValue(0, newValue, false);
+        }
+        else if (field.name == 'teilintervallBis') {
+            formPanel.down('probenintervallslider')
+                .setValue(1, newValue, false);
+         }
+
+    },
+    /**
+     * The save function saves the content of the Location form.
+     * On success it will reload the Store,
+     * on failure, it will display an Errormessage
+     */
+    save: function(button) {
+        var formPanel = button.up('form');
+        var data = formPanel.getForm().getFieldValues(true);
+        for (var key in data) {
+            formPanel.getForm().getRecord().set(key, data[key]);
+        }
+        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);
+                    if (response.action === 'create' && json.success) {
+                        button.up('window').close();
+                        var win = Ext.create('Lada.view.window.MessprogrammEdit', {
+                            record: record
+                        });
+                        win.show();
+                        win.initData();
+                    }
+                }
+            },
+            failure: function(record, response) {
+                button.setDisabled(true);
+                button.up('toolbar').down('button[action=discard]')
+                    .setDisabled(true);
+                var rec = formPanel.getForm().getRecord();
+                rec.dirty = false;
+                formPanel.getForm().loadRecord(record);
+                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'));
+                    }
+                    formPanel.clearMessages();
+                    //formPanel.setRecord(record);
+                    formPanel.setMessages(json.errors, json.warnings);
+                } 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());
+        formPanel.getForm().owner.populateIntervall(
+            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);
+        }
+    },
+
+    /**
+     * checkPeriod() is called when a fields defining an intervall
+     * were modified
+     * The function validates if the start is smaller than end.
+     */
+    checkPeriod: function(field) {
+
+        // This field might be a field within a Period.
+        // Search for Partner field (period: end/start) and validate
+        // End Before Start validation
+        if (field.period) {
+            var partners = new Array();
+                partners[0] = field.up('fieldset').down('numberfield[period=start]').getValue()
+                partners[1] = field.up('fieldset').down('numberfield[period=end]').getValue()
+            if (partners[0] && partners[1] && partners[0] > partners [1]) {
+                var msg = Lada.getApplication().bundle.getMsg('662');
+                field.up('fieldset').showWarningOrError(true, msg, false, '');
+            } else {
+                field.up('fieldset').clearMessages();
+            }
+        }
+    }
+});
--- a/app/model/MmtMessprogramm.js	Wed May 06 10:59:03 2015 +0200
+++ b/app/model/MmtMessprogramm.js	Wed May 06 14:15:37 2015 +0200
@@ -37,7 +37,7 @@
 
     proxy: {
         type: 'rest',
-        url: 'lada-server/mmtmessprogramm',
+        url: 'lada-server/messprogrammmmt',
         reader: {
             type: 'json',
             root: 'data'
--- a/app/store/MmtMessprogramm.js	Wed May 06 10:59:03 2015 +0200
+++ b/app/store/MmtMessprogramm.js	Wed May 06 14:15:37 2015 +0200
@@ -11,6 +11,6 @@
  */
 Ext.define('Lada.store.MmtMessprogramm', {
     extend: 'Ext.data.Store',
-    model: 'Lada.model.MmtMessprogramm'
+    model: 'Lada.model.MmtMessprogramm',
 });
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/store/Probenintervall.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,79 @@
+/* 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 Store which maps between the identifiers
+ * of a probenintervall and their meanings.
+ */
+
+Ext.define('Lada.store.Probenintervall', {
+    extend: 'Ext.data.Store',
+    fields: ['probenintervall',
+            {
+                name: 'piTexti18nId',
+                convert: translateStore
+            },
+            'periodstart',
+            'periodend'],
+    storeId: 'probenintervall',
+    data: [{
+        'probenintervall': 'J',
+        'piTexti18nId': 'pi.yearly',
+        'periodstart': 1,
+        'periodend': 365
+    }, {
+        'probenintervall': 'H',
+        'piTexti18nId': 'pi.halfyearly',
+        'periodstart': 1,
+        'periodend': 183
+    }, {
+        'probenintervall': 'Q',
+        'piTexti18nId': 'pi.quarteryearly',
+        'periodstart': 1,
+        'periodend': 91
+    }, {
+        'probenintervall': 'M',
+        'piTexti18nId': 'pi.monthly',
+        'periodstart': 1,
+        'periodend': 30
+    }, {
+        'probenintervall': 'W4',
+        'piTexti18nId': 'pi.fourweekly',
+        'periodstart': 1,
+        'periodend': 28
+    }, {
+        'probenintervall': 'W2',
+        'piTexti18nId': 'pi.twoweekly',
+        'periodstart': 1,
+        'periodend': 14
+    }, {
+        'probenintervall': 'W',
+        'piTexti18nId': 'pi.weekly',
+        'periodstart': 1,
+        'periodend': 7
+    }, {
+        'probenintervall': 'T',
+        'piTexti18nId': 'pi.daily',
+        'periodstart': 1,
+        'periodend': 1
+    }],
+    sorters: [{
+        property: 'periodend',
+        direction: 'DESC',
+    }],
+    sortOnLoad: true,
+    remoteSort: false,
+});
+
+function translateStore(v, record){
+// TODO currently Lada.get... can not be found when this code is run.
+//    var i18n = Lada.getApplication().bundle;
+//    return i18n.getMsg(v);
+      return v;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/form/Messprogramm.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,441 @@
+/* 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.
+ */
+
+/*
+ * Formular to edit a Messprogramm
+ */
+Ext.define('Lada.view.form.Messprogramm', {
+    extend: 'Ext.form.Panel',
+    alias: 'widget.messprogrammform',
+    requires: [
+        'Lada.view.widget.Datenbasis',
+        'Lada.view.widget.Messstelle',
+        'Lada.view.widget.Netzbetreiber',
+        'Lada.view.widget.Betriebsart',
+        'Lada.view.widget.Testdatensatz',
+        'Lada.view.widget.Probenart',
+        'Lada.view.widget.Umwelt',
+        'Lada.view.widget.base.TextField',
+        'Lada.view.widget.base.FieldSet',
+        'Lada.model.Messprogramm',
+        'Lada.model.MmtMessprogramm',
+        'Lada.view.widget.Probenintervall',
+        'Lada.view.widget.ProbenintervallSlider',
+        'Lada.view.widget.base.Datetime',
+        'Lada.view.widget.base.DateField'
+    ],
+
+    model: 'Lada.model.Messprogramm',
+    minWidth: 650,
+    margin: 5,
+    border: 0,
+
+    recordId: null,
+
+    trackResetOnLoad: true,
+
+    initComponent: function() {
+        var me = this;
+        var i18n = Lada.getApplication().bundle;
+        this.items = [{
+            xtype: 'fieldset',
+            title: i18n.getMsg('messprogramm.form.fieldset.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: [{
+                    layout: 'hbox',
+                    border: 0,
+                    items: [{
+                        border: 0,
+                        width: '50%',
+                        minWidth: 290,
+                        layout: {
+                            type: 'vbox',
+                            align: 'stretch'
+                        },
+                        margin: '0, 10, 0, 0',
+                        items: [{
+                            xtype: 'messstelle',
+                            name: 'mstId',
+                            fieldLabel: i18n.getMsg('mstId'),
+                            labelWidth: 135,
+                            allowBlank: false,
+                            editable: true
+                        }, {
+                            xtype: 'textfield',
+                            name: 'name',
+                            fieldLabel: i18n.getMsg('name'),
+                            labelWidth: 135,
+                            allowBlank: false,
+                            editable: true
+                        }, {
+                             xtype: 'textarea', //todo: we need a widget which is capable of handling errormsg.
+                            name: 'probeKommentar',
+                            labelAlign: 'top',
+                            fieldLabel: i18n.getMsg('probeKommentar'),
+                            labelwidth: 135,
+                            anchor: '100%'
+                        }]
+                    }, {
+                        border: 0,
+                        width: '50%',
+                        minWidth: 300,
+                        margin: '0, 1, 0, 0',
+                        items: [{
+                            xtype: 'fset',
+                            title: i18n.getMsg('erwAngaben'),
+                            name: 'erwAngaben',
+                            collapsible: false,
+                            collapsed: false,
+                            items: [{
+                                xtype: 'datenbasis',
+                                editable: false,
+                                name: 'datenbasisId',
+                                fieldLabel: i18n.getMsg('datenbasisId'),
+                                anchor: '100%',
+                                labelWidth: 105
+                            }, {
+                                xtype: 'betriebsart',
+                                name: 'baId',
+                                fieldLabel: i18n.getMsg('baId'),
+                                anchor: '100%',
+                                labelWidth: 105
+                            }, {
+                                xtype: 'testdatensatz',
+                                name: 'test',
+                                fieldLabel: i18n.getMsg('test'),
+                                anchor: '100%',
+                                labelWidth: 105,
+                                allowBlank: false
+                            }, {
+                                xtype: 'probenart',
+                                editable: false,
+                                name: 'probenartId',
+                                fieldLabel: i18n.getMsg('probenartId'),
+                                anchor: '100%',
+                                labelWidth: 105,
+                                allowBlank: false
+                            }, {
+                                xtype: 'numberfield',
+                                allowDecimals: false,
+                                name: 'probeNehmerId',
+                                fieldLabel: i18n.getMsg('probeNehmerId'),
+                                anchor: '100%',
+                                labelWidth: 105
+                            }, {
+                                xtype: 'netzbetreiber',
+                                name: 'netzbetreiberId',
+                                editable: false,
+                                fieldLabel: i18n.getMsg('netzbetreiberId'),
+                                anchor: '100%',
+                                labelWidth: 105,
+                                allowBlank: false
+                           }]
+                        }]
+                    }]
+                }, {
+                    // Medium
+                    xtype: 'fieldset',
+                    title: i18n.getMsg('medium'),
+                    items: [{
+                        border: 0,
+                        layout: {
+                            type: 'vbox',
+                            align: 'stretch'
+                        },
+                        width: '100%',
+                        items: [{
+                           xtype: 'textfield',
+                            maxLength: 38,
+                            enforceMaxLength: true,
+                            name: 'mediaDesk',
+                            labelWidth: 125,
+                            fieldLabel: i18n.getMsg('mediaDesk'),
+                            regex: new RegExp('(?:D: ){1}(?:[0-9]{2} ){11}[0-9]{2}'),
+                            regexText: i18n.getMsg('err.msg.deskriptorvalidation'),
+                            listeners: {
+                                dirtychange: {
+                                    fn: this.updateOnChange,
+                                    scope: me
+                                }
+                            }
+                        }, {
+                            xtype: 'umwelt',
+                            name: 'umwId',
+                            fieldLabel: i18n.getMsg('umwId'),
+                            labelWidth: 125,
+                            allowBlank: false,
+                            editable: true,
+                            listeners: {
+                                dirtychange: {
+                                    fn: this.updateOnChange,
+                                    scope: me
+                                }
+                            }
+                        }, {
+                            xtype: 'fieldset',
+                            title: i18n.getMsg('deskDetails'),
+                            collapsible: true,
+                            collapsed: true,
+                            defaultType: 'textfield',
+                            layout: {
+                                type: 'table',
+                                columns: 3
+                            },
+                            items: this.buildDescriptors(),
+                            listeners: {
+                                dirtychange: {
+                                    fn: this.updateOnChange,
+                                    scope: me
+                                }
+                            }
+                        }]
+                    }]
+                }, {
+                    // Zeit
+                    xtype: 'fieldset',
+                    title: i18n.getMsg('time'),
+                    layout: {
+                        type: 'hbox',
+                        pack: 'center',
+                        align: 'stretch'
+                    },
+                    items: [{
+                        xtype: 'fset',
+                        title: i18n.getMsg('validity'),
+                        name: 'gueltigPeriod',
+                        anchor: '100%',
+                        width: '50%',
+                        margin: '0, 5, 5, 5',
+                        layout: {
+                            type: 'vbox',
+                            align: 'stretch'
+                        },
+                        items: [{
+                            xtype: 'datetime',
+                            fieldLabel: i18n.getMsg('gueltigVon'),
+                            labelWidth: 90,
+                            anchor: '100%',
+                            name: 'gueltigVon',
+                            format: 'd.m.Y H:i',
+                            period: 'start'
+                        }, {
+                            xtype: 'datetime',
+                            fieldLabel: i18n.getMsg('gueltigBis'),
+                            labelWidth: 90,
+                            anchor: '100%',
+                            name: 'gueltigBis',
+                            format: 'd.m.Y H:i',
+                            period: 'end'
+                        }]
+                    }, {
+                        xtype: 'fset',
+                        title: i18n.getMsg('probenintervall'),
+                        name: 'probenintervall',
+                        anchor: '100%',
+                        width: '50%',
+                        margin: '0, 5, 5, 5',
+                        layout: {
+                            type: 'vbox',
+                            align: 'stretch'
+                        },
+                        items: [{
+                            xtype: 'probenintervall',
+                            fieldLabel: i18n.getMsg('probenintervall'),
+                            labelWidth: 90,
+                            anchor: '100%',
+                            name: 'probenintervall'
+                        }, {
+                            xtype: 'numberfield',
+                            fieldLabel: i18n.getMsg('teilintervallVon'),
+                            labelWidth: 90,
+                            anchor: '100%',
+                            name: 'teilintervallVon',
+                            period: 'start'
+                        }, {
+                            xtype: 'numberfield',
+                            fieldLabel: i18n.getMsg('teilintervallBis'),
+                            labelWidth: 90,
+                            anchor: '100%',
+                            name: 'teilintervallBis',
+                            period: 'end'
+                        }, {
+                            xtype: 'probenintervallslider',
+                            fieldLabel: i18n.getMsg('intervall'),
+                            labelWidth: 90,
+                            anchor: '100%',
+                            values: [0, 0],
+                                //this will be overridden
+                                // by setRecord
+                        }]
+                    }]
+                }]
+            }]
+        }];
+        this.callParent(arguments);
+    },
+
+    populateIntervall: function(record, intervall) {
+        console.log('Populate Start');
+        //intervall is an identifier of a intervall
+        // for instance H, M, J, ...
+        // Initialize the probenintervallslider
+        var s = this.down('probenintervallslider');
+        var v = this.getForm().findField('teilintervallVon');
+        var b = this.getForm().findField('teilintervallBis');
+        var intervallstore = Ext.data.StoreManager.get('Probenintervall');
+
+        var svalUpper = null
+        var svalLower = null
+
+        if (!intervallstore) {
+            intervallstore = Ext.create('Lada.store.Probenintervall');
+        }
+
+        //It is likely that this method was not
+        // called from the controller,
+        //and the probenintervall was not changed.
+        // Load the records in this case
+        if (!intervall) {
+            intervall = record.get('probenintervall',
+                    0, false, false, true);
+
+            svalUpper = record.get('teilintervallBis');
+            svalLower = record.get('teilintervallVon');
+        }
+
+
+        var intrec = intervallstore
+            .findRecord('probenintervall',
+                intervall, 0, false, false, true);
+
+        var min = intrec.get('periodstart');
+        var max = intrec.get('periodend');
+
+        if (!svalUpper) {
+            svalUpper = max;
+        }
+        if (!svalLower) {
+            svalLower = min;
+        }
+
+        //Set Teilintervalle
+        v.setMinValue(min);
+        v.setMaxValue(max);
+        b.setMinValue(min);
+        b.setMaxValue(max);
+
+        //Set Slider
+        s.setMinValue(min);
+        s.setMaxValue(max);
+
+        v.setValue(svalLower);
+        b.setValue(svalUpper);
+
+        console.log('Populate End');
+    },
+
+    setRecord: function(record) {
+        this.clearMessages();
+        this.getForm().loadRecord(record);
+        //Set the intervall numberfields and the slider.
+        this.down('probenintervallslider').setValue([
+            record.get('teilintervallVon'),
+            record.get('teilintervallBis')
+        ]);
+
+        //TODO Set Sliders MinMaxValue
+
+        this.down('probenintervallslider').on(
+            'change',
+            Lada.app.getController('Lada.controller.form.Messprogramm')
+                .synchronizeFields
+        );
+
+    },
+
+    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() {
+        // TODO
+    },
+
+    setReadOnly: function(value) {
+        // TODO
+    },
+
+    buildDescriptors: function() {
+        var fields = [];
+        for (var i = 0; i < 12; i++) {
+            fields[i] = {
+                fieldLabel: 'S' + i,
+                name: 's' + i,
+                labelWidth: 25,
+                margin: '0, 10, 5, 0'
+            };
+        }
+        return fields;
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/grid/Messmethoden.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,131 @@
+/* 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.
+ */
+
+/*
+ * Grid to list Messmethoden
+ */
+Ext.define('Lada.view.grid.Messmethoden', {
+    extend: 'Ext.grid.Panel',
+    alias: 'widget.messmethodengrid',
+
+    requires: [
+        'Lada.view.widget.Messmethode'
+    ],
+
+    maxHeight: 350,
+    minHeight: 110,
+    viewConfig: {
+        deferEmptyText: false
+    },
+    margin: '0, 5, 5, 5',
+
+    recordId: null,
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.emptyText = i18n.getMsg('emptytext.mmtgrid');
+
+        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+            clicksToMoveEditor: 1,
+            autoCancel: false,
+            disabled: false,
+            pluginId: 'rowedit',
+            listeners:{
+                // Make row ineditable when readonly is set to true
+                // Normally this would belong into a controller an not the view.
+                // But the RowEditPlugin is not handled there.
+                beforeedit: function(e, o) {
+                    var readonlywin = o.grid.up('window').record.get('readonly');
+                    var readonlygrid = o.record.get('readonly');
+                    if (readonlywin == true || readonlygrid == true || this.disabled)  {
+                        return false;
+                    }
+                    return true;
+                }
+            }
+         });
+
+        this.plugins = [this.rowEditing];
+
+        this.dockedItems = [{
+            xtype: 'toolbar',
+            dock: 'bottom',
+            items: ['->', {
+                text: i18n.getMsg('add'),
+                icon: 'resources/img/list-add.png',
+                action: 'add',
+                probeId: this.probeId,
+                parentId: this.parentId
+            }, {
+                text: i18n.getMsg('delete'),
+                icon: 'resources/img/list-remove.png',
+                action: 'delete'
+            }]
+        }];
+        this.columns = [{
+            header: 'Messmethode',
+            dataIndex: 'id',
+            flex: 1,
+            renderer: function(value) {
+                if (!value || value === '') {
+                    return '';
+                }
+                var store = Ext.data.StoreManager.get('messmethode');
+                return store.findRecord('mprId', value, 0, false, false, true).get('messmethode');
+            },
+            editor: {
+                xtype: 'combobox',
+                store: Ext.data.StoreManager.get('messmethode'),
+                displayField: 'messmethode',
+                valueField: 'id',
+                allowBlank: false,
+                editable: true,
+                forceSelection: true,
+                autoSelect: true,
+                queryMode: 'local',
+                minChars: 0,
+                typeAhead: false,
+                triggerAction: 'all'
+            }
+        }];
+        this.initData();
+        this.callParent(arguments);
+    },
+
+    initData: function() {
+        if (this.store) {
+            this.store.removeAll();
+        }
+        else {
+            this.store = Ext.create('Lada.store.MmtMessprogramm');
+        }
+        this.store.load({
+            params: {
+                mprId: 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();
+         }
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widget/Probenintervall.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,51 @@
+/* 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.
+ */
+
+
+
+
+/**
+ * Combobox for Probenintervall
+ */
+Ext.define('Lada.view.widget.Probenintervall', {
+    extend: 'Lada.view.widget.base.ComboBox',
+    alias: 'widget.probenintervall',
+    requires: [
+        'Lada.store.Probenintervall'
+    ],
+    store: 'Probenintervall',
+    displayField: 'probenintervall',
+    valueField: 'probenintervall',
+    forceSelection: true,
+    //editable: this.editable || false,
+    // Enable filtering of comboboxes
+    queryMode: 'local',
+    triggerAction: 'all',
+    typeAhead: false,
+    tpl: Ext.create("Ext.XTemplate",
+        '<tpl for="."><div class="x-combo-list-item  x-boundlist-item" >' +
+            '{probenintervall} - {piTexti18nId}</div></tpl>'),
+    displayTpl: Ext.create('Ext.XTemplate',
+         '<tpl for=".">{probenintervall} -'+
+         '{piTexti18nId}</tpl>'),
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.emptyText = i18n.getMsg('emptytext.probenintervall');
+
+        this.store = Ext.data.StoreManager.get('Probenintervall');
+
+        if (!this.store) {
+            this.store = Ext.create('Lada.store.Probenintervall');
+        }
+        else {
+            this.store.clearFilter();
+        }
+        this.callParent(arguments);
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widget/ProbenintervallSlider.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,12 @@
+Ext.define('Lada.view.widget.ProbenintervallSlider', {
+    extend: 'Ext.slider.Multi',
+    alias: 'widget.probenintervallslider',
+    useTips: false,
+    //editable: this.editable || false,
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+
+        this.callParent(arguments);
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/window/MessprogrammCreate.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,103 @@
+/* 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 a Messprogramm
+ *
+ */
+Ext.define('Lada.view.window.MessprogrammCreate', {
+    extend: 'Ext.window.Window',
+    alias: 'widget.messprogrammcreate',
+
+    requires: [
+        'Lada.view.form.Messprogramm'
+    ],
+
+    collapsible: true,
+    maximizable: true,
+    autoShow: true,
+    autoScroll: true,
+    layout: 'fit',
+    constrain: true,
+
+    record: null,
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.title = i18n.getMsg('messprogramm.window.create.title');
+        this.buttons = [{
+            text: i18n.getMsg('close'),
+            scope: this,
+            handler: this.close
+        }];
+
+        // 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.width = 700;
+        this.height = Ext.getBody().getViewSize().height - 30;
+        // InitialConfig is the config object passed to the constructor on
+        // creation of this window. We need to pass it throuh to the form as
+        // we need the "modelId" param to load the correct item.
+
+        this.items = [{
+            border: 0,
+            autoScroll: true,
+            items: [{
+                xtype: 'messprogrammform'
+            }, {
+                //Messmethoden
+                xtype: 'fieldset',
+                title: i18n.getMsg('mmtmessprogramm.form.fieldset.title'),
+                autoScroll: true,
+                margin: 5,
+                layout: {
+                    type: 'hbox',
+                },
+                items: [{
+                    xtype: 'messmethodengrid',
+                    flex: 1
+                }, {
+                    xtype: 'messmethodengrid',
+                    flex: 1
+                }]
+            }]
+        }];
+        this.callParent(arguments);
+    },
+
+    initData: function() {
+        var record = Ext.create('Lada.model.Messprogramm');
+        this.down('messprogrammform').setRecord(record);
+    },
+
+    setMessages: function(errors, warnings) {
+        this.down('messprogrammform').setMessages(errors, warnings);
+    },
+
+    clearMessages: function() {
+        this.down('messprogrammform').clearMessages();
+    },
+
+    disableChildren: function(){
+        //intentionally!
+        return true;
+    },
+
+    enableChildren: function(){
+        //intentionally!
+        return true;
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/window/MessprogrammEdit.js	Wed May 06 14:15:37 2015 +0200
@@ -0,0 +1,154 @@
+/* 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 edit a Messprogramm
+ */
+Ext.define('Lada.view.window.MessprogrammEdit', {
+    extend: 'Ext.window.Window',
+    alias: 'widget.messprogrammedit',
+
+    requires: [
+        'Lada.view.form.Messprogramm',
+        'Lada.view.grid.Messmethoden',
+    ],
+
+    collapsible: true,
+    maximizable: true,
+    autoShow: true,
+    autoScroll: true,
+    layout: 'fit',
+    constrain: true,
+
+    record: null,
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+
+        if (this.record === null) {
+            Ext.Msg.create(i18n.getMsg('err.msg.generic.title'),
+                i18n.getMsg('err.msg.novalidmessprogram'));
+            this.callParent(arguments);
+            return;
+        }
+        this.title = i18n.getMsg('messprogramm.window.edit.title');
+        this.buttons = [{
+            text: i18n.getMsg('close'),
+            scope: this,
+            handler: this.close
+        }];
+        this.width = 700;
+
+        // 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.height = Ext.getBody().getViewSize().height - 30;
+        // InitialConfig is the config object passed to the constructor on
+        // creation of this window. We need to pass it throuh to the form as
+        // we need the "Id" param to load the correct item.
+        this.items = [{
+            border: 0,
+            autoScroll: true,
+            items: [{
+                xtype: 'messprogrammform',
+                recordId: this.record.get('id')
+            }, {
+                //Messmethoden
+                xtype: 'fieldset',
+                title: i18n.getMsg('mmtmessprogramm.form.fieldset.title'),
+                autoScroll: true,
+                margin: 5,
+                layout: {
+                    type: 'hbox',
+                },
+                items: [{
+                    xtype: 'messmethodengrid',
+                    flex: 1
+                }, {
+                    xtype: 'messmethodengrid',
+                    flex: 1
+                }]
+            }]
+        }];
+        this.callParent(arguments);
+    },
+
+    initData: function() {
+        this.setLoading(true);
+        this.clearMessages();
+        me = this;
+        Ext.ClassManager.get('Lada.model.Messprogramm').load(this.record.get('id'), {
+            failure: function(record, action) {
+                me.setLoading(false);
+                // TODO
+                console.log('An unhandled Failure occured. See following Response and Record');
+                console.log(action);
+                console.log(record);
+             },
+            success: function(record, response) {
+                this.down('messprogrammform').setRecord(record);
+                this.record = record;
+                owner = this.record.get('owner');
+
+                // If this would be A probe, it would be always
+                // allowed to add Messungen:
+                /*
+                if (owner) {
+                    me.enableAddMessungen();
+                }
+                */
+
+                var json = Ext.decode(response.response.responseText);
+                if (json) {
+                    this.setMessages(json.errors, json.warnings);
+                }
+                // If the Messprogramm is ReadOnly, disable Inputfields and grids
+                if (this.record.get('readonly') === true) {
+                    this.down('messprogrammform').setReadOnly(true);
+                    this.disableChildren();
+                }
+                else {
+                    this.down('messprogrammform').setReadOnly(false);
+                    this.enableChildren();
+                }
+                me.setLoading(false);
+            },
+            scope: this
+        });
+    },
+
+    //This was used in a Probewindow, I left it here for reference...
+    /*
+    enableAddMessungen: function() {
+        this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false);
+    },
+    */
+
+    disableChildren: function() {
+        // thera are no children....
+    },
+
+    enableChildren: function() {
+        // there are no children....
+    },
+
+    setMessages: function(errors, warnings) {
+        this.down('messprogrammform').setMessages(errors, warnings);
+    },
+
+    clearMessages: function() {
+        this.down('messprogrammform').clearMessages();
+    }
+});
--- a/resources/i18n/Lada_de-DE.properties	Wed May 06 10:59:03 2015 +0200
+++ b/resources/i18n/Lada_de-DE.properties	Wed May 06 14:15:37 2015 +0200
@@ -56,6 +56,8 @@
 gueltigVon:Gültig Von
 gueltigBis:Gültig Bis
 probeKommentar:Probe Kommentar
+messmethode:Messmethode
+nuklide:Nuklide
 
 emptytext.probenintervall:Wählen Sie ein Probenintervall
 emptytext.datenbasis:Wahlen Sie eine Datenbasis
@@ -69,16 +71,17 @@
 medium:Medium
 deskDetails:Details Deskriptoren
 time:Zeit
-messmethoden:Messmethode
 validity:Gültigkeit
 sollzeitraum:Sollzeitraum
 
 messprogramm.window.edit.title:Messprogramm bearbeiten
 messprogramm.window.create.title:Messprogramm erstellen
 messprogramm.form.fieldset.title:Messprogramm
-mmtmessprogramm.form.fieldset.title:Messmethode
+mmtmessprogramm.form.fieldset.title:Messmethode & Nuklide
 
 # Actions
+add:Hinzufügen
+delete:Löschen
 edit:bearbeiten
 create:erstellen
 close:Schließen

http://lada.wald.intevation.org