torsten@472: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz torsten@472: * Software engineering by Intevation GmbH torsten@472: * torsten@472: * This file is Free Software under the GNU GPL (v>=3) torsten@472: * and comes with ABSOLUTELY NO WARRANTY! Check out torsten@472: * the documentation coming with IMIS-Labordaten-Application for details. torsten@472: */ torsten@472: torsten@347: /* torsten@347: * Formular to create and edit a Ort torsten@347: */ torsten@109: Ext.define('Lada.view.orte.CreateForm', { torsten@109: extend: 'Lada.view.widgets.LadaForm', torsten@109: model: 'Lada.model.Ort', torsten@149: requires: [ torsten@149: 'Lada.view.widgets.Ortdetail', torsten@149: 'Lada.view.widgets.Staat', raimund@447: 'Lada.view.widgets.Verwaltungseinheit', raimund@447: 'Lada.view.orte.CreateOrt' torsten@149: ], raimund@447: edit: false, torsten@109: initComponent: function() { raimund@491: this.items = [{ raimund@491: xtype: 'ortdetail', raimund@491: name: 'ortId', raimund@491: fieldLabel: 'Ort', raimund@491: listeners: { raimund@491: scope: this, raimund@491: 'change': function (field, newv, oldv, opts) { raimund@491: if (field.up('window')) { raimund@491: field.up('window').down('fieldset').show(); raimund@491: } raimund@496: var orte = Ext.data.StoreManager.get('staOrte'); raimund@491: var ort = orte.getById(newv); raimund@491: var fields = [ raimund@491: 'beschreibung', raimund@491: 'bezeichnung', raimund@491: 'hoeheLand', raimund@491: 'latitude', raimund@491: 'longitude', raimund@491: 'staatId', raimund@491: 'gemId' raimund@491: ]; torsten@429: raimund@491: // Load currently "selected" verwaltungseinheit. This raimund@491: // is needed as without having this record the field raimund@491: // would only display the raw value (id) of the raimund@491: // verwaltungseinheit. raimund@496: var verw = raimund@496: Ext.data.StoreManager.get('staVerwaltungseinheiten'); raimund@491: if (ort) { raimund@491: verw.load({ raimund@491: id: ort.get('gemId') raimund@491: }); raimund@491: } torsten@429: raimund@491: var form = this.getForm(); raimund@491: if ( ort != undefined ) { raimund@491: for (var i = fields.length - 1; i >= 0; i--){ raimund@491: ffield = form.findField("ort_"+fields[i]); raimund@491: ffield.setValue(ort.get(fields[i])); torsten@149: } torsten@149: } torsten@149: } raimund@491: } raimund@491: }, { raimund@491: xtype: 'textfield', raimund@491: name: 'ortsTyp', raimund@491: maxLength: 1, raimund@491: fieldLabel: 'Typ' raimund@491: }, { raimund@491: xtype: 'textareafield', raimund@491: name: 'ortszusatztext', raimund@491: maxLength: 100, raimund@491: fieldLabel: 'Ortszusatz' raimund@491: }, { raimund@491: xtype: 'button', raimund@491: name: 'newort', raimund@491: text: 'Neuen Ort Anlegen', raimund@491: hidden: this.edit, raimund@491: action: 'newort' raimund@491: }, { raimund@491: xtype: 'fieldset', raimund@491: title: 'Ortsangaben', raimund@491: hidden: !this.edit, raimund@491: defaults: { raimund@491: labelWidth: 150 raimund@447: }, raimund@491: items: [{ raimund@491: xtype: 'textfield', raimund@491: maxLength: 100, raimund@491: name: 'ort_beschreibung', raimund@491: fieldLabel: 'Beschreibung' raimund@491: }, { raimund@491: xtype: 'textfield', raimund@491: maxLength: 10, raimund@491: name: 'ort_bezeichnung', raimund@491: fieldLabel: 'Bezeichnung' raimund@491: }, { raimund@491: xtype: 'staat', raimund@491: name: 'ort_staatId', raimund@491: fieldLabel: 'Staat' raimund@491: }, { raimund@491: xtype: 'verwaltungseinheiten', raimund@491: name: 'ort_gemId', raimund@491: fieldLabel: 'Gemeinde' raimund@491: }, { raimund@491: xtype: 'numberfield', raimund@491: name: 'ort_latitude', raimund@491: fieldLabel: 'Lat' raimund@491: }, { raimund@491: xtype: 'numberfield', raimund@491: name: 'ort_longitude', raimund@491: fieldLabel: 'Lon' raimund@491: }, { raimund@491: xtype: 'numberfield', raimund@491: name: 'ort_hoeheLand', raimund@491: fieldLabel: 'Höhe' raimund@491: }] raimund@491: }]; raimund@491: this.callParent(arguments); torsten@149: }, raimund@491: torsten@149: updateOrtInfo: function(field, oldv, newv, opts) { torsten@149: console.log(field, oldv, newv, opts); torsten@109: } torsten@109: });