changeset 574:8d2cf853eed2

merged.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 10 Mar 2015 14:33:03 +0100
parents 6a1af698510e (diff) d9593b520b3b (current diff)
children 54dbb6c44ca6
files app.js app/controller/ProbenzusatzwertGrid.js
diffstat 6 files changed, 173 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Tue Mar 10 11:58:07 2015 +0100
+++ b/app.js	Tue Mar 10 14:33: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'
     ]
 });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/PKommentarGrid.js	Tue Mar 10 14:33: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 11:58:07 2015 +0100
+++ b/app/controller/ProbenzusatzwertGrid.js	Tue Mar 10 14:33: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 14:33: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 11:58:07 2015 +0100
+++ b/app/view/grid/PKommentar.js	Tue Mar 10 14:33: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 11:58:07 2015 +0100
+++ b/app/view/grid/Probenzusatzwert.js	Tue Mar 10 14:33: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