comparison app/view/form/Ortserstellung.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 c1b7db04b39c
comparison
equal deleted inserted replaced
1288:08085b7d1d0b 1289:bfdc00c24baf
16 'Lada.view.widget.Verwaltungseinheit', 16 'Lada.view.widget.Verwaltungseinheit',
17 'Lada.view.widget.Staat' 17 'Lada.view.widget.Staat'
18 ], 18 ],
19 model: null, 19 model: null,
20 20
21 margin: 5,
22
21 record: null, 23 record: null,
22 24
23 initComponent: function() { 25 initComponent: function() {
24 var i18n = Lada.getApplication().bundle; 26 var i18n = Lada.getApplication().bundle;
25 var me = this; 27 var me = this;
26 this.items = [{ 28 this.items = [{
27 xtype: 'netzbetreiber', 29 xtype: 'netzbetreiber',
28 editable: false, 30 editable: false,
29 readOnly: true, 31 readOnly: true,
30 submitValue: true, 32 submitValue: true,
33 border: 0,
31 fieldLabel: i18n.getMsg('netzbetreiberId'), 34 fieldLabel: i18n.getMsg('netzbetreiberId'),
32 margin : '0, 5, 5, 5', 35 labelWidth: 125,
33 labelWidth: 80,
34 width: 150,
35 value: Lada.netzbetreiber[0] 36 value: Lada.netzbetreiber[0]
36 }, { 37 }, {
37 xtype: 'checkbox', 38 xtype: 'checkbox',
38 name: 'aktiv', 39 name: 'aktiv',
39 fieldLabel: 'aktiv:' 40 fieldLabel: 'aktiv:'
40 }, {
41 xtype: 'displayfield',
42 align: 'right',
43 value: 'D',
44 labelWidth: 125,
45 maxLength: 1,
46 name: 'messpunktart',
47 fieldLabel: 'Art des Messpunktes:'
48 },{ 41 },{
49 xtype: 'staat', 42 xtype: 'staat',
50 labelWidth: 125, 43 labelWidth: 125,
51 fieldLabel: i18n.getMsg('staat'), 44 fieldLabel: i18n.getMsg('staat'),
52 name: 'staatId', 45 name: 'staatId',
46 forceSelection: true,
53 listeners: { 47 listeners: {
54 change: { 48 change: {
55 fn: function() { me.checkCommitEnabled() } 49 fn: function() { me.checkCommitEnabled() }
56 } 50 }
57 } 51 }
58 }, { 52 }, {
59 xtype: 'verwaltungseinheit', 53 xtype: 'verwaltungseinheit',
60 labelWidth: 125, 54 labelWidth: 125,
61 fieldLabel: i18n.getMsg('orte.gemeinde'), 55 fieldLabel: i18n.getMsg('orte.gemeinde'),
56 forceSelection: true,
62 name: 'gemId', 57 name: 'gemId',
63 listeners: { 58 listeners: {
64 change: { 59 change: {
65 fn: function() { me.checkCommitEnabled() } 60 fn: function() { me.checkCommitEnabled() }
66 } 61 }
104 } 99 }
105 } 100 }
106 }, { 101 }, {
107 xtype: 'numfield', 102 xtype: 'numfield',
108 labelWidth: 125, 103 labelWidth: 125,
109 fieldLabel: 'Höhe:', 104 fieldLabel: i18n.getMsg('orte.hoeheLand'),
110 name: 'hoeheLand', 105 name: 'hoeheLand',
111 maxLength: 10, 106 maxLength: 10,
112 allowDecimals: true 107 allowDecimals: true
113 }, { 108 }, {
114 xtype: 'tfield', 109 xtype: 'tfield',
115 labelWidth: 125, 110 labelWidth: 125,
116 maxLength: 100, 111 maxLength: 100,
117 name: 'kurztext', 112 name: 'kurztext',
118 fieldLabel: i18n.getMsg('orte.kurztext'), 113 fieldLabel: i18n.getMsg('orte.kurztext')
119 },{ 114 },{
120 xtype: 'tfield', 115 xtype: 'tfield',
121 labelWidth: 125, 116 labelWidth: 125,
122 fieldLabel: i18n.getMsg('orte.langtext'), 117 fieldLabel: i18n.getMsg('orte.langtext'),
123 name: 'langtext' 118 name: 'langtext'
124 },{ 119 },{
125 xtype: 'tfield', 120 xtype: 'tfield',
126 labelWidth: 125, 121 labelWidth: 125,
127 fieldLabel: 'Berichtstext:', 122 fieldLabel: i18n.getMsg('orte.berichtstext'),
128 name: 'berichtstext' 123 name: 'berichtstext'
124 }, {
125 xtype: 'tfield',
126 labelWidth: 125,
127 maxLength: 100,
128 name: 'anlageId',
129 fieldLabel: i18n.getMsg('orte.anlageId')
130 }, {
131 xtype: 'tfield',
132 labelWidth: 125,
133 maxLength: 100,
134 name: 'zone',
135 fieldLabel: i18n.getMsg('orte.zone')
136 },{
137 xtype: 'tfield',
138 labelWidth: 125,
139 maxLength: 100,
140 name: 'sektor',
141 fieldLabel: i18n.getMsg('orte.sektor')
142 },{
143 xtype: 'tfield',
144 labelWidth: 125,
145 maxLength: 100,
146 name: 'ortTyp',
147 fieldLabel: i18n.getMsg('orte.ortTyp')
148 },{
149 xtype: 'tfield',
150 labelWidth: 125,
151 maxLength: 100,
152 name: 'zustaendigkeit',
153 fieldLabel: i18n.getMsg('orte.zustaendigkeit')
154 },{
155 xtype: 'tfield',
156 labelWidth: 125,
157 maxLength: 100,
158 name: 'mpArt',
159 fieldLabel: i18n.getMsg('orte.mpArt')
160 },{
161 xtype: 'tfield',
162 labelWidth: 125,
163 maxLength: 100,
164 name: 'nutsCode',
165 fieldLabel: i18n.getMsg('orte.nutsCode')
166 },{
167 xtype: 'tfield',
168 labelWidth: 125,
169 maxLength: 100,
170 name: 'ozId',
171 fieldLabel: i18n.getMsg('orte.ozId')
129 }]; 172 }];
173
130 this.dockedItems = [{ 174 this.dockedItems = [{
131 xtype: 'toolbar', 175 xtype: 'toolbar',
132 dock: 'bottom', 176 dock: 'bottom',
133 border: '0, 1, 1, 1', 177 border: '0, 1, 1, 1',
134 style: { 178 style: {
148 me.close(); 192 me.close();
149 } 193 }
150 }] 194 }]
151 }]; 195 }];
152 196
153 //TODO:
154 // 'Anlage:'?
155 // zone
156 // sektor
157 // zustaendigkeit
158 // Messregime (mpArt)
159 // 'Prog.-Punkt:', ?
160 // nutsCode
161 // Ortszusatz-ID (ozId)
162 this.callParent(arguments); 197 this.callParent(arguments);
163 this.getForm().loadRecord(this.record); 198 this.getForm().loadRecord(this.record);
164 }, 199 },
165 200
166 /** 201 /**
167 * checks Messpunktart and if the Messpunkt can be committed. 202 * checks if the Messpunkt can be committed.
168 * Disables the save button if false 203 * Disables the save button if false
169 */ 204 */
170 // TODO messpunktart is not yet finally defined
171 checkCommitEnabled: function() { 205 checkCommitEnabled: function() {
172 var savebutton = this.down('toolbar').down('button[action=save]'); 206 var savebutton = this.down('toolbar').down('button[action=save]');
173 var form = this.getForm(); 207 var form = this.getForm();
174 if (this.getForm().findField('kdaId').getValue() || 208 if (form.findField('kdaId').getValue() ||
175 this.getForm().findField('koordYExtern').getValue() || 209 form.findField('koordYExtern').getValue() ||
176 this.getForm().findField('koordXExtern').getValue()) { 210 form.findField('koordXExtern').getValue()) {
177 if (this.checkCoordinates()) { 211 if (this.checkCoordinates()) {
178 form.findField('messpunktart').setValue('D');
179 savebutton.setDisabled(false); 212 savebutton.setDisabled(false);
180 } else { 213 } else {
181 savebutton.setDisabled(true); 214 savebutton.setDisabled(true);
182 } 215 }
183 } else if (form.findField('gemId').getValue()) { 216 } else if (form.findField('gemId').getValue() ||
184 form.findField('messpunktart').setValue('V'); 217 form.findField('staatId').getValue() >= 0 ) {
185 savebutton.setDisabled(false);
186 } else if (form.findField('staatId').getValue()) {
187 form.findField('messpunktart').setValue('S');
188 savebutton.setDisabled(false); 218 savebutton.setDisabled(false);
189 } else { 219 } else {
190 form.findField('messpunktart').setValue('D');
191 savebutton.setDisabled(true); 220 savebutton.setDisabled(true);
192 } 221 }
193 }, 222 },
194 223
195 /** 224 /**
238 this_panel.record.set('ortId', null); 267 this_panel.record.set('ortId', null);
239 this_panel.record.set('netzbetreiberId', Lada.netzbetreiber[0]); 268 this_panel.record.set('netzbetreiberId', Lada.netzbetreiber[0]);
240 this_panel.record.save({ 269 this_panel.record.save({
241 success: function(record, response) { 270 success: function(record, response) {
242 var newOrtId; 271 var newOrtId;
243 Ext.Msg.show({
244 title: Lada.getApplication().bundle.getMsg('success'),
245 autoScroll: true,
246 msg: 'Ort erfolgreich angelegt!',
247 buttons: Ext.Msg.OK
248 });
249 var ozw = this_panel.up().parentWindow; 272 var ozw = this_panel.up().parentWindow;
250 ozw.ortstore.load({ 273 ozw.ortstore.load({
251 callback: function(records, operation, success) { 274 callback: function(records, operation, success) {
252 ozw.down('map').addLocations(ozw.ortstore); 275 ozw.down('map').addLocations(ozw.ortstore);
253 ozw.down('ortstammdatengrid').setStore(ozw.ortstore); 276 var osg = ozw.down('ortstammdatengrid');
277 osg.setStore(ozw.ortstore);
254 var id = Ext.decode(response.response.responseText).data.id; 278 var id = Ext.decode(response.response.responseText).data.id;
255 var record = ozw.down('ortstammdatengrid').store.getById(id); 279 var record = osg.store.getById(id);
256 var selectionmodel = ozw.down('ortstammdatengrid').getSelectionModel(); 280 var selmod = osg.getView().getSelectionModel();
257 console.log(record); 281 selmod.select(record);
258 selectionmodel.select(record); 282 Ext.Msg.show({
283 title: Lada.getApplication().bundle.getMsg('success'),
284 autoScroll: true,
285 msg: 'Ort erfolgreich angelegt!',
286 buttons: Ext.Msg.OK
287 });
259 this_panel.close(); 288 this_panel.close();
260 }, 289 },
261 scope: this 290 scope: this
262 }); 291 });
292
263 }, 293 },
264 failure: function(record, response) { 294 failure: function(record, response) {
265 // TODO check
266 var json = Ext.decode(response.response.responseText); 295 var json = Ext.decode(response.response.responseText);
267 if (json) { 296 if (json) {
268 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ 297 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
269 formPanel.setMessages(json.errors, json.warnings); 298 formPanel.setMessages(json.errors, json.warnings);
270 } 299 }

http://lada.wald.intevation.org