Mercurial > lada > lada-client
comparison app/controller/Proben.js @ 491:850ccfe5f3c4
Code style.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 31 Oct 2014 23:23:32 +0100 |
parents | 446e99cfd425 |
children | d07e5086a64b |
comparison
equal
deleted
inserted
replaced
490:446e99cfd425 | 491:850ccfe5f3c4 |
---|---|
77 return out.join(""); | 77 return out.join(""); |
78 } | 78 } |
79 | 79 |
80 Ext.define('Lada.controller.Proben', { | 80 Ext.define('Lada.controller.Proben', { |
81 extend: 'Lada.controller.Base', | 81 extend: 'Lada.controller.Base', |
82 | |
82 views: [ | 83 views: [ |
83 'proben.Edit', | 84 'proben.Edit', |
84 'proben.Create', | 85 'proben.Create', |
85 'proben.Import' | 86 'proben.Import' |
86 ], | 87 ], |
88 | |
87 stores: [ | 89 stores: [ |
88 'Proben', | 90 'Proben', |
89 'Zusatzwerte', | 91 'Zusatzwerte', |
90 'Probenzusatzwerte', | 92 'Probenzusatzwerte', |
91 'KommentareP', | 93 'KommentareP', |
92 'Orte', | 94 'Orte', |
93 'Messungen' | 95 'Messungen' |
94 ], | 96 ], |
97 | |
95 init: function() { | 98 init: function() { |
96 console.log('Initialising the Proben controller'); | 99 console.log('Initialising the Proben controller'); |
97 this.callParent(); | 100 this.callParent(arguments); |
98 }, | 101 }, |
102 | |
99 addListeners: function() { | 103 addListeners: function() { |
100 this.control({ | 104 this.control({ |
101 'probenlist': { | 105 'probenlist': { |
102 itemdblclick: this.editItem | 106 itemdblclick: this.editItem |
103 }, | 107 }, |
127 savesuccess: this.editSuccess, | 131 savesuccess: this.editSuccess, |
128 savefailure: this.editFailure | 132 savefailure: this.editFailure |
129 } | 133 } |
130 }); | 134 }); |
131 }, | 135 }, |
136 | |
132 addItem: function(button) { | 137 addItem: function(button) { |
133 console.log('Adding new Probe'); | 138 console.log('Adding new Probe'); |
134 var view = Ext.widget('probencreate'); | 139 var view = Ext.widget('probencreate'); |
135 }, | 140 }, |
141 | |
136 /** | 142 /** |
137 * Opens a window with a file chooser to select the file to upload | 143 * Opens a window with a file chooser to select the file to upload |
138 * @private | 144 * @private |
139 */ | 145 */ |
140 selectUploadFile: function(button) { | 146 selectUploadFile: function(button) { |
141 console.log('Importing'); | 147 console.log('Importing'); |
142 var view = Ext.widget('probenimport'); | 148 var view = Ext.widget('probenimport'); |
143 }, | 149 }, |
150 | |
144 /** Uploads the selected file the the server | 151 /** Uploads the selected file the the server |
145 * @private | 152 * @private |
146 */ | 153 */ |
147 uploadItem: function(button) { | 154 uploadItem: function(button) { |
148 var win = button.up('window'); | 155 var win = button.up('window'); |
149 var form = win.down('form'); | 156 var form = win.down('form'); |
150 if(form.isValid()){ | 157 if (form.isValid()) { |
151 form.submit({ | 158 form.submit({ |
152 url: 'server/rest/import/laf', | 159 url: 'server/rest/import/laf', |
153 waitMsg: 'Importiere...', | 160 waitMsg: 'Importiere...', |
154 // TODO: Handle the response correct. o must must contain the | 161 // TODO: Handle the response correct. o must must contain the |
155 // filename (None) <2013-08-13 16:17> | 162 // filename (None) <2013-08-13 16:17> |
173 win.close(); | 180 win.close(); |
174 } | 181 } |
175 }); | 182 }); |
176 } | 183 } |
177 }, | 184 }, |
185 | |
178 /** | 186 /** |
179 * Will download the selected Probe in LAF format in a new window (tab). | 187 * Will download the selected Probe in LAF format in a new window (tab). |
180 */ | 188 */ |
181 downloadFile: function(button) { | 189 downloadFile: function(button) { |
182 var grid = button.up('grid'); | 190 var grid = button.up('grid'); |
183 var selection = grid.getView().getSelectionModel().getSelection(); | 191 var selection = grid.getView().getSelectionModel().getSelection(); |
184 var hiddenItems = []; | 192 var hiddenItems = []; |
185 for (var i = 0; i < selection.length; i++) { | 193 for (var i = 0; i < selection.length; i++) { |
186 hiddenItems.push({xtype: 'hiddenfield', name: 'probeId', value: selection[i].get('probeId')}); | 194 hiddenItems.push({ |
195 xtype: 'hiddenfield', | |
196 name: 'probeId', | |
197 value: selection[i].get('probeId') | |
198 }); | |
187 } | 199 } |
188 console.log('create download form.'); | 200 console.log('create download form.'); |
189 var hiddenForm = Ext.create('Ext.form.Panel', { | 201 var hiddenForm = Ext.create('Ext.form.Panel', { |
190 title: 'hiddenForm', | 202 title: 'hiddenForm', |
191 standardSubmit: true, | 203 standardSubmit: true, |
196 hidden: true, | 208 hidden: true, |
197 items: hiddenItems | 209 items: hiddenItems |
198 }); | 210 }); |
199 hiddenForm.getForm().submit(); | 211 hiddenForm.getForm().submit(); |
200 }, | 212 }, |
213 | |
201 editItem: function(grid, record) { | 214 editItem: function(grid, record) { |
202 console.log('Editing Probe'); | 215 console.log('Editing Probe'); |
203 var id = record.get('id'); | 216 var id = record.get('id'); |
204 console.log('id is: ' + id); | 217 console.log('id is: ' + id); |
205 // Load Zusatzwerte | 218 // Load Zusatzwerte |
230 mstore.load({ | 243 mstore.load({ |
231 params: { | 244 params: { |
232 probeId: id | 245 probeId: id |
233 } | 246 } |
234 }); | 247 }); |
235 var view = Ext.widget('probenedit', {modelId: id}); | 248 var view = Ext.widget('probenedit', { |
249 modelId: id | |
250 }); | |
236 view.show(); | 251 view.show(); |
237 console.log("Loaded Probe with ID " + record.getId()); //outputs ID | 252 console.log("Loaded Probe with ID " + record.getId()); //outputs ID |
238 }, | 253 }, |
254 | |
239 createSuccess: function(form, record, response) { | 255 createSuccess: function(form, record, response) { |
240 // Close Createdialog | 256 // Close Createdialog |
241 var win = form.up('window'); | 257 var win = form.up('window'); |
242 win.close(); | 258 win.close(); |
243 var store = this.getProbenStore(); | 259 var store = this.getProbenStore(); |
271 } | 287 } |
272 } | 288 } |
273 }); | 289 }); |
274 } | 290 } |
275 }, | 291 }, |
292 | |
276 editSuccess: function(form, record, response) { | 293 editSuccess: function(form, record, response) { |
277 // Reload store | 294 // Reload store |
278 var store = this.getProbenStore(); | 295 var store = this.getProbenStore(); |
279 store.reload(); | 296 store.reload(); |
280 var win = form.up('window'); | 297 var win = form.up('window'); |