dustin@1004: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@1004: * Software engineering by Intevation GmbH dustin@1004: * dustin@1004: * This file is Free Software under the GNU GPL (v>=3) dustin@1004: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@1004: * the documentation coming with IMIS-Labordaten-Application for details. dustin@1004: */ dustin@1004: dustin@1004: /** dustin@1004: * Grid to list Orte Stammdaten dustin@1004: */ dustin@1004: Ext.define('Lada.view.grid.Orte', { dustin@1004: extend: 'Ext.grid.Panel', dustin@1004: alias: 'widget.ortstammdatengrid', dustin@1004: raimund@1308: requires: [ raimund@1317: 'Ext.ux.grid.FiltersFeature', raimund@1317: 'Lada.view.widget.KoordinatenArt', raimund@1317: 'Lada.view.widget.Kta', raimund@1317: 'Lada.view.widget.OrtsZusatz', raimund@1317: 'Lada.view.widget.OrtTyp' raimund@1308: ], dustin@1004: // minHeight and deferEmptyText are needed to be able to show the dustin@1004: // emptyText message. dustin@1004: minHeight: 110, dustin@1004: viewConfig: { dustin@1004: deferEmptyText: false dustin@1004: }, dustin@1004: dustin@1004: recordId: null, dustin@1004: dustin@1004: warnings: null, dustin@1004: errors: null, dustin@1004: readOnly: true, dustin@1004: allowDeselect: true, raimund@1050: editableGrid: true, raimund@1308: features: [], dustin@1004: dustin@1004: initComponent: function() { dustin@1004: var i18n = Lada.getApplication().bundle; dustin@1004: this.emptyText = i18n.getMsg('orte.emptyGrid'); dustin@1004: raimund@1050: if (this.editableGrid) { raimund@1050: this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { raimund@1050: clicksToMoveEditor: 1, raimund@1050: autoCancel: false, raimund@1050: disabled: false, raimund@1050: pluginId: 'rowedit' raimund@1050: }); raimund@1050: this.plugins = [this.rowEditing]; raimund@1050: } raimund@1049: raimund@1308: filters = { raimund@1308: ftype: 'filters', raimund@1308: // encode and local configuration options defined previously for easier reuse raimund@1308: encode: false, // json encode the filter query raimund@1308: local: true, // defaults to false (remote filtering) raimund@1308: raimund@1308: // Filters are most naturally placed in the column definition, but can also be raimund@1308: // added here. raimund@1308: filters: [{ raimund@1308: type: 'boolean', raimund@1308: dataIndex: 'visible' raimund@1308: }] raimund@1308: }; raimund@1308: this.features = [filters]; raimund@1308: dustin@1004: this.columns = [{ raimund@1081: xtype: 'actioncolumn', raimund@1081: text: 'RW', raimund@1081: dataIndex: 'readonly', raimund@1081: sortable: false, raimund@1081: width: 30, raimund@1081: getClass: function (val, meta, rec) { raimund@1081: if (rec.get('readonly') === false) { raimund@1081: return 'edit'; raimund@1081: } raimund@1081: return 'noedit'; raimund@1081: } raimund@1081: }, { tom@1135: header: i18n.getMsg('netzbetreiberId'), raimund@1130: renderer: function(value) { raimund@1130: var r = ''; raimund@1130: if (!value || value === '') { raimund@1130: r = 'Error'; raimund@1130: } raimund@1130: var store = Ext.data.StoreManager.get('netzbetreiber'); raimund@1130: var record = store.getById(value); raimund@1130: if (record) { raimund@1130: r = record.get('netzbetreiber'); raimund@1130: } raimund@1130: return r; raimund@1130: }, raimund@1130: editor: { raimund@1130: xtype: 'combobox', raimund@1130: store: Ext.data.StoreManager.get('netzbetreiberFiltered'), raimund@1130: displayField: 'netzbetreiber', raimund@1130: valueField: 'id', raimund@1130: allowBlank: false raimund@1130: }, raimund@1130: dataIndex: 'netzbetreiberId' raimund@1130: }, { dustin@1004: header: i18n.getMsg('orte.ortId'), raimund@1130: editor: { raimund@1140: xtype: 'textfield', tom@1254: maxLength: 10, raimund@1140: allowBlank: false raimund@1130: }, raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, dustin@1004: dataIndex: 'ortId' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.nutsCode'), raimund@1130: editor: { tom@1254: xtype: 'textfield', tom@1254: maxLength: 10 raimund@1130: }, raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, dustin@1004: dataIndex: 'nutsCode' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.anlageId'), raimund@1130: editor: { raimund@1325: xtype: 'combobox', raimund@1325: store: Ext.data.StoreManager.get('ktas'), raimund@1325: displayField: 'code', raimund@1325: valueField: 'id' raimund@1317: }, raimund@1317: renderer: function(value) { raimund@1317: if (value === undefined || raimund@1317: value === null || raimund@1317: value === '' raimund@1317: ) { raimund@1317: return ''; raimund@1317: } raimund@1317: var store = Ext.data.StoreManager.get('ktas'); raimund@1317: var record = store.getById(value); raimund@1317: return record.get('code'); raimund@1130: }, dustin@1004: dataIndex: 'anlageId' dustin@1004: }, { tom@1297: header: i18n.getMsg('orte.verwaltungseinheit'), dustin@1004: dataIndex: 'gemId', dustin@1004: width: 120, raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, dustin@1004: renderer: function(value) { raimund@1130: if (!value) { raimund@1130: return ''; raimund@1130: } dustin@1004: var store = Ext.data.StoreManager.get('verwaltungseinheiten'); dustin@1004: var record = store.getById(value); dustin@1004: return record.get('bezeichnung'); raimund@1130: }, raimund@1130: editor: { raimund@1130: xtype: 'combobox', raimund@1130: store: Ext.data.StoreManager.get('verwaltungseinheiten'), raimund@1130: displayField: 'bezeichnung', raimund@1130: valueField: 'id', raimund@1130: allowBlank: false dustin@1004: } dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.staatId'), dustin@1004: dataIndex: 'staatId', dustin@1004: width: 70, raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, dustin@1004: renderer: function(value) { raimund@1296: if (value === undefined || value === '') { raimund@1130: return ''; raimund@1130: } dustin@1004: var staaten = Ext.data.StoreManager.get('staaten'); dustin@1004: var record = staaten.getById(value); dustin@1004: return record.get('staatIso'); raimund@1130: }, raimund@1130: editor: { raimund@1130: xtype: 'combobox', raimund@1130: store: Ext.data.StoreManager.get('staaten'), raimund@1130: displayField: 'staatIso', raimund@1130: valueField: 'id', raimund@1130: allowBlank: false dustin@1004: } dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.kdaId'), raimund@1308: filter: { raimund@1317: type: 'string' raimund@1308: }, raimund@1130: editor: { raimund@1325: xtype: 'combobox', raimund@1325: store: Ext.data.StoreManager.get('koordinatenart'), raimund@1325: displayField: 'koordinatenart', raimund@1325: valueField: 'id' raimund@1130: }, raimund@1317: renderer: function(value) { raimund@1317: if (value === undefined || value === '') { raimund@1317: return ''; raimund@1317: } raimund@1317: var kda = Ext.data.StoreManager.get('koordinatenart'); raimund@1317: var record = kda.getById(value); raimund@1317: return record.get('koordinatenart'); raimund@1317: }, dustin@1004: dataIndex: 'kdaId' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.ozId'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1317: editor: { raimund@1325: xtype: 'combobox', raimund@1325: store: Ext.data.StoreManager.get('ortszusatz'), raimund@1325: displayField: 'ozsId', raimund@1325: valueField: 'ozsId' raimund@1317: }, raimund@1317: renderer: function(value) { raimund@1317: if (value === undefined || raimund@1317: value === null || raimund@1317: value === '' raimund@1317: ) { raimund@1317: return ''; raimund@1317: } raimund@1317: var oz = Ext.data.StoreManager.get('ortszusatz'); raimund@1317: var record = oz.getById(value); raimund@1317: return record.get('ozsId'); raimund@1317: }, dustin@1004: dataIndex: 'ozId' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.ortTyp'), raimund@1308: filter: { raimund@1317: type: 'string' raimund@1317: }, raimund@1317: editor: { raimund@1325: xtype: 'combobox', raimund@1325: store: Ext.data.StoreManager.get('orttyp'), raimund@1325: displayField: 'code', raimund@1325: valueField: 'id' raimund@1317: }, raimund@1317: renderer: function(value) { raimund@1317: if (value === undefined || raimund@1317: value === null || raimund@1317: value === '' raimund@1317: ) { raimund@1317: return ''; raimund@1317: } raimund@1317: var ot = Ext.data.StoreManager.get('orttyp'); raimund@1317: var record = ot.getById(value); raimund@1317: return record.get('code'); raimund@1308: }, dustin@1004: dataIndex: 'ortTyp' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.mpArt'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { tom@1254: xtype: 'textfield', tom@1254: maxLength: 10 raimund@1130: }, dustin@1004: dataIndex: 'mpArt' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.zone'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { tom@1254: xtype: 'textfield', tom@1254: maxLength: 1 raimund@1130: }, dustin@1004: dataIndex: 'zone' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.sektor'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { tom@1254: xtype: 'textfield', tom@1254: maxLength: 2 raimund@1130: }, dustin@1004: dataIndex: 'sektor' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.zustaendigkeit'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { tom@1254: xtype: 'textfield', tom@1254: maxLength: 10 raimund@1130: }, dustin@1004: dataIndex: 'zustaendigkeit' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.berichtstext'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { tom@1254: xtype: 'textfield', tom@1254: maxLength: 70 raimund@1130: }, dustin@1004: dataIndex: 'berichtstext' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.kurztext'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { raimund@1140: xtype: 'textfield', tom@1254: maxLength: 15, raimund@1140: allowBlank: false raimund@1130: }, dustin@1004: dataIndex: 'kurztext' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.langtext'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { raimund@1140: xtype: 'textfield', tom@1254: maxLength: 100, raimund@1140: allowBlank: false raimund@1130: }, dustin@1004: dataIndex: 'langtext' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.unscharf'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { raimund@1130: xtype: 'textfield' raimund@1130: }, dustin@1004: dataIndex: 'unscharf' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.hoeheLand'), raimund@1308: filter: { raimund@1308: type: 'numeric' raimund@1308: }, raimund@1130: editor: { raimund@1130: xtype: 'numberfield' raimund@1130: }, dustin@1004: dataIndex: 'hoeheLand' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.koordXExtern'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { raimund@1140: xtype: 'textfield', tom@1254: maxLength: 22, raimund@1140: allowBlank: false raimund@1130: }, dustin@1004: dataIndex: 'koordXExtern' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.koordYExtern'), raimund@1308: filter: { raimund@1308: type: 'string' raimund@1308: }, raimund@1130: editor: { raimund@1140: xtype: 'textfield', tom@1254: maxLength: 22, raimund@1140: allowBlank: false raimund@1130: }, dustin@1004: dataIndex: 'koordYExtern' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.longitude'), raimund@1308: filter: { raimund@1308: type: 'numeric' raimund@1308: }, raimund@1130: editor: { raimund@1130: xtype: 'numberfield' raimund@1130: }, dustin@1004: dataIndex: 'longitude' dustin@1004: }, { dustin@1004: header: i18n.getMsg('orte.latitude'), raimund@1308: filter: { raimund@1308: type: 'numeric' raimund@1308: }, raimund@1130: editor: { raimund@1130: xtype: 'numberfield' raimund@1130: }, dustin@1004: dataIndex: 'latitude' dustin@1004: }, { tom@1137: header: i18n.getMsg('letzteAenderung'), raimund@1308: filter: { raimund@1308: type: 'date' raimund@1308: }, tom@1137: xtype: 'datecolumn', tom@1137: format: 'd.m.Y H:i', dustin@1004: dataIndex: 'letzteAenderung' dustin@1004: }]; dustin@1004: this.callParent(arguments); dustin@1004: }, dustin@1004: dustin@1004: /** dustin@1004: * This sets the Store of this Grid dustin@1004: */ dustin@1004: setStore: function(store){ dustin@1004: var i18n = Lada.getApplication().bundle; dustin@1004: dustin@1004: if (store) { dustin@1004: this.reconfigure(store); dustin@1021: dustin@1021: var ptbar = this.down('pagingtoolbar'); dustin@1021: if (ptbar) { dustin@1021: this.removeDocked(ptbar); dustin@1021: } dustin@1021: dustin@1021: if (store.pageSize > 0) { dustin@1021: this.addDocked([{ dustin@1021: xtype: 'pagingtoolbar', dustin@1021: dock: 'bottom', dustin@1021: store: store, dustin@1021: displayInfo: true dustin@1021: }]); dustin@1021: } dustin@1004: } raimund@1130: raimund@1130: if (Ext.Array.contains(Lada.funktionen, 4)) { raimund@1130: var panel = this.up('ortpanel'); raimund@1130: panel.down('button[action=add]').enable(); raimund@1130: panel.down('button[action=addMap]').enable(); raimund@1130: } raimund@1049: }, raimund@1049: raimund@1049: selectOrt: function(map, feature) { raimund@1049: var id = feature[0].data.id; raimund@1049: var record = this.store.getById(id); raimund@1049: this.getSelectionModel().select(record); mkrambach@1293: var win = this.up('ortszuordnungwindow'); mkrambach@1293: if (win){ mkrambach@1293: win.down('ortszuordnungform').setOrt(null, record); mkrambach@1293: } dustin@1004: } dustin@1004: });