changeset 981:2c394e72ba41 stammdatengrids

Use the lada-server for stammdatenqueries.
author Dustin Demuth <dustin@intevation.de>
date Fri, 04 Dec 2015 15:29:04 +0100
parents 7867752a0d58
children d8b0b23047b1
files app/controller/Filter.js app/store/StammdatenQueries.js app/view/grid/DatensatzErzeuger.js app/view/grid/MessprogrammKategorie.js app/view/grid/Probenehmer.js
diffstat 5 files changed, 52 insertions(+), 137 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Filter.js	Thu Dec 03 10:34:42 2015 +0100
+++ b/app/controller/Filter.js	Fri Dec 04 15:29:04 2015 +0100
@@ -92,25 +92,18 @@
             this.displayFields.reverse();
         }
 
-/// THIS IS INTERMEDIARY CODE AND CAN BE REMOVED WHEN TYPES ARE SENT FOR PROBEN AND MESSPROGRAMME
-        console.log('remove this intermediary code...');
-        var modes = element.up('panel[name=main]').down('radiogroup').getChecked();
-        queryType = (queryType) ? queryType : modes[0].inputValue;
-/// END OF INTERMEDIARY CODE
-
-
-        if (queryType == 'proben' || queryType == 'messprogramme') {
+        if (queryType == 'probe' || queryType == 'messprogramm') {
             // Dynamic Grids
             // We need to set both grid and Store.
             var frgrid; // The Resultgrid
             var gridstore; // The Store which will be used in the resultgrid.
 
             switch (queryType) {
-                case 'proben':
+                case 'probe':
                     gridstore = Ext.create('Lada.store.ProbenList');
                     frgrid = Ext.create('Lada.view.grid.ProbeList');
                     break;
-                case 'messprogramme':
+                case 'messprogramm':
                     gridstore = Ext.create('Lada.store.MessprogrammeList');
                     frgrid = Ext.create('Lada.view.grid.MessprogrammeList');
                     break;
@@ -128,12 +121,18 @@
             // grid
             var resultGrid;
             switch (queryType) {
-                case 'MessprogrammKategorie':
+                case 'messprogrammkategorie':
                     resultGrid = Ext.create('Lada.view.grid.MessprogrammKategorie');
                     break;
-                case 'DatensatzErzeuger':
+                case 'datensatzerzeuger':
                     resultGrid = Ext.create('Lada.view.grid.DatensatzErzeuger');
                     break;
+                case 'ort':
+                    resultGrid = Ext.create('Lada.view.grid.Ort');
+                    break;
+                case 'probenehmer':
+                    resultGrid = Ext.create('Lada.view.grid.Probenehmer');
+                    break;
             }
             if (resultGrid) {
                 contentPanel.add(resultGrid);
@@ -271,28 +270,28 @@
             }
             searchParams[filter.getName()] = value;
         }
-        // Retrieve the mode
-        var modes = element.up('panel[name=main]').down('radiogroup').getChecked();
-        var sname = modes[0].inputValue;
 
-        // Todo: Migragte away from sname, use type instead
-        if (sname === 'proben') {
-            sname = 'Lada.store.ProbenList';
-        }
-        else if (sname === 'messprogramme') {
-            sname = 'Lada.store.MessprogrammeList';
-        }
-        else if (sname === 'stammdaten') {
-            //Store depends of the Type...
-            // TODO the switchcasese should be unified
-            switch (type) {
-                case 'MessprogrammKategorie':
-                    sname = 'Lada.store.MessprogrammKategorie';
-                    break;
-                case 'DatensatzErzeuger':
-                    sname = 'Lada.store.DatensatzErzeuger';
-                    break;
-            }
+        //Store depends of the Type...
+        // TODO the switchcasese should be unified withj those in SelectSql
+        switch (type) {
+            case 'proben':
+                sname = 'Lada.store.ProbenList';
+                break;
+            case 'messprogramm':
+                sname = 'Lada.store.MessprogrammeList';
+                break;
+            case 'messprogrammkategorie':
+                sname = 'Lada.store.MessprogrammKategorie';
+                break;
+            case 'datensatzerzeuger':
+                sname = 'Lada.store.DatensatzErzeuger';
+                break;
+            case 'ort':
+                sname = 'Lada.store.Ort';
+                break;
+            case 'probenehmer':
+                sname = 'Lada.store.Probenehmer';
+                break;
         }
 
         // Find the store or create a new one.
--- a/app/store/StammdatenQueries.js	Thu Dec 03 10:34:42 2015 +0100
+++ b/app/store/StammdatenQueries.js	Fri Dec 04 15:29:04 2015 +0100
@@ -13,13 +13,13 @@
     extend: 'Ext.data.Store',
     model: 'Lada.model.Query',
     autoLoad: true,
-    data: { data: [
+/*    data: { data: [
          {id: '0', name: 'MessprogrammKategorie', type: 'MessprogrammKategorie', sql: 'bogus', description: 'bogusBeschr', filters:  []},
          {id: '1', name: 'DatensatzErzeuger', type: 'DatensatzErzeuger', sql: 'bogus', description: 'bogusBeschr', filters:  []}
-        ]},
+        ]},*/
     proxy: {
-        type: 'memory',
-        //url: 'lada-server/query/stammdaten',
+        type: 'rest',
+        url: 'lada-server/query/stammdaten',
         reader: {
             type: 'json',
             root: 'data'
--- a/app/view/grid/DatensatzErzeuger.js	Thu Dec 03 10:34:42 2015 +0100
+++ b/app/view/grid/DatensatzErzeuger.js	Fri Dec 04 15:29:04 2015 +0100
@@ -24,6 +24,7 @@
     errors: null,
     readOnly: true,
     allowDeselect: true,
+    border: false,
 
     initComponent: function() {
         var i18n = Lada.getApplication().bundle;
--- a/app/view/grid/MessprogrammKategorie.js	Thu Dec 03 10:34:42 2015 +0100
+++ b/app/view/grid/MessprogrammKategorie.js	Fri Dec 04 15:29:04 2015 +0100
@@ -24,6 +24,7 @@
     errors: null,
     readOnly: true,
     allowDeselect: true,
+    border: false,
 
     initComponent: function() {
         var i18n = Lada.getApplication().bundle;
--- a/app/view/grid/Probenehmer.js	Thu Dec 03 10:34:42 2015 +0100
+++ b/app/view/grid/Probenehmer.js	Fri Dec 04 15:29:04 2015 +0100
@@ -24,6 +24,7 @@
     errors: null,
     readOnly: true,
     allowDeselect: true,
+    border: false,
 
     initComponent: function() {
         var i18n = Lada.getApplication().bundle;
@@ -38,46 +39,7 @@
                 id: 'tbtitle',
                 text: i18n.getMsg('pn.gridTitle')
             }]
-        /*
-            //bottom toolbar?
-            }, {
-            xtype: 'toolbar',
-            dock: 'bottom',
-            items: ['->', {
-                text: 'Hinzufügen',
-                icon: 'resources/img/list-add.png',
-                action: 'add',
-                probeId: this.probeId
-            }, {
-                text: 'Löschen',
-                icon: 'resources/img/list-remove.png',
-                action: 'delete'
-            }]
-        */
         }];
-     /*
-     // Do we have row-editing
-        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.columns = [{
             header: i18n.getMsg('netzbetreiberId'),
             dataIndex: 'netzbetreiberId',
@@ -174,72 +136,24 @@
                 scope: this
             }
         };
-        // this.initData(); //This will be called by the Query Component.
         this.callParent(arguments);
-        //TODO this.setReadOnly(true); //Grid is always initialised as RO
-    },
-
-    initData: function() {
-        this.store = Ext.create('Lada.store.DatensatzErzeuger');
-        this.store.load(); //TODO: Params?
     },
 
-    setReadOnly: function(b) {
-        if (b == true){
-            //Readonly
-            if (this.getPlugin('rowedit')){
-                this.getPlugin('rowedit').disable();
-            }
-            try {
-                this.down('button[action=delete]').disable();
-                this.down('button[action=add]').disable();
-            }
-            catch(e) {
-                //TODO: Do Nothing...
-            }
-        }else{
-            //Writable
-            if (this.getPlugin('rowedit')){
-                this.getPlugin('rowedit').enable();
-            }
-            try {
-                this.down('button[action=delete]').enable();
-                this.down('button[action=add]').enable();
-            }
-            catch(e) {
-                //TODO: Do Nothing...
-            }
-        }
-    },
     /**
-     * Activate the Remove Button
+     * This sets the Store of this Grid
      */
-    activateRemoveButton: function(selection, record) {
-        var grid = this;
-        //only enable the remove buttone, when the grid is editable.
-        if (! grid.readOnly) {
-            try {
-                grid.down('button[action=delete]').enable();
-            }
-            catch(e) {
-                //TODO: Do Nothing
-            }
-        }
-    },
-    /**
-     * deactivate the Remove Button
-     */
-    deactivateRemoveButton: function(selection, record) {
-        var grid = this;
-        //only enable the remove buttone, when the grid is editable.
-        if (! grid.readOnly) {
-            try {
-                grid.down('button[action=delete]').disable();
-            }
-            catch(e) {
-                //TODO: Do Nothing
-            }
-        }
+    setStore: function(store){
+        var i18n = Lada.getApplication().bundle;
+
+        this.removeDocked(Ext.getCmp('ptbar'), true);
+        this.reconfigure(store);
+        this.addDocked([{
+            xtype: 'pagingtoolbar',
+            id: 'ptbar',
+            dock: 'bottom',
+            store: store,
+            displayInfo: true
+        }]);
     }
 });
 

http://lada.wald.intevation.org