comparison app/view/window/Ortszuordnung.js @ 1289:bfdc00c24baf

Ortszuordnung for messprogramm and probe using same form
author Maximilian Krambach <mkrambach@intevation.de>
date Wed, 01 Feb 2017 14:52:51 +0100
parents 08085b7d1d0b
children 317ae6bfd647
comparison
equal deleted inserted replaced
1288:08085b7d1d0b 1289:bfdc00c24baf
5 * and comes with ABSOLUTELY NO WARRANTY! Check out 5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details. 6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */ 7 */
8 8
9 /** 9 /**
10 * Window to create/edit the Ort / Probe Relation 10 * Window to create/edit the Ort/Probe or Ort/Messprogramm Relation
11 */ 11 */
12
12 Ext.define('Lada.view.window.Ortszuordnung', { 13 Ext.define('Lada.view.window.Ortszuordnung', {
13 extend: 'Ext.window.Window', 14 extend: 'Ext.window.Window',
14 alias: 'widget.ortszuordnungwindow', 15 alias: 'widget.ortszuordnungwindow',
15 16
16 requires: [ 17 requires: [
18 'Lada.model.Ortszuordnung',
19 'Lada.model.OrtszuordnungMp',
17 'Lada.view.form.Ortszuordnung', 20 'Lada.view.form.Ortszuordnung',
18 'Lada.view.form.Ortserstellung', 21 'Lada.view.form.Ortserstellung',
19 'Lada.view.panel.Map', 22 'Lada.view.panel.Map',
20 'Lada.view.grid.Orte' 23 'Lada.view.grid.Orte'
21 ], 24 ],
25 autoshow: true, 28 autoshow: true,
26 layout: 'fit', 29 layout: 'fit',
27 constrain: true, 30 constrain: true,
28 31
29 probe: null, 32 probe: null,
33 messprogramm: null,
30 34
31 parentWindow: null, 35 parentWindow: null,
32 record: null, 36 record: null,
33 grid: null, 37 grid: null,
34 38
36 * This function initialises the Window 40 * This function initialises the Window
37 */ 41 */
38 initComponent: function() { 42 initComponent: function() {
39 var i18n = Lada.getApplication().bundle; 43 var i18n = Lada.getApplication().bundle;
40 this.title = i18n.getMsg('ortszuordnung.window.title'); 44 this.title = i18n.getMsg('ortszuordnung.window.title');
41 45 var recordtype;
42 if (this.record && this.probe) { 46 if (this.probe) {
43 // A record be edited 47 if (this.record) {
44 this.title = i18n.getMsg('ortszuordnung.window.title') 48 // A probe record will be edited
49 this.title = i18n.getMsg('ortszuordnung.window.title')
45 + ' ' 50 + ' '
46 + i18n.getMsg('ortszuordnung.window.title2') 51 + i18n.getMsg('ortszuordnung.window.title2')
47 + ' ' 52 + ' '
48 + i18n.getMsg('probe') 53 + i18n.getMsg('probe')
49 + ' ' 54 + ' '
50 + this.probe.get('hauptprobenNr') 55 + this.probe.get('hauptprobenNr')
51 + ' ' 56 + ' '
52 + i18n.getMsg('edit'); 57 + i18n.getMsg('edit');
58 } else {
59 // A new probe record will be created
60 this.title = i18n.getMsg('ortszuordnung.window.title')
61 + ' '
62 + i18n.getMsg('ortszuordnung.window.title2')
63 + ' '
64 + i18n.getMsg('probe')
65 + ' '
66 + this.probe.get('hauptprobenNr')
67 + ' '
68 + i18n.getMsg('create');
69 }
70 } else if (this.messprogramm) {
71 if (this.record) {
72 // A messprogramm record will be edited
73 this.title = i18n.getMsg('ortszuordnung.window.title')
74 + ' '
75 + i18n.getMsg('ortszuordnung.window.title2')
76 + ' '
77 + i18n.getMsg('messprogramm')
78 + ' '
79 + i18n.getMsg('edit');
80 } else {
81 // A new messprogramm record will be created
82 this.title = i18n.getMsg('ortszuordnung.window.title')
83 + ' '
84 + i18n.getMsg('ortszuordnung.window.title2')
85 + ' '
86 + i18n.getMsg('messprogramm')
87 + ' '
88 + i18n.getMsg('create');
89 }
53 } 90 }
54 else if (this.probe) { 91
55 // A new record will be created
56 this.title = i18n.getMsg('ortszuordnung.window.title')
57 + ' '
58 + i18n.getMsg('ortszuordnung.window.title2')
59 + ' '
60 + i18n.getMsg('probe')
61 + ' '
62 + this.probe.get('hauptprobenNr')
63 + ' '
64 + i18n.getMsg('create');
65 }
66 this.buttons = [{ 92 this.buttons = [{
67 text: i18n.getMsg('close'), 93 text: i18n.getMsg('close'),
68 scope: this, 94 scope: this,
69 handler: this.close 95 handler: this.close
70 }]; 96 }];
95 externalOrteStore: true 121 externalOrteStore: true
96 }, { 122 }, {
97 xtype: 'ortszuordnungform', 123 xtype: 'ortszuordnungform',
98 region: 'east', 124 region: 'east',
99 minHeight: 380, 125 minHeight: 380,
126 type: this.probe? 'probe': 'mpr'
100 }, { 127 }, {
101 region: 'south', 128 region: 'south',
102 border: 0, 129 border: 0,
103 layout: 'fit', 130 layout: 'fit',
104 name: 'ortgrid', 131 name: 'ortgrid',
133 action: 'clone' 160 action: 'clone'
134 }] 161 }]
135 }] 162 }]
136 }] 163 }]
137 }]; 164 }];
138
139 this.callParent(arguments); 165 this.callParent(arguments);
140 }, 166 },
141 167
142 /** 168 /**
143 * Initialise the Data of this Window 169 * Initialise the Data of this Window
144 */ 170 */
145 initData: function() { 171 initData: function() {
146 var me = this; 172 var me = this;
147 if (!this.record) { 173 if (!this.record) {
148 this.record = Ext.create('Lada.model.Ortszuordnung'); 174 if (this.probe) {
175 this.record = Ext.create('Lada.model.Ortszuordnung');
176 this.record.set('probeId', this.probe.get('id'));
177 } else {
178 this.record = Ext.create('Lada.model.OrtszuordnungMp');
179 this.record.set('messprogrammId', this.messprogramm.get('id'));
180 }
149 if (!this.record.get('letzteAenderung')) { 181 if (!this.record.get('letzteAenderung')) {
150 this.record.data.letzteAenderung = new Date(); 182 this.record.data.letzteAenderung = new Date();
151 } 183 }
152 this.record.set('probeId', this.probe.get('id'));
153 } 184 }
154 this.down('ortszuordnungform').setRecord(this.record); 185 this.down('ortszuordnungform').setRecord(this.record);
155 var map = this.down('map'); 186 var map = this.down('map');
156 var osg = this.down('ortstammdatengrid'); 187 var osg = this.down('ortstammdatengrid');
157 this.ortstore = Ext.create('Lada.store.Orte', { 188 this.ortstore = Ext.create('Lada.store.Orte', {
173 map.featureLayer.setVisibility(false); 204 map.featureLayer.setVisibility(false);
174 map.selectedFeatureLayer = new OpenLayers.Layer.Vector( 205 map.selectedFeatureLayer = new OpenLayers.Layer.Vector(
175 'gewählter Messpunkt', { 206 'gewählter Messpunkt', {
176 styleMap: new OpenLayers.StyleMap({ 207 styleMap: new OpenLayers.StyleMap({
177 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png', 208 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
178 pointRadius: 10, 209 pointRadius: 12,
179 label: '${bez}', 210 label: '${bez}',
180 labelAlign: 'rt', 211 labelAlign: 'rt',
181 fontColor: 'blue', 212 fontColor: 'blue',
182 fontWeight: 'bold', 213 fontWeight: 'bold',
183 }), 214 }),
184 displayInLayerSwitcher: false, 215 displayInLayerSwitcher: false,
185 projection: new OpenLayers.Projection('EPSG:3857') 216 projection: new OpenLayers.Projection('EPSG:3857')
186 }); 217 });
187 map.map.addLayer(map.selectedFeatureLayer); 218 map.map.addLayer(map.selectedFeatureLayer);
188 map.selectedFeatureLayer.setZIndex(499); 219 map.selectedFeatureLayer.setZIndex(499);
189 var ortId = me.record.get('ortId'); 220 var ortId = me.messprogramm? me.record.get('ort') : me.record.get('ortId');
190 if (ortId){ 221 if (ortId){
191 var feat = map.featureLayer.getFeaturesByAttribute('id', ortId)[0]; 222 var feat = map.featureLayer.getFeaturesByAttribute('id', ortId);
192 map.selectControl.select(feat); 223 var ortrecord = this.findRecord('id', ortId);
224 osg.selectOrt(map, feat);
225 map.selectFeature(this.model, ortrecord);
226 me.down('ortszuordnungform').setOrt(null,ortrecord);
193 } 227 }
194 } 228 }
195 } 229 }
196 } 230 }
197 }); 231 });

http://lada.wald.intevation.org