changeset 579:50c05b1b085f

merged
author Dustin Demuth <dustin@intevation.de>
date Tue, 10 Mar 2015 15:50:03 +0100
parents bbe610be91cc (diff) 5af82dc8612d (current diff)
children fe074c2250b4
files
diffstat 8 files changed, 182 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Mar 10 15:34:55 2015 +0100
+++ b/.hgignore	Tue Mar 10 15:50:03 2015 +0100
@@ -10,5 +10,7 @@
 *.rej
 */.*
 *.swp
+ext-*/
+resources/
 # switch to regexp syntax.
 syntax: regexp
--- a/app.js	Tue Mar 10 15:34:55 2015 +0100
+++ b/app.js	Tue Mar 10 15:50:03 2015 +0100
@@ -27,6 +27,7 @@
     // found on https://github.com/elmasse/Ext.i18n.Bundle
     requires: [
         'Lada.override.Table',
+        'Lada.override.RowEditor',
         'Ext.i18n.Bundle',
         'Ext.layout.container.Column',
         'Lada.store.Datenbasis',
@@ -95,8 +96,6 @@
         Ext.create('Lada.store.Verwaltungseinheiten', {
             storeId: 'verwaltungseinheiten'
         });
-
-
     },
 
     // Define the controllers of the application. They will be initialized
@@ -107,6 +106,6 @@
         'Lada.controller.ProbeForm',
         'Lada.controller.OrtGrid',
         'Lada.controller.ProbenzusatzwertGrid',
-        'Lada.controller.MessungenGrid'
+        'Lada.controller.PKommentarGrid'
     ]
 });
