[Lada-commits] [PATCH] Introduced Orte into Stammdatengrids, Added Ortszuordnung. THIS COMMIT IS WORK IN PROGRESS, Proben will NOT work after this commit. Orte can not be edited

Wald Commits scm-commit at wald.intevation.org
Wed Jan 20 12:32:56 CET 2016


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1453289562 -3600
# Branch stammdatengrids
# Node ID 9ac03f461ab441e0b4724daa95969aebf16693d5
# Parent  15d8c64049d1c064640260f4228f0f437ff8aceb
Introduced Orte into Stammdatengrids, Added Ortszuordnung. THIS COMMIT IS WORK IN PROGRESS, Proben will NOT work after this commit. Orte can not be edited.

diff -r 15d8c64049d1 -r 9ac03f461ab4 app.js
--- a/app.js	Fri Jan 15 14:42:29 2016 +0100
+++ b/app.js	Wed Jan 20 12:32:42 2016 +0100
@@ -36,7 +36,7 @@
         'Lada.store.Messmethoden',
         'Lada.store.Messstellen',
         'Lada.store.Netzbetreiber',
-        'Lada.store.Locations',
+        'Lada.store.Orte',
         'Lada.store.Pflichtmessgroessen',
         'Lada.store.Probenarten',
         'Lada.store.Probenzusaetze',
@@ -135,8 +135,8 @@
         Ext.create('Lada.store.Netzbetreiber', {
             storeId: 'netzbetreiber'
         });
