comparison app/controller/Orte.js @ 154:16ba7e2465fd

Implemented creating and editing new l_ort. Created editing orte.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 02 Jul 2013 15:28:41 +0200
parents 26ac4c99f8c4
children 5414e611097e
comparison
equal deleted inserted replaced
153:e9fb4814153a 154:16ba7e2465fd
41 }); 41 });
42 }, 42 },
43 saveOrt: function(button) { 43 saveOrt: function(button) {
44 console.log('Saving Ort'); 44 console.log('Saving Ort');
45 var form = button.up('window').down('form'); 45 var form = button.up('window').down('form');
46 form.commit(); 46 var fform = form.getForm();
47
48 var ortdetail = null;
49 var ortdetailstore = Ext.getStore('Ortedetails');
50 var newortdetail = true;
51
52 var ortid = fform.findField('ortId').getValue();
53 if (ortid === null) {
54 console.log('New Ortdetail');
55 ortdetail = Ext.create('Lada.model.Ortdetail');
56 ortdetailstore.add(ortdetail);
57 newortdetail = true;
58 } else {
59 console.log('Editing Ortdetail');
60 ortdetail = ortdetailstore.getById(ortid);
61 }
62
63 var fields = ['beschreibung', 'bezeichnung', 'hoeheLand',
64 'latitude', 'longitude', 'staatId', 'gemId'];
65 for (var i = fields.length - 1; i >= 0; i--){
66 ffield = fform.findField("ort_"+fields[i]);
67 ortdetail.set(fields[i], ffield.getValue());
68 }
69 // Create a new Ortedetail if nessecary
70 ortdetailstore.sync({
71 success: function() {
72 if (newortdetail) {
73 // TODO: Get ID from new created ortdetail and set it to the ort
74 ortid = 1;
75 form.model.set('ortId', ortid);
76 }
77 form.commit();
78 },
79 failure: function() {
80 console.log('Error on saving Ortdetails');
81 }
82 });
83
47 }, 84 },
48 addOrt: function(button) { 85 addOrt: function(button) {
49 console.log('Adding new Ort for Probe ' + button.probeId); 86 console.log('Adding new Ort for Probe ' + button.probeId);
50 var ort = Ext.create('Lada.model.Ort'); 87 var ort = Ext.create('Lada.model.Ort');
51 ort.set('probeId', button.probeId); 88 ort.set('probeId', button.probeId);

http://lada.wald.intevation.org