changeset 574:8d2cf853eed2

merged.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 10 Mar 2015 14:33:03 +0100
parents 6a1af698510e (current diff) d9593b520b3b (diff)
children 54dbb6c44ca6
files app.js app/controller/ProbenzusatzwertGrid.js
diffstat 7 files changed, 162 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/MessungenGrid.js	Tue Mar 10 14:33:03 2015 +0100
@@ -0,0 +1,76 @@
+/* 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.
+ */
+
+/*
+ * Controller for a Messungengrid
+ */
+Ext.define('Lada.controller.MessungenGrid', {
+    extend: 'Ext.app.Controller',
+
+    init: function() {
+        this.control({
+            'messungengrid': {
+                selectionchange: this.selectionChanged,
+                edit: this.gridSave
+            },
+            'messungengrid button[action=open]': {
+                click: this.open
+            },
+            'messungengrid button[action=add]': {
+                click: this.add
+            },
+            'messungengrid button[action=delete]': {
+                click: this.remove
+            }
+        });
+    },
+
+    selectionChanged: function(grid, record) {
+        if (record) {
+            grid.view.panel.down('button[action=open]').enable();
+        }
+    },
+
+    gridSave: function(editor, context) {
+        context.record.save({
+            success: function() {
+                context.grid.store.reload();
+                context.grid.up('window').initData();
+            },
+            failure: function() {
+                // TODO
+            }
+        });
+    },
+
+    open: function() {
+        // todo
+        console.log('open');
+    },
+
+    add: function() {
+        // todo
+        console.log('add');
+    },
+
+    remove: function(button) {
+        var grid = button.up('grid');
+        var selection = grid.getView().getSelectionModel().getSelection()[0];
+        Ext.MessageBox.confirm('Messung löschen', 'Sind Sie sicher?', function(btn) {
+            if (btn === 'yes') {
+                selection.destroy({
+                    success: function() {
+                        button.up('window').initData();
+                    },
+                    failure: function() {
+                    }
+                });
+            }
+        });
+    }
+});
--- a/app/controller/OrtGrid.js	Tue Mar 10 14:31:32 2015 +0100
+++ b/app/controller/OrtGrid.js	Tue Mar 10 14:33:03 2015 +0100
@@ -46,17 +46,19 @@
     },
 
     open: function() {
+        // todo
         console.log('open');
     },
 
     add: function() {
+        // todo
         console.log('add');
     },
 
     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) {
+        Ext.MessageBox.confirm('Ortsangabe löschen', 'Sind Sie sicher?', function(btn) {
             if (btn === 'yes') {
                 selection.destroy({
                     success: function() {
--- a/app/controller/ProbenzusatzwertGrid.js	Tue Mar 10 14:31:32 2015 +0100
+++ b/app/controller/ProbenzusatzwertGrid.js	Tue Mar 10 14:33:03 2015 +0100
@@ -46,7 +46,7 @@
     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) {
+        Ext.MessageBox.confirm('Zusatzwert löschen', 'Sind Sie sicher?', function(btn) {
             if (btn === 'yes') {
                 selection.destroy({
                     success: function() {
--- a/app/model/Messung.js	Tue Mar 10 14:31:32 2015 +0100
+++ b/app/model/Messung.js	Tue Mar 10 14:33:03 2015 +0100
@@ -26,9 +26,9 @@
         name: 'messzeitpunkt',
         convert: function(v) {
             if (!v) {
-                return v;
+               return new Date();
             }
-            return new Date();
+            return new Date(v);
         },
         defaultValue: new Date()
     }, {
@@ -39,9 +39,9 @@
         type: 'date',
         convert: function(v) {
             if (!v) {
-                return v;
+                return new Date;
             }
-            return new Date();
+            return new Date(v);
         },
         defaultValue: new Date()
     }, {
--- a/app/model/Messwert.js	Tue Mar 10 14:31:32 2015 +0100
+++ b/app/model/Messwert.js	Tue Mar 10 14:33:03 2015 +0100
@@ -39,9 +39,9 @@
         type: 'date',
         convert: function(v) {
             if (!v) {
-                return v;
+                return new Date();
             }
-            return new Date();
+            return new Date(v);
         },
         defaultValue: new Date()
     }],
@@ -50,7 +50,7 @@
 
     proxy: {
         type: 'rest',
-        url: 'server/rest/messwert',
+        url: 'lada-server/messwert',
         reader: {
             type: 'json',
             root: 'data'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/model/Status.js	Tue Mar 10 14:33:03 2015 +0100
@@ -0,0 +1,37 @@
+/* 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.
+ */
+
+/**
+ * Model class for Status
+ */
+Ext.define('Lada.model.Status', {
+    extend: 'Ext.data.Model',
+
+    fields: [{
+        name: 'id'
+    }, {
+        name: 'messungsId'
+    }, {
+        name: 'status'
+    }, {
+        name: 'sdatum'
+    }, {
+        name: 'skommentar'
+    }],
+
+    idProperty: 'id',
+
+    proxy: {
+        type: 'rest',
+        url: 'lada-server/status',
+        reader: {
+            type: 'json',
+            root: 'data'
+        }
+    }
+});
--- a/app/view/grid/Messungen.js	Tue Mar 10 14:31:32 2015 +0100
+++ b/app/view/grid/Messungen.js	Tue Mar 10 14:33:03 2015 +0100
@@ -45,7 +45,7 @@
                 text: 'Hinzufügen',
                 icon: 'resources/img/list-add.png',
                 action: 'add',
-                probeId: this.recordId
+                probeId: this.probeId
             }, {
                 text: 'Löschen',
                 icon: 'resources/img/list-remove.png',
@@ -60,15 +60,6 @@
                 allowBlank: false
             }
         }, {
-        /*
-            header: 'Probe-ID',
-            dataIndex: 'probeId',
-            flex: 1,
-            editor: {
-                allowBlank: false
-            }
-        }, {
-        */
             header: 'Nebenproben-Nr.',
             dataIndex: 'nebenprobenNr',
             flex: 1,
@@ -94,52 +85,26 @@
                 //minText: 'Das Datum der Messung darf nicht vor dem 01.01.2001 liegen.',
                 maxValue: Ext.Date.format(new Date(), 'd.m.Y')
             }
-        }
-        /*
-         , {
-            header: 'Messdauer',
-            dataIndex: 'messdauer',
-            width: 50,
-            editor: {
-                allowBlank: false
-            }
-        }, {
-            header: 'Geplant',
-            dataIndex: 'geplant',
-            width: 10,
-            editor: {
-                xtype: 'checkboxfield',
-                allowBlank: false
-            }
         }, {
-            header: 'Letzte Änderung',
-            dataIndex: 'letzteAenderung',
-            width: 50,
-            editor: {
-                xtype: 'datefield',
-                allowBlank: false,
-                format: 'd.m.Y',
-                //minValue: '01.01.2001', //todo: gibt es das?
-                //minText: 'Das Datum der letzten Änderung darf nicht vor dem 01.01.2001 liegen.',
-                maxValue: Ext.Date.format(new Date(), 'd.m.Y')
-            }
-        }*/
-        , {
             header: 'Status',
+            flex: 1,
             dataIndex: 'id',
-            flex: 1,
             renderer: function(value) {
-                var sstore = Ext.getStore('Status'); // Es existiert derzeit kein StatusModel. Der Status Store referenziert jedoch darauf.
-                sstore.load({
+//fixme: dezeit existiert nur 1 status daher immer unbekannt
+                this.statusStore.load(
+                {
                     params: {
-                        probeId: value.recordId,
-                        messungsId: value.id
+                        messungsId: value,
                     }
                 });
-                if (sstore.getTotalCount() === 0) {
+
+                if (!this.statusStore){
                     return 'unbekannt';
                 }
-                return sstore.last().get('status');
+                if (this.statusStore.getTotalCount() === 0) {
+                    return 'unbekannt';
+                }
+                return this.statusStore.last().get('status');
             }
         }, {
             header: 'OK-Flag',
@@ -157,29 +122,41 @@
             }
         }, {
             header: 'Anzahl Nuklide',
+            // Gibt die Anzahl der Messwerte wieder,
+            // NICHT die Anzahl der verschiedenen Nukleide
+            // Eventuell ist die Bezeichnug daher irreführend
             flex: 1,
+            dataIndex: 'id',
             renderer: function(value) {
-                var mstore = Ext.getStore('Messwerte');
-                mstore.load({
+//fixme: gibt immer 0 aus
+                this.messwerteStore.load({
                     params: {
-                        probeId: value.recordId,
-                        messungsId: value.id
+                        messungId: value,
                     }
                 });
-                return mstore.getTotalCount();
+
+                if (!this.messwerteStore){
+                    return 'unbekannt';
+                }
+                return this.messwerteStore.getCount();
             }
         }, {
             header: 'Anzahl Kommentare',
             flex: 1,
+            dataIndex: 'id',
             renderer: function(value) {
-                var kstore = Ext.getStore('MKommentare');
-                kstore.load({
+//fixme: gibt immer 0 aus
+               this.mKommentareStore.load({
                     params: {
-                        probeId: value.probeId,
-                        messungsId: value.id
+                        messungsId: value,
                     }
                 });
-                return kstore.getTotalCount();
+
+                if (!this.mKommentareStore){
+                    return 'unbekannt';
+                }
+
+                return this.mKommentareStore.getTotalCount();
             }
         }];
         this.initData();
@@ -188,20 +165,14 @@
 
     initData: function(){
         this.store = Ext.create('Lada.store.Messungen');
+        this.statusStore = Ext.create('Lada.store.Status');
+        this.messwerteStore = Ext.create('Lada.store.Messwerte');
+        this.mKommentareStore = Ext.create('Lada.store.MKommentare');
+
         this.store.load({
             params: {
                 probeId: this.recordId
             }
         });
-    },
-    listeners: {
-        selectionchange: function(model, selected, eOpts) {
-            /*
-            * Enable the 'details' button only when an item is selected
-            */
-            if (selected.length > 0) {
-                this.down('button[action=open]').enable();
-            }
-        }
     }
 });

http://lada.wald.intevation.org