--- a/app/controller/Filter.js	Tue Mar 10 15:34:55 2015 +0100
+++ b/app/controller/Filter.js	Tue Mar 10 15:50:03 2015 +0100
@@ -113,14 +113,14 @@
                 });
             }
             else if (type === 'datetime') {
-                field = Ext.create('Lada.view.widgets.Datetime', {
+                field = Ext.create('Lada.view.widget.Datetime', {
                     name: name,
                     labelWidth: 135,
                     fieldLabel: label
                 });
             }
             else if (type === 'bool') {
-                field = Ext.create('Lada.view.widgets.Testdatensatz', {
+                field = Ext.create('Lada.view.widget.Testdatensatz', {
                     name: name,
                     labelWidth: 135,
                     fieldLabel: label,
@@ -128,7 +128,7 @@
                 });
             }
             else if (type === 'listmst') {
-                field = Ext.create('Lada.view.widgets.Messstelle', {
+                field = Ext.create('Lada.view.widget.Messstelle', {
                     name: name,
                     labelWidth: 135,
                     fieldLabel: label,
@@ -136,7 +136,7 @@
                 });
             }
             else if (type === 'listumw') {
-                field = Ext.create('Lada.view.widgets.Umwelt', {
+                field = Ext.create('Lada.view.widget.Umwelt', {
                     name: name,
                     labelWidth: 135,
                     fieldLabel: label,
@@ -144,7 +144,7 @@
                 });
             }
             else if (type === 'listdbasis') {
-                field = Ext.create('Lada.view.widgets.Datenbasis', {
+                field = Ext.create('Lada.view.widget.Datenbasis', {
                     name: name,
                     labelWidth: 135,
                     fieldLabel: label,
@@ -152,7 +152,7 @@
                 });
             }
             else if (type === 'listver') {
-                field = Ext.create('Lada.view.widgets.Verwaltungseinheit', {
+                field = Ext.create('Lada.view.widget.Verwaltungseinheit', {
                     name: name,
                     labelWidth: 135,
                     fieldLabel: label,
@@ -160,7 +160,7 @@
                 });
             }
             else if (type === 'listnetz') {
-                field = Ext.create('Lada.view.widgets.Netzbetreiber', {
+                field = Ext.create('Lada.view.widget.Netzbetreiber', {
                     name: name,
                     labelWidth: 135,
                     fieldLabel: label,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/PKommentarGrid.js	Tue Mar 10 15:50:03 2015 +0100
@@ -0,0 +1,61 @@
+/* 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.
+ */
+
+Ext.define('Lada.controller.PKommentarGrid', {
+    extend: 'Ext.app.Controller',
+
+    init: function() {
+        this.control({
+            'pkommentargrid': {
+                edit: this.edit
+            },
+            'pkommentargrid button[action=add]': {
+                click: this.add
+            },
+            'pkommentargrid button[action=delete]': {
+                click: this.remove
+            }
+        });
+    },
+
+    edit: function(editor, context) {
+        context.record.save({
+            success: function() {
+                context.grid.store.reload();
+                context.grid.up('window').initData();
+            },
+            failure: function() {
+                // TODO
+            }
+        });
+    },
+
+    add: function(button) {
+        var record = Ext.create('Lada.model.PKommentar');
+        record.set('probeId', button.up('pkommentargrid').recordId);
+        button.up('pkommentargrid').store.insert(0, record);
+        button.up('pkommentargrid').rowEditing.startEdit(0, 1);
+    },
+
+    remove: function(button) {
+        var grid = button.up('grid');
+        var selection = grid.getView().getSelectionModel().getSelection()[0];
+        Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) {
+            if (btn === 'yes') {
+                selection.destroy({
+                    success: function() {
+                        button.up('window').initData();
+                    },
+                    failure: function() {
+                        // TODO
+                    }
+                });
+            }
+        });
+    }
+});
--- a/app/controller/ProbenzusatzwertGrid.js	Tue Mar 10 15:34:55 2015 +0100
+++ b/app/controller/ProbenzusatzwertGrid.js	Tue Mar 10 15:50:03 2015 +0100
@@ -35,8 +35,12 @@
         });
     },
 
-    add: function() {
-        console.log('add');
+    add: function(button) {
+        var record = Ext.create('Lada.model.Zusatzwert', {
+            probeId: button.up('probenzusatzwertgrid').recordId
+        });
+        button.up('probenzusatzwertgrid').store.insert(0, record);
+        button.up('probenzusatzwertgrid').rowEditing.startEdit(0, 1);
     },
 
     remove: function(button) {
@@ -47,8 +51,10 @@
                 selection.destroy({
                     success: function() {
                         button.up('window').initData();
+                        grid.initData();
                     },
                     failure: function() {
+                        // TODO
                     }
                 });
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/override/RowEditor.js	Tue Mar 10 15:50:03 2015 +0100
@@ -0,0 +1,61 @@
+/* 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.
+ */
+
+Ext.define('Lada.override.RowEditor', {
+    override: 'Ext.grid.RowEditor',
+
+    addFieldsForColumn: function(column, initial) {
+        var me = this,
+            i,
+            length, field;
+
+        if (Ext.isArray(column)) {
+            for (i = 0, length = column.length; i < length; i++) {
+                me.addFieldsForColumn(column[i], initial);
+            }
+            return;
+        }
+
+        if (column.getEditor) {
+            // Get a default display field if necessary
+            field = column.getEditor(null, {
+                xtype: 'displayfield',
+                // Override Field's implementation so that the default display fields will not return values. This is done because
+                // the display field will pick up column renderers from the grid.
+                getModelData: function() {
+                    return null;
+                }
+            });
+            if (column.align === 'right') {
+                field.fieldStyle = 'text-align:right';
+            }
+
+            if (column.xtype === 'actioncolumn') {
+                field.fieldCls += ' ' + Ext.baseCSSPrefix + 'form-action-col-field'
+            }
+
+            if (me.isVisible() && me.context) {
+                if (field.is('displayfield')) {
+                    me.renderColumnData(field, me.context.record, column);
+                }
+                else {
+                    field.suspendEvents();
+                    field.setValue(me.context.record.get(column.dataIndex));
+                    field.resumeEvents();
+                }
+            }
+            if (column.hidden) {
+                me.onColumnHide(column);
+            } else if (column.rendered && !initial) {
+                // Setting after initial render
+                me.onColumnShow(column);
+            }
+        }
+        me.mon(field, 'change', me.onFieldChange, me);
+    }
+});
--- a/app/view/grid/PKommentar.js	Tue Mar 10 15:34:55 2015 +0100
+++ b/app/view/grid/PKommentar.js	Tue Mar 10 15:50:03 2015 +0100
@@ -14,12 +14,13 @@
     alias: 'widget.pkommentargrid',
 
     requires: [
-        'Ext.toolbar.Toolbar'
+        'Ext.toolbar.Toolbar',
+        'Lada.store.PKommentare'
     ],
 
     maxHeight: 350,
     emptyText: 'Keine Kommentaregefunden.',
-    minHeight: 65,
+    minHeight: 110,
     viewConfig: {
         deferEmptyText: false
     },
@@ -27,11 +28,11 @@
     recordId: null,
 
     initComponent: function() {
-        var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false
         });
-        this.plugins = [rowEditing];
+        this.plugins = [this.rowEditing];
         this.dockedItems = [{
             xtype: 'toolbar',
             dock: 'bottom',
@@ -49,7 +50,20 @@
         this.columns = [{
             header: 'Erzeuger',
             dataIndex: 'erzeuger',
+            width: 140,
+            renderer: function(value) {
+                if (!value || value === '') {
+                    return '';
+                }
+                var store = Ext.data.StoreManager.get('messstellen');
+                var record = store.getById(value);
+                return record.get('messStelle');
+            },
             editor: {
+                xtype: 'combobox',
+                store: Ext.data.StoreManager.get('messstellen'),
+                displayField: 'messStelle',
+                valueField: 'id',
                 allowBlank: false
             }
         }, {
@@ -65,10 +79,25 @@
             header: 'Text',
             dataIndex: 'text',
             flex: 1,
+            renderer: function(value) {
+                return '<div style="white-space: normal !important;">' +
+                    value + '</div>';
+            },
             editor: {
+                xtype: 'textarea',
                 allowBlank: false
             }
         }];
+        this.initData();
         this.callParent(arguments);
+    },
+
+    initData: function() {
+        this.store = Ext.create('Lada.store.PKommentare');
+        this.store.load({
+            params: {
+                probeId: this.recordId
+            }
+        });
     }
 });
--- a/app/view/grid/Probenzusatzwert.js	Tue Mar 10 15:34:55 2015 +0100
+++ b/app/view/grid/Probenzusatzwert.js	Tue Mar 10 15:50:03 2015 +0100
@@ -27,11 +27,11 @@
     recordId: null,
 
     initComponent: function() {
-        var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false
         });
-        this.plugins = [rowEditing];
+        this.plugins = [this.rowEditing];
         this.dockedItems = [{
             xtype: 'toolbar',
             dock: 'bottom',
@@ -55,6 +55,9 @@
             dataIndex: 'pzsId',
             flex: 1,
             renderer: function(value) {
+                if (!value || value === '') {
+                    return '';
+                }
                 var store = Ext.data.StoreManager.get('probenzusaetze');
                 var record = store.getById(value);
                 return record.get('beschreibung');
@@ -85,6 +88,9 @@
             dataIndex: 'pzsId',
             width: 80,
             renderer: function(value) {
+                if (!value || value === '') {
+                    return '';
+                }
                 var zstore = Ext.data.StoreManager.get('probenzusaetze');
                 var mstore = Ext.data.StoreManager.get('messeinheiten');
                 var mehId = zstore.getById(value).get('mehId');

http://lada.wald.intevation.org