Mercurial > lada > lada-client
comparison app/view/form/Ortszuordnung.js @ 1288:08085b7d1d0b
Ortszuordnung: Search, new orte, display and validity check
author | Maximilian Krambach <mkrambach@intevation.de> |
---|---|
date | Fri, 27 Jan 2017 13:25:14 +0100 |
parents | a792eecf1614 |
children | bfdc00c24baf |
comparison
equal
deleted
inserted
replaced
1287:e317ba349204 | 1288:08085b7d1d0b |
---|---|
14 alias: 'widget.ortszuordnungform', | 14 alias: 'widget.ortszuordnungform', |
15 | 15 |
16 model: 'Lada.model.Ortszuordnung', | 16 model: 'Lada.model.Ortszuordnung', |
17 | 17 |
18 requires: [ | 18 requires: [ |
19 'Lada.view.form.OrtInfo', | |
19 'Lada.view.widget.Verwaltungseinheit', | 20 'Lada.view.widget.Verwaltungseinheit', |
20 'Lada.view.widget.Staat' | 21 'Lada.view.widget.Staat' |
21 ], | 22 ], |
22 | 23 |
23 layout: 'fit', | 24 layout: 'fit', |
28 | 29 |
29 trackResetOnLoad: true, | 30 trackResetOnLoad: true, |
30 | 31 |
31 initComponent: function() { | 32 initComponent: function() { |
32 var i18n = Lada.getApplication().bundle; | 33 var i18n = Lada.getApplication().bundle; |
34 var me = this; | |
33 this.items = [{ | 35 this.items = [{ |
34 xtype: 'fieldset', | 36 xtype: 'fieldset', |
35 title: i18n.getMsg('ortszuordnung.form.fset.title'), | 37 title: i18n.getMsg('ortszuordnung.form.fset.title'), |
36 layout: 'fit', | 38 layout: 'fit', |
37 items: [{ | 39 items: [{ |
73 autoscroll: true, | 75 autoscroll: true, |
74 border: 0, | 76 border: 0, |
75 items: [{ | 77 items: [{ |
76 layout: 'vbox', | 78 layout: 'vbox', |
77 border: 0, | 79 border: 0, |
78 margin: '0, 10, 0, 0', | 80 margin: '0, 20, 0, 0', |
79 items: [{ | 81 items: [{ |
80 xtype: 'tfield', | 82 xtype: 'tfield', |
81 labelWidth: 125, | 83 labelWidth: 125, |
82 maxLength: 100, | 84 maxLength: 100, |
83 name: 'ortszusatztext', | 85 name: 'ortszusatztext', |
85 }, { | 87 }, { |
86 xtype: 'textfield', | 88 xtype: 'textfield', |
87 labelWidth: 125, | 89 labelWidth: 125, |
88 maxLength: 1, | 90 maxLength: 1, |
89 allowBlank: false, | 91 allowBlank: false, |
90 regex: /[UEZA]/, | 92 regex: /[UEZA]{1}/, |
91 activeError: 'U, E, Z oder A eingeben', | 93 activeError: 'U, E, Z oder A eingeben', |
92 name: 'ortszuordnungTyp', | 94 name: 'ortszuordnungTyp', |
93 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp') | 95 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp'), |
96 | |
94 }, { | 97 }, { |
95 xtype: 'displayfield', | 98 // this field is hidden because the user doesn't |
96 labelWidth: 125, | 99 // need to know the internal ortID |
97 fieldLabel: i18n.getMsg('orte.ortid'), | 100 xtype: 'textfield', |
101 // fieldLabel: i18n.getMsg('orte.ortid'), | |
102 allowBlank: false, | |
103 regex: /^[0-9]{1,45}$/, | |
98 submitValue: true, | 104 submitValue: true, |
99 name: 'ortId' | 105 hidden: true, |
106 name: 'ortId', | |
107 listeners: { | |
108 change: me.changedOrt | |
109 } | |
100 }] | 110 }] |
101 }, { | 111 }, |
102 layout: 'vbox', | 112 Ext.create('Lada.view.form.OrtInfo', { |
103 flex: 1, | 113 record: me.record |
104 margin: '0, 10, 0, 0', | 114 }) |
105 border: 0, | 115 ] |
106 items: [{ | |
107 xtype: 'displayfield', | |
108 labelWidth: 125, | |
109 fieldLabel: i18n.getMsg('orte.kurztext'), | |
110 name: 'kurztext' | |
111 }, { | |
112 xtype: 'displayfield', | |
113 labelWidth: 125, | |
114 fieldLabel: i18n.getMsg('orte.langtext'), | |
115 name: 'langtext' | |
116 }, { | |
117 xtype: 'displayfield', | |
118 labelWidth: 125, | |
119 fieldLabel: i18n.getMsg('staat'), | |
120 name: 'staatISO' | |
121 }, { | |
122 xtype: 'displayfield', | |
123 labelWidth: 125, | |
124 fieldLabel: i18n.getMsg('orte.gemeinde'), | |
125 name: 'gemeinde' | |
126 }, { | |
127 xtype: 'displayfield', | |
128 labelWidth: 125, | |
129 fieldLabel: i18n.getMsg('orte.gemeindename'), | |
130 name: 'gemeinde' | |
131 }, { | |
132 xtype: 'displayfield', | |
133 labelWidth: 125, | |
134 fieldLabel: i18n.getMsg('orte.kda'), | |
135 name: 'kdaId' | |
136 }, { | |
137 xtype: 'displayfield', | |
138 labelWidth: 125, | |
139 fieldLabel: i18n.getMsg('orte.koordx'), | |
140 name: 'koordXExtern' | |
141 }, { | |
142 xtype: 'displayfield', | |
143 labelWidth: 125, | |
144 fieldLabel: i18n.getMsg('orte.koordy'), | |
145 name: 'koordYExtern' | |
146 }] | |
147 }] | |
148 }] | 116 }] |
149 //}, { | 117 }] |
150 // layout: 'vbox', | 118 }]; |
151 // flex: 1, | |
152 // margin: '0, 10, 0, 0', | |
153 // border: 0, | |
154 // items: [{ | |
155 // xtype: '' | |
156 // }] | |
157 }] | |
158 }]; | |
159 this.callParent(arguments); | 119 this.callParent(arguments); |
160 }, | 120 }, |
161 | 121 |
162 setRecord: function(record) { | 122 setRecord: function(record) { |
163 this.getForm().loadRecord(record); | 123 this.getForm().loadRecord(record); |
164 | 124 if (!record.get('readonly')) { |
165 if (! record.get('readonly')) { | |
166 this.down('[action=setOrt]').enable(); | 125 this.down('[action=setOrt]').enable(); |
167 this.setReadOnly(false); | 126 this.setReadOnly(false); |
168 } | 127 } |
169 else { | 128 else { |
170 this.setReadOnly(true); | 129 this.setReadOnly(true); |
181 } | 140 } |
182 var verwStore = Ext.StoreManager.get('verwaltungseinheiten'); | 141 var verwStore = Ext.StoreManager.get('verwaltungseinheiten'); |
183 var verw = verwStore.getById(ort.get('gemId')); | 142 var verw = verwStore.getById(ort.get('gemId')); |
184 var staatStore = Ext.StoreManager.get('staaten'); | 143 var staatStore = Ext.StoreManager.get('staaten'); |
185 var staat = staatStore.getById(ort.get('staatId')); | 144 var staat = staatStore.getById(ort.get('staatId')); |
186 | 145 var ortinfo = this.down('ortinfo') |
187 this.getForm().setValues({ | 146 ortinfo.loadRecord(ort); |
147 ortinfo.getForm().setValues({ | |
188 gemeinde: verw.get('bezeichnung'), | 148 gemeinde: verw.get('bezeichnung'), |
189 staat: staat.get('staatIso'), | 149 staat: staat.get('staatIso'), |
190 lon: ort.get('longitude'), | 150 lon: ort.get('longitude'), |
191 lat: ort.get('latitude') | 151 lat: ort.get('latitude') |
192 }); | 152 }); |
193 }, | 153 }, |
194 | 154 |
195 /** | 155 /** |
196 * setOrt can be called from a CallbackFunction, ie select from a grid. | 156 * setOrt can be called from a CallbackFunction, ie select from a grid. |
197 * it will set the ortId of this record | 157 * it will set the ortId of this record |
198 */ | 158 */ |
199 setOrt: function(row, selRecord, index, opts) { | 159 setOrt: function(row, selRecord, index, opts) { |
200 var newOrtId = selRecord.get('id'); | 160 var newOrtId = selRecord.get('id'); |
201 var r = this.getRecord(); | 161 var r = this.getRecord(); |
202 if (newOrtId) { | 162 if (newOrtId) { |
203 if (newOrtId != r.get('ortId')) { | 163 if (newOrtId != r.get('ortId')) { |
204 r.set('ortId', newOrtId); | 164 r.set('ortId', newOrtId); |
205 this.getForm().setValues({ortId: newOrtId}); | 165 this.getForm().setValues({ortId: newOrtId}); |
206 this.refreshOrt(newOrtId); | 166 this.refreshOrt(newOrtId); |
207 //set dirty... | |
208 this.fireEvent('dirtychange', this.getForm(), true); | |
209 } | 167 } |
210 } | 168 } |
211 }, | 169 }, |
212 | 170 |
213 setMessages: function(errors, warnings) { | 171 setMessages: function(errors, warnings) { |
238 content = errors[key]; | 196 content = errors[key]; |
239 var errorText = ''; | 197 var errorText = ''; |
240 for (var i = 0; i < content.length; i++) { | 198 for (var i = 0; i < content.length; i++) { |
241 errorText += i18n.getMsg(content[i].toString()) + '\n'; | 199 errorText += i18n.getMsg(content[i].toString()) + '\n'; |
242 } | 200 } |
243 element.showErrors(errorText); | 201 element.markInvalid(errorText); |
244 } | 202 } |
245 } | 203 } |
246 }, | 204 }, |
247 | 205 |
248 clearMessages: function() { | 206 clearMessages: function() { |
250 }, | 208 }, |
251 | 209 |
252 setReadOnly: function(value) { | 210 setReadOnly: function(value) { |
253 this.down('tfield[name=ortszusatztext]').setReadOnly(value); | 211 this.down('tfield[name=ortszusatztext]').setReadOnly(value); |
254 this.down('textfield[name=ortszuordnungTyp]').setReadOnly(value); | 212 this.down('textfield[name=ortszuordnungTyp]').setReadOnly(value); |
213 }, | |
214 | |
215 /** | |
216 * Helper to trigger the forms' validity check on change of ortID | |
217 */ | |
218 changedOrt: function() { | |
219 var controller = Lada.app.getController( | |
220 'Lada.controller.form.Ortszuordnung'); | |
221 var form = this.up('form').getForm(); | |
222 controller.validityChange(form, form.isValid()); | |
223 | |
255 } | 224 } |
256 }); | 225 }); |
257 | 226 |