changeset 1113:566976d72ce5

merged.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 17 May 2016 17:13:02 +0200
parents e76551a6da27 (diff) 7baaf2cd3f57 (current diff)
children 66d4b392bc5f
files app.js app/controller/Filter.js
diffstat 15 files changed, 300 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Fri May 13 14:24:07 2016 +0200
+++ b/app.js	Tue May 17 17:13:02 2016 +0200
@@ -29,6 +29,8 @@
         'Lada.override.RowEditor',
         'Lada.override.i18n.DE',
         'Lada.override.JSON',
+        'Lada.override.RowExpander',
+        'Lada.view.plugin.GridRowExpander',
         'Ext.i18n.Bundle',
         'Ext.layout.container.Column',
         'Lada.store.Deskriptoren',
--- a/app/controller/Filter.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/controller/Filter.js	Tue May 17 17:13:02 2016 +0200
@@ -126,11 +126,27 @@
             switch (queryType) {
                 case 'probe':
                     gridstore = Ext.create('Lada.store.ProbenList');
-                    frgrid = Ext.create('Lada.view.grid.ProbeList');
+                    frgrid = Ext.create('Lada.view.grid.ProbeList', {
+                        plugins: [{
+                            ptype: 'gridrowexpander',
+                            gridType: 'Lada.view.grid.Messung',
+                            gridConfig: {
+                                bottomBar: false
+                            }
+                        }]
+                    });
                     break;
                 case 'messung':
                     gridstore = Ext.create('Lada.store.MessungenList');
-                    frgrid = Ext.create('Lada.view.grid.MessungList');
+                    frgrid = Ext.create('Lada.view.grid.MessungList', {
+                        plugins: [{
+                            ptype: 'gridrowexpander',
+                            gridType: 'Lada.view.grid.Messwert',
+                            gridConfig: {
+                                bottomBar: false
+                            }
+                        }]
+                    });
                     break;
                 case 'messprogramm':
                     gridstore = Ext.create('Lada.store.MessprogrammeList');
--- a/app/controller/grid/Messung.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/controller/grid/Messung.js	Tue May 17 17:13:02 2016 +0200
@@ -39,30 +39,68 @@
      * Window.
      */
     editItem: function(grid, record) {
-        var probe = grid.up('window').record;
-        /* Only open a new Window when:
-           statusEdit = True
-           -or-
-           the value of status is not 0
-           -or-
-           the owner = True
+        // we have a window with a probe record!
+        if (grid.up('window')) {
+            var probe = grid.up('window').record;
+            /* Only open a new Window when:
+               statusEdit = True
+               -or-
+               the value of status is not 0
+               -or-
+               the owner = True
 
-           the statusWert attribute is not present in the original data.
-           it is appended, when the value and name of the status were
-           determined.
-        */
-        if (record.get('statusEdit')
-            || record.get('statusWert') > 0
-            || record.get('owner')) {
-            var win = Ext.create('Lada.view.window.MessungEdit', {
-                parentWindow: grid.up('window'),
-                probe: probe,
-                record: record,
-                grid: grid
-            });
-            win.show();
-            win.initData();
+               the statusWert attribute is not present in the original data.
+               it is appended, when the value and name of the status were
+               determined.
+            */
+            if (record.get('statusEdit')
+                || record.get('statusWert') > 0
+                || record.get('owner')) {
+                var win = Ext.create('Lada.view.window.MessungEdit', {
+                    parentWindow: grid.up('window'),
+                    probe: probe,
+                    record: record,
+                    grid: grid
+                });
+                win.show();
+                win.initData();
+            }
+            return;
         }
+        var probeRecord = Ext.create('Lada.model.ProbeList');
+        probeRecord.setId(record.get('probeId'));
+        probeRecord.set('owner', record.get('owner'));
+        probeRecord.set('readonly', record.get('readonly'));
+
+        var probeWin = Ext.create('Lada.view.window.ProbeEdit', {
+            record: probeRecord,
+            style: 'z-index: -1;' //Fixes an Issue where windows could not be created in IE8
+        });
+
+        probeWin.setPosition(30);
+        probeWin.show();
+        probeWin.initData();
+
+        Ext.ClassManager.get('Lada.model.Probe').load(record.get('probeId'), {
+            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(precord, response) {
+                var messungWin = Ext.create('Lada.view.window.MessungEdit', {
+                    parentWindow: grid.up('window'),
+                    probe: precord,
+                    record: record,
+                    grid: grid
+                });
+                messungWin.show();
+                messungWin.setPosition(window.innerWidth - 30 - messungWin.width);
+                messungWin.initData();
+            }
+        });
     },
 
     /**
--- a/app/controller/grid/ProbeList.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/controller/grid/ProbeList.js	Tue May 17 17:13:02 2016 +0200
@@ -37,6 +37,10 @@
             },
             'probelistgrid toolbar button[action=print]': {
                 click: this.printSelection
+            },
+            'probelistgrid gridview': {
+                expandbody: this.expandBody,
+                collapsebody: this.collapseBody
             }
         });
         this.callParent(arguments);
@@ -338,5 +342,21 @@
         if (btn === 'yes') {
             location.reload();
         }
+    },
+
+    expandBody: function(rowNode, record, expandRow) {
+//        var row = Ext.get('probe-row-' + record.get('id'));
+//        var messungGrid = Ext.create('Lada.view.grid.Messung', {
+//            recordId: record.get('id'),
+//            bottomBar: false,
+//            rowLines: true
+//        });
+//        row.swallowEvent(['click', 'mousedown', 'mouseup', 'dblclick'], true);
+//        messungGrid.render(row);
+    },
+
+    collapseBody: function(rowNode, record, expandRow) {
+//        var element = Ext.get('probe-row-' + record.get('id')).down('div');
+//        element.destroy();
     }
 });
--- a/app/model/ProbeList.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/model/ProbeList.js	Tue May 17 17:13:02 2016 +0200
@@ -14,6 +14,9 @@
     extend: 'Ext.data.Model',
 
     fields: [{
+        name: 'pid',
+        mapping: 'id'
+    }, {
         name: 'readonly'
     }, {
         name: 'owner'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/override/RowExpander.js	Tue May 17 17:13:02 2016 +0200
@@ -0,0 +1,18 @@
+/* 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.RowExpander', {
+    override: 'Ext.grid.plugin.RowExpander',
+    beforeReconfigure: function (grid, store, columns, oldStore, oldColumns) {
+        var expander = this.getHeaderConfig();
+        expander.locked = true;
+        if (columns) {
+            columns.unshift(expander);
+        }
+    }
+});
--- a/app/view/grid/Messung.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/view/grid/Messung.js	Tue May 17 17:13:02 2016 +0200
@@ -26,6 +26,7 @@
     warnings: null,
     errors: null,
     readOnly: true,
+    bottomBar: true,
     allowDeselect: true,
 
     initComponent: function() {
@@ -159,6 +160,9 @@
         };
         this.initData();
         this.callParent(arguments);
+        if (!this.bottomBar) {
+            this.down('toolbar[dock=bottom]').hide();
+        }
         this.setReadOnly(true); //Grid is always initialised as RO
     },
 
--- a/app/view/grid/MessungList.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/view/grid/MessungList.js	Tue May 17 17:13:02 2016 +0200
@@ -17,7 +17,8 @@
         var i18n = Lada.getApplication().bundle;
         this.emptyText = i18n.getMsg('messung.emptyGrid');
         this.selModel = Ext.create('Ext.selection.CheckboxModel', {
-            checkOnly: true
+            checkOnly: true,
+            injectCheckbox: 1
         });
 
         this.dockedItems = [{
@@ -35,7 +36,7 @@
                 disabled: true //disabled on start, enabled by the controller
             }, {
                 text: i18n.getMsg('statusSetzen'),
-                icon: 'resources/img/emblem-important.png',
+                icon: 'resources/img/mail-mark-notjunk.png',
                 action: 'setstatus',
                 disabled: true //disabled on start, enabled by the controller
             }]
--- a/app/view/grid/Messwert.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/view/grid/Messwert.js	Tue May 17 17:13:02 2016 +0200
@@ -30,6 +30,7 @@
     readOnly: true,
     allowDeselect: true,
     messgroesseStore: null,
+    bottomBar: true,
 
     initComponent: function() {
         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
@@ -42,6 +43,12 @@
                 // Normally this would belong into a controller an not the view.
                 // But the RowEditPlugin is not handled there.
                 beforeedit: function(e, o) {
+                    // We are not in a messung window!
+                    if (!o.grid.up('window')) {
+                        return false;
+                    }
+                    // We are in a messung window and should check if we can
+                    // edit.
                     var readonlywin = o.grid.up('window').record.get('readonly');
                     var readonlygrid = o.record.get('readonly');
                     if (readonlywin == true || readonlygrid == true || this.disabled)  {
@@ -186,6 +193,9 @@
         this.initData();
         this.callParent(arguments);
         this.setReadOnly(true); //Grid is always initialised as RO
+        if (!me.bottomBar) {
+            this.down('toolbar[dock=bottom]').hide();
+        }
     },
 
     initData: function() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/plugin/GridRowExpander.js	Tue May 17 17:13:02 2016 +0200
@@ -0,0 +1,147 @@
+Ext.define('Lada.view.plugin.GridRowExpander', {
+    extend: 'Ext.grid.plugin.RowExpander',
+    alias: 'plugin.gridrowexpander',
+
+    rowBodyTpl: '&nbsp;',
+    loadingMessage: '<div class="x-grid-rowbody-loading">Loading...</div>',
+    type: null,
+    gridConfig: null,
+
+    constructor: function(config) {
+        var me = this;
+        var tpl = config.rowBodyTpl || me.rowBodyTpl;
+        var cmps;
+        me.type = config.gridType;
+        me.gridConfig = config.gridConfig;
+
+        me.callParent(arguments);
+
+        cmps = me.cmps = new Ext.util.MixedCollection(null, function(o) {
+            return o.recordId;
+        });
+
+        cmps.on('remove', me.onCmpRemove, me);
+
+        me.rowBodyTpl = new Ext.XTemplate(tpl);
+    },
+
+    init: function(grid) {
+        var me = this;
+        var view = grid.getView();
+        view.processUIEvent = me.createProcessUIEvent(view.processUIEvent);
+
+        me.callParent(arguments);
+    },
+
+    destroy: function() {
+        var cmps = this.cmps;
+        cmps.removeAll();
+
+        this.callParent();
+    },
+
+    onCmpRemove: function(cmp) {
+        cmp.destroy();
+    },
+
+    createProcessUIEvent: function(oldFn) {
+        var grid = this.getCmp();
+        return function(e) {
+            var me = this;
+            var item = e.getTarget(me.dataRowSelector || me.itemSelector,
+                me.getTargetEl());
+            var row;
+            var eGrid;
+
+            row = Ext.fly(item);
+
+            if (row) {
+                eGrid = row.up('.x-grid'); // grid el of UI event
+            }
+            if (eGrid && eGrid.id !== grid.el.id) {
+                if (e.type !== 'contextmenu' && e.type !== 'keydown') {
+                    e.stopEvent();
+                }
+
+                return null;
+            }
+
+            return oldFn.apply(me, arguments);
+        };
+    },
+
+    toggleRow: function(rowIdx) {
+        var me = this;
+        var rowNode = me.view.getNode(rowIdx);
+        var row = Ext.get(rowNode);
+        var nextBd = Ext.get(row).down(this.rowBodyTrSelector);
+        var expandDiv = nextBd.down('div.x-grid-rowbody');
+        var record = me.view.getRecord(rowNode);
+
+        if (row.hasCls(me.rowCollapsedCls)) {
+            row.removeCls(me.rowCollapsedCls);
+            nextBd.removeCls(me.rowBodyHiddenCls);
+            me.recordsExpanded[record.internalId] = true;
+
+            me.showCmp(expandDiv, record);
+            me.view.fireEvent('expandbody', rowNode, record, nextBd.dom);
+        }
+        else {
+            row.addCls(me.rowCollapsedCls);
+            nextBd.addCls(me.rowBodyHiddenCls);
+            me.recordsExpanded[record.internalId] = false;
+
+            me.collapseCmp(expandDiv, record);
+            me.view.fireEvent('collapsebody', rowNode, record, nextBd.dom);
+        }
+    },
+
+    createCmp: function(record, id, config) {
+        var me = this;
+
+        var gridConfig = config.gridConfig;
+        Ext.apply(gridConfig, {
+            recordId: record.get('id'),
+            cls: 'row-expander-grid'
+        });
+        var grid = Ext.create(me.type, gridConfig);
+
+        return grid;
+    },
+
+    showCmp: function(row, record) {
+        var me = this;
+        var cmps = me.cmps;
+        var id = record.getObservableId();
+        var idx = cmps.findIndex('recordId', id);
+        var cmp = cmps.getAt(idx);
+        var gridConfig = me.gridConfig;
+
+        if (!cmp) {
+            row.update(me.loadingMessage);
+
+            cmp = me.cmps.add(me.createCmp(record, id, {
+                gridConfig: gridConfig
+            }));
+        }
+        row.update('');
+        cmp.render(row);
+    },
+
+    getInnerCmp: function(record) {
+        return this.cmps.getByKey(
+            record.getObservableId()
+        );
+    },
+
+    collapseCmp: function(row, record) {
+        var me = this;
+        var cmps = me.cmps;
+        var id = record.getObservableId();
+        var idx = cmps.findIndex('recordId', id);
+        var cmp = cmps.getAt(idx);
+
+        cmps.remove(cmp);
+        cmp.destroy();
+    }
+});
--- a/app/view/widget/DynamicGrid.js	Fri May 13 14:24:07 2016 +0200
+++ b/app/view/widget/DynamicGrid.js	Tue May 17 17:13:02 2016 +0200
@@ -83,6 +83,9 @@
         fields.push(new Ext.data.Field({
             name: 'statusEdit'
         }));
+        fields.push(new Ext.data.Field({
+            name: 'id'
+        }));
 
         resultColumns.push({
             xtype: 'actioncolumn',
--- a/resources/css/lada.css	Fri May 13 14:24:07 2016 +0200
+++ b/resources/css/lada.css	Tue May 17 17:13:02 2016 +0200
@@ -73,3 +73,15 @@
 ::-ms-reveal {
    display: none;
 }
+
+.row-expander-grid .x-grid-row-selected .x-grid-td {
+    background-color : #c6c6c6;
+}
+
+.row-expander-grid .x-grid-row-over .x-grid-td {
+    background-color : #e0e0e0;
+}
+
+.row-expander-grid .x-grid-with-row-lines .x-grid-td {
+    border-bottom: 1px solid #e0e0e0;
+}
Binary file resources/img/mail-mark-notjunk.png has changed
Binary file resources/img/view-time-schedule-baselined-status.png has changed
Binary file resources/img/view-time-schedule-edit-status.png has changed

http://lada.wald.intevation.org