-        Ext.create('Lada.store.Locations', {
-            storeId: 'locations'
+        Ext.create('Lada.store.Orte', {
+            storeId: 'orte'
         });
         Ext.create('Lada.store.Pflichtmessgroessen', {
             storeId: 'pflichtmessgroessen'
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/controller/Filter.js
--- a/app/controller/Filter.js	Fri Jan 15 14:42:29 2016 +0100
+++ b/app/controller/Filter.js	Wed Jan 20 12:32:42 2016 +0100
@@ -128,7 +128,7 @@
                     resultGrid = Ext.create('Lada.view.grid.DatensatzErzeuger');
                     break;
                 case 'ort':
-                    resultGrid = Ext.create('Lada.view.grid.Ort');
+                    resultGrid = Ext.create('Lada.view.grid.Orte');
                     break;
                 case 'probenehmer':
                     resultGrid = Ext.create('Lada.view.grid.Probenehmer');
@@ -287,7 +287,7 @@
                 sname = 'Lada.store.DatensatzErzeuger';
                 break;
             case 'ort':
-                sname = 'Lada.store.Ort';
+                sname = 'Lada.store.Orte';
                 break;
             case 'probenehmer':
                 sname = 'Lada.store.Probenehmer';
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/model/Location.js
--- a/app/model/Location.js	Fri Jan 15 14:42:29 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/* 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 Ort Stammdaten
- */
-Ext.define('Lada.model.Location', {
-    extend: 'Ext.data.Model',
-
-    fields: [{
-        name: 'id'
-    }, {
-        name: 'bezeichnung'
-    }, {
-        name: 'beschreibung'
-    }, {
-        name: 'unscharf'
-    }, {
-        name: 'nutsCode'
-    }, {
-        name: 'koordXExtern'
-    }, {
-        name: 'koordYExtern'
-    }, {
-        name: 'hoeheLand'
-    }, {
-        name: 'letzteAenderung',
-        type: 'date',
-        convert: function(v) {
-            if (!v) {
-                return v;
-            }
-            return new Date(v);
-        }
-    }, {
-        name: 'longitude',
-        type: 'float'
-    }, {
-        name: 'latitude',
-        type: 'float'
-    }, {
-        name: 'staatId'
-    }, {
-        name: 'verwaltungseinheitId'
-    }, {
-        name: 'otyp'
-    }],
-
-    idProperty: 'id',
-
-    proxy: {
-        type: 'rest',
-        url: 'lada-server/rest/location',
-        reader: {
-            type: 'json',
-            root: 'data'
-        }
-    }
-});
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/model/Ort.js
--- a/app/model/Ort.js	Fri Jan 15 14:42:29 2016 +0100
+++ b/app/model/Ort.js	Wed Jan 20 12:32:42 2016 +0100
@@ -7,7 +7,7 @@
  */
 
 /**
- * Model class for Ort
+ * Model class for Ort Stammdaten
  */
 Ext.define('Lada.model.Ort', {
     extend: 'Ext.data.Model',
@@ -15,20 +15,55 @@
     fields: [{
         name: 'id'
     }, {
-        name: 'owner',
-        type: 'boolean'
+        name: 'aktiv'
     }, {
-        name: 'readonly',
-        type: 'boolean',
-        persist: false
+        name: 'ortId'
     }, {
-        name: 'ort'
+        name: 'nutsCode'
     }, {
-        name: 'probeId'
+        name: 'anlageId'
     }, {
-        name: 'ortsTyp'
+        name: 'netzbetreiberId'
     }, {
-        name: 'ortszusatztext'
+        name: 'gemId'
+    }, {
+        name: 'staatId'
+    }, {
+        name: 'kdaId'
+    }, {
+        name: 'ozId'
+    }, {
+        name: 'ortTyp'
+    }, {
+        name: 'mpArt'
+    }, {
+        name: 'zone'
+    }, {
+        name: 'sektor'
+    }, {
+        name: 'zustaendigkeit'
+    }, {
+        name: 'berichtstext'
+    }, {
+        name: 'kurztext'
+    }, {
+        name: 'langtext'
+    }, {
+        name: 'beschreibung'
+    }, {
+        name: 'unscharf'
+    }, {
+        name: 'hoeheLand'
+    }, {
+        name: 'koordXExtern'
+    }, {
+        name: 'koordYExtern'
+    }, {
+        name: 'longitude',
+        type: 'float'
+    }, {
+        name: 'latitude',
+        type: 'float'
     }, {
         name: 'letzteAenderung',
         type: 'date',
@@ -38,22 +73,6 @@
             }
             return new Date(v);
         }
-    }, {
-        name: 'treeModified',
-        serialize: function(value) {
-            if (value === '') {
-                return null;
-            }
-            return value;
-        }
-    }, {
-        name: 'parentModified',
-        serialize: function(value) {
-            if (value === '') {
-                return null;
-            }
-            return value;
-        }
     }],
 
     idProperty: 'id',
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/model/Ortszuordnung.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/model/Ortszuordnung.js	Wed Jan 20 12:32:42 2016 +0100
@@ -0,0 +1,69 @@
+/* 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 Ortszuorndung
+ */
+Ext.define('Lada.model.Ortszuordnung', {
+    extend: 'Ext.data.Model',
+
+    fields: [{
+        name: 'id'
+    }, {
+        name: 'owner',
+        type: 'boolean'
+    }, {
+        name: 'readonly',
+        type: 'boolean',
+        persist: false
+    }, {
+        name: 'ortId'
+    }, {
+        name: 'probeId'
+    }, {
+        name: 'ortszuordnungTyp'
+    }, {
+        name: 'ortszusatztext'
+    }, {
+        name: 'letzteAenderung',
+        type: 'date',
+        convert: function(v) {
+            if (!v) {
+                return v;
+            }
+            return new Date(v);
+        }
+    }, {
+        name: 'treeModified',
+        serialize: function(value) {
+            if (value === '') {
+                return null;
+            }
+            return value;
+        }
+    }, {
+        name: 'parentModified',
+        serialize: function(value) {
+            if (value === '') {
+                return null;
+            }
+            return value;
+        }
+    }],
+
+    idProperty: 'id',
+
+    proxy: {
+        type: 'rest',
+        url: 'lada-server/rest/ortszuordnung',
+        reader: {
+            type: 'json',
+            root: 'data'
+        }
+    }
+});
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/model/Verwaltungseinheit.js
--- a/app/model/Verwaltungseinheit.js	Fri Jan 15 14:42:29 2016 +0100
+++ b/app/model/Verwaltungseinheit.js	Wed Jan 20 12:32:42 2016 +0100
@@ -15,14 +15,12 @@
     /**
      * Fields are:
      *  - id: The unique identifer (Primary key)
-     *  - beschreibung: The long description.
-     *  - umweltBereich:
-     *  - mehId:
+     *  - bezeichnung: The long description.
      */
     fields: [{
         name: 'id'
     }, {
-        name: 'bundeland'
+        name: 'bundesland'
     }, {
         name: 'kdaId'
     }, {
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/store/Locations.js
--- a/app/store/Locations.js	Fri Jan 15 14:42:29 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/* 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.
- */
-
-/**
- * Store for Ortedetails
- */
-Ext.define('Lada.store.Locations', {
-    extend: 'Ext.data.Store',
-    model: 'Lada.model.Location',
-    sorters: [{
-        property: 'bezeichnung'
-    }],
-    autoLoad: true
-});
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/store/Orte.js
--- a/app/store/Orte.js	Fri Jan 15 14:42:29 2016 +0100
+++ b/app/store/Orte.js	Wed Jan 20 12:32:42 2016 +0100
@@ -3,13 +3,17 @@
  *
  * 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. 
+ * the documentation coming with IMIS-Labordaten-Application for details.
  */
 
 /**
- * Store for Orte
+ * Store for Orte details
  */
 Ext.define('Lada.store.Orte', {
     extend: 'Ext.data.Store',
-    model: 'Lada.model.Ort'
+    model: 'Lada.model.Ort',
+    sorters: [{
+        property: 'bezeichnung'
+    }],
+    autoLoad: true
 });
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/store/Ortszuordnung.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/store/Ortszuordnung.js	Wed Jan 20 12:32:42 2016 +0100
@@ -0,0 +1,15 @@
+/* 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. 
+ */
+
+/**
+ * Store for Ortszuordnungen
+ */
+Ext.define('Lada.store.Ortszuordnung', {
+    extend: 'Ext.data.Store',
+    model: 'Lada.model.Ortszuordnung
+});
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/view/grid/Ort.js
--- a/app/view/grid/Ort.js	Fri Jan 15 14:42:29 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-/* 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.
- */
-
-/**
- * Grid to list Orte
- */
-Ext.define('Lada.view.grid.Ort', {
-    extend: 'Ext.grid.Panel',
-    alias: 'widget.ortgrid',
-
-    maxHeight: 350,
-    emptyText: 'Keine Orte gefunden.',
-        // minHeight and deferEmptyText are needed to be able to show the
-        // emptyText message.
-    minHeight: 110,
-    viewConfig: {
-        deferEmptyText: false
-    },
-    margin: '0, 5, 5, 5',
-
-    recordId: null,
-
-    warnings: null,
-    errors: null,
-    readOnly: true,
-    allowDeselect: true,
-
-    initComponent: function() {
-        this.dockedItems = [{
-            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'
-            }]
-        }];
-        this.columns = [{
-            header: 'Typ',
-            dataIndex: 'ortsTyp',
-            width: 50,
-            editor: {
-                allowBlank: false
-            }
-        }, {
-            header: 'Staat',
-            dataIndex: 'ort',
-            width: 70,
-            renderer: function(value) {
-                var store = Ext.data.StoreManager.get('locations');
-                var staaten = Ext.data.StoreManager.get('staaten');
-                var record =
-                    staaten.getById(store.getById(value).get('staatId'));
-                return record.get('staatIso');
-            }
-        }, {
-            header: 'Gemeineschlüssel',
-            dataIndex: 'ort',
-            width: 120,
-            renderer: function(value) {
-                var store = Ext.data.StoreManager.get('locations');
-                var record = store.getById(value);
-                return record.get('verwaltungseinheitId');
-            }
-        }, {
-            header: 'Gemeindename',
-            dataIndex: 'ort',
-            flex: 1,
-            renderer: function(value) {
-                var store = Ext.data.StoreManager.get('locations');
-                var gemeinden =
-                    Ext.data.StoreManager.get('verwaltungseinheiten');
-                var record = store.getById(value);
-                var gemid = record.get('verwaltungseinheitId');
-                var record2 = gemeinden.getById(gemid);
-                return record2.get('bezeichnung');
-            }
-        }, {
-            header: 'Messpunkt',
-            dataIndex: 'ort',
-            renderer: function(value) {
-                var store = Ext.getStore('locations');
-                var record = store.getById(value);
-                return record.get('bezeichnung');
-            }
-        }];
-        this.listeners = {
-           select: {
-               fn: this.activateRemoveButton,
-               scope: this
-            },
-            deselect: {
-                fn: this.deactivateRemoveButton,
-                scope: this
-            }
-        };
-        this.initData();
-        this.callParent(arguments);
-        this.setReadOnly(true); //Grid is always initialised as RO
-    },
-
-    initData: function() {
-        this.store = Ext.create('Lada.store.Orte');
-        this.store.load({
-            params: {
-                probeId: this.recordId
-            }
-        });
-        Ext.ClassManager.get('Lada.model.Probe').load(this.recordId, {
-            failure: function(record, action) {
-                // TODO
-            },
-            success: function(record, response) {
-                var json = Ext.decode(response.response.responseText);
-                if (json) {
-                    this.warnings = json.warnings;
-                    this.errors = json.errors;
-                }
-            },
-            scope: this
-        });
-    },
-
-    setReadOnly: function(b) {
-        if (b == true){
-            //Readonly
-            if (this.getPlugin('rowedit')){
-                this.getPlugin('rowedit').disable();
-            }
-            this.down('button[action=delete]').disable();
-            this.down('button[action=add]').disable();
-        }else{
-            //Writable
-            if (this.getPlugin('rowedit')){
-                this.getPlugin('rowedit').enable();
-            }
-            //this.down('button[action=delete]').enable();
-            this.down('button[action=add]').enable();
-        }
-    },
-    /**
-     * Activate the Remove Button
-     */
-    activateRemoveButton: function(selection, record) {
-        var grid = this;
-        //only enable the remove buttone, when the grid is editable.
-        if (! grid.readOnly) {
-            grid.down('button[action=delete]').enable();
-        }
-    },
-    /**
-     * Activate the Remove Button
-     */
-    deactivateRemoveButton: function(selection, record) {
-        var grid = this;
-        //only enable the remove buttone, when the grid is editable.
-        if (! grid.readOnly) {
-            grid.down('button[action=delete]').disable();
-        }
-    }
-});
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/view/grid/Orte.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/grid/Orte.js	Wed Jan 20 12:32:42 2016 +0100
@@ -0,0 +1,179 @@
+/* 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.
+ */
+
+/**
+ * Grid to list Orte Stammdaten
+ */
+Ext.define('Lada.view.grid.Orte', {
+    extend: 'Ext.grid.Panel',
+    alias: 'widget.ortstammdatengrid',
+
+    // minHeight and deferEmptyText are needed to be able to show the
+    // emptyText message.
+    minHeight: 110,
+    viewConfig: {
+        deferEmptyText: false
+    },
+
+    recordId: null,
+
+    warnings: null,
+    errors: null,
+    readOnly: true,
+    allowDeselect: true,
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.emptyText = i18n.getMsg('orte.emptyGrid');
+
+        this.dockedItems = [{
+            xtype: 'toolbar',
+            dock: 'top',
+            items: [{
+                xtype: 'tbtext',
+                id: 'tbtitle',
+                text: i18n.getMsg('orte.gridTitle')
+            },
+            '->',
+            {
+                text: i18n.getMsg('orte.button.add'),
+                icon: 'resources/img/list-add.png',
+                action: 'add',
+                disabled: true // disabled on startup, will be enabled by setStore
+            }, {
+                text: i18n.getMsg('orte.button.delete'),
+                icon: 'resources/img/list-remove.png',
+                action: 'delete',
+                disabled: true // disabled on startup, will be enabled by controller if necessary
+            }]
+        }];
+        this.columns = [{
+            header: i18n.getMsg('orte.ortId'),
+            dataIndex: 'ortId'
+        }, {
+            header: i18n.getMsg('orte.nutsCode'),
+            dataIndex: 'nutsCode'
+        }, {
+            header: i18n.getMsg('orte.anlageId'),
+            dataIndex: 'anlageId'
+        }, {
+            header: i18n.getMsg('orte.gemId'),
+            dataIndex: 'gemId',
+            width: 120,
+            renderer: function(value) {
+                var store = Ext.data.StoreManager.get('verwaltungseinheiten');
+                var record = store.getById(value);
+                return record.get('bezeichnung');
+            }
+        }, {
+            header: i18n.getMsg('orte.staatId'),
+            dataIndex: 'staatId',
+            width: 70,
+            renderer: function(value) {
+                var staaten = Ext.data.StoreManager.get('staaten');
+                var record = staaten.getById(value);
+                return record.get('staatIso');
+            }
+        }, {
+            header: i18n.getMsg('orte.kdaId'),
+            dataIndex: 'kdaId'
+        }, {
+            header: i18n.getMsg('orte.ozId'),
+            dataIndex: 'ozId'
+        }, {
+            header: i18n.getMsg('orte.ortTyp'),
+            dataIndex: 'ortTyp'
+        }, {
+            header: i18n.getMsg('orte.mpArt'),
+            dataIndex: 'mpArt'
+        }, {
+            header: i18n.getMsg('orte.zone'),
+            dataIndex: 'zone'
+        }, {
+            header: i18n.getMsg('orte.sektor'),
+            dataIndex: 'sektor'
+        }, {
+            header: i18n.getMsg('orte.zustaendigkeit'),
+            dataIndex: 'zustaendigkeit'
+        }, {
+            header: i18n.getMsg('orte.berichtstext'),
+            dataIndex: 'berichtstext'
+        }, {
+            header: i18n.getMsg('orte.kurztext'),
+            dataIndex: 'kurztext'
+        }, {
+            header: i18n.getMsg('orte.langtext'),
+            dataIndex: 'langtext'
+        }, {
+            header: i18n.getMsg('orte.beschreibung'),
+            dataIndex: 'beschreibung'
+        }, {
+            header: i18n.getMsg('orte.unscharf'),
+            dataIndex: 'unscharf'
+        }, {
+            header: i18n.getMsg('orte.hoeheLand'),
+            dataIndex: 'hoeheLand'
+        }, {
+            header: i18n.getMsg('orte.koordXExtern'),
+            dataIndex: 'koordXExtern'
+        }, {
+            header: i18n.getMsg('orte.koordYExtern'),
+            dataIndex: 'koordYExtern'
+        }, {
+            header: i18n.getMsg('orte.longitude'),
+            dataIndex: 'longitude'
+        }, {
+            header: i18n.getMsg('orte.latitude'),
+            dataIndex: 'latitude'
+        }, {
+            header: i18n.getMsg('orte.letzteAenderung'),
+            dataIndex: 'letzteAenderung'
+        }];
+        this.listeners = {
+           select: {
+               fn: this.activateRemoveButton,
+               scope: this
+            },
+            deselect: {
+                fn: this.deactivateRemoveButton,
+                scope: this
+            }
+        };
+        this.listeners = {
+           select: {
+               fn: this.activateRemoveButton,
+               scope: this
+            },
+            deselect: {
+                fn: this.deactivateRemoveButton,
+                scope: this
+            }
+        };
+        this.callParent(arguments);
+    },
+
+    /**
+     * This sets the Store of this Grid
+     */
+    setStore: function(store){
+        var i18n = Lada.getApplication().bundle;
+
+        if (store) {
+            this.removeDocked(Ext.getCmp('ptbar'), true);
+            this.reconfigure(store);
+            this.down('button[action=add]').enable();
+            this.addDocked([{
+                xtype: 'pagingtoolbar',
+                id: 'ptbar',
+                dock: 'bottom',
+                store: store,
+                displayInfo: true
+            }]);
+        }
+    }
+});
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/view/grid/Ortszuordnung.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/grid/Ortszuordnung.js	Wed Jan 20 12:32:42 2016 +0100
@@ -0,0 +1,171 @@
+/* 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.
+ */
+
+/**
+ * Grid to list Ortszuordnungen
+ */
+Ext.define('Lada.view.grid.Ortszuordnung', {
+    extend: 'Ext.grid.Panel',
+    alias: 'widget.ortgrid',
+
+    maxHeight: 350,
+    emptyText: 'Keine Orte gefunden.',
+        // minHeight and deferEmptyText are needed to be able to show the
+        // emptyText message.
+    minHeight: 110,
+    viewConfig: {
+        deferEmptyText: false
+    },
+    margin: '0, 5, 5, 5',
+
+    recordId: null,
+
+    warnings: null,
+    errors: null,
+    readOnly: true,
+    allowDeselect: true,
+
+    initComponent: function() {
+        this.dockedItems = [{
+            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'
+            }]
+        }];
+        this.columns = [{
+            header: 'Typ',
+            dataIndex: 'ortsTyp',
+            width: 50,
+            editor: {
+                allowBlank: false
+            }
+        }, {
+            header: 'Staat',
+            dataIndex: 'ort',
+            width: 70,
+            renderer: function(value) {
+                var store = Ext.data.StoreManager.get('orte');
+                var staaten = Ext.data.StoreManager.get('staaten');
+                var record =
+                    staaten.getById(store.getById(value).get('staatId'));
+                return record.get('staatIso');
+            }
+        }, {
+            header: 'Gemeineschlüssel',
+            dataIndex: 'ort',
+            width: 120,
+            renderer: function(value) {
+                var store = Ext.data.StoreManager.get('orte');
+                var record = store.getById(value);
+                return record.get('gemId');
+            }
+        }, {
+            header: 'Gemeindename',
+            dataIndex: 'ort',
+            flex: 1,
+            renderer: function(value) {
+                var store = Ext.data.StoreManager.get('orte');
+                var gemeinden =
+                    Ext.data.StoreManager.get('verwaltungseinheiten');
+                var record = store.getById(value);
+                var gemid = record.get('gemId');
+                var record2 = gemeinden.getById(gemid);
+                return record2.get('bezeichnung');
+            }
+        }, {
+            header: 'Messpunkt',
+            dataIndex: 'ort',
+            renderer: function(value) {
+                var store = Ext.getStore('orte');
+                var record = store.getById(value);
+                return record.get('bezeichnung');
+            }
+        }];
+        this.listeners = {
+           select: {
+               fn: this.activateRemoveButton,
+               scope: this
+            },
+            deselect: {
+                fn: this.deactivateRemoveButton,
+                scope: this
+            }
+        };
+        this.initData();
+        this.callParent(arguments);
+        this.setReadOnly(true); //Grid is always initialised as RO
+    },
+
+    initData: function() {
+        this.store = Ext.create('Lada.store.Ortszuordnung');
+        this.store.load({
+            params: {
+                probeId: this.recordId
+            }
+        });
+        Ext.ClassManager.get('Lada.model.Probe').load(this.recordId, {
+            failure: function(record, action) {
+                // TODO
+            },
+            success: function(record, response) {
+                var json = Ext.decode(response.response.responseText);
+                if (json) {
+                    this.warnings = json.warnings;
+                    this.errors = json.errors;
+                }
+            },
+            scope: this
+        });
+    },
+
+    setReadOnly: function(b) {
+        if (b == true){
+            //Readonly
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').disable();
+            }
+            this.down('button[action=delete]').disable();
+            this.down('button[action=add]').disable();
+        }else{
+            //Writable
+            if (this.getPlugin('rowedit')){
+                this.getPlugin('rowedit').enable();
+            }
+            //this.down('button[action=delete]').enable();
+            this.down('button[action=add]').enable();
+        }
+    },
+    /**
+     * Activate the Remove Button
+     */
+    activateRemoveButton: function(selection, record) {
+        var grid = this;
+        //only enable the remove buttone, when the grid is editable.
+        if (! grid.readOnly) {
+            grid.down('button[action=delete]').enable();
+        }
+    },
+    /**
+     * Activate the Remove Button
+     */
+    deactivateRemoveButton: function(selection, record) {
+        var grid = this;
+        //only enable the remove buttone, when the grid is editable.
+        if (! grid.readOnly) {
+            grid.down('button[action=delete]').disable();
+        }
+    }
+});
diff -r 15d8c64049d1 -r 9ac03f461ab4 app/view/window/ProbeEdit.js
--- a/app/view/window/ProbeEdit.js	Fri Jan 15 14:42:29 2016 +0100
+++ b/app/view/window/ProbeEdit.js	Wed Jan 20 12:32:42 2016 +0100
@@ -15,7 +15,7 @@
 
     requires: [
         'Lada.view.form.Probe',
-        'Lada.view.grid.Ort',
+        'Lada.view.grid.Ortszuordnung',
         'Lada.view.grid.Probenzusatzwert',
         'Lada.view.grid.PKommentar',
         'Lada.view.grid.Messung'


More information about the Lada-commits mailing list