Mercurial > lada > lada-client
comparison app/controller/Orte.js @ 155:5414e611097e
Set ortId in l_ort if new ortdetail was created.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 02 Jul 2013 15:47:45 +0200 |
parents | 16ba7e2465fd |
children | 19d79b41f95d |
comparison
equal
deleted
inserted
replaced
154:16ba7e2465fd | 155:5414e611097e |
---|---|
45 var form = button.up('window').down('form'); | 45 var form = button.up('window').down('form'); |
46 var fform = form.getForm(); | 46 var fform = form.getForm(); |
47 | 47 |
48 var ortdetail = null; | 48 var ortdetail = null; |
49 var ortdetailstore = Ext.getStore('Ortedetails'); | 49 var ortdetailstore = Ext.getStore('Ortedetails'); |
50 var newortdetail = true; | 50 var newortdetail = false; |
51 | 51 |
52 var ortid = fform.findField('ortId').getValue(); | 52 var ortid = fform.findField('ortId').getValue(); |
53 if (ortid === null) { | 53 if (ortid === null) { |
54 console.log('New Ortdetail'); | 54 console.log('New Ortdetail'); |
55 ortdetail = Ext.create('Lada.model.Ortdetail'); | 55 ortdetail = Ext.create('Lada.model.Ortdetail'); |
66 ffield = fform.findField("ort_"+fields[i]); | 66 ffield = fform.findField("ort_"+fields[i]); |
67 ortdetail.set(fields[i], ffield.getValue()); | 67 ortdetail.set(fields[i], ffield.getValue()); |
68 } | 68 } |
69 // Create a new Ortedetail if nessecary | 69 // Create a new Ortedetail if nessecary |
70 ortdetailstore.sync({ | 70 ortdetailstore.sync({ |
71 success: function() { | 71 success: function(batch, options) { |
72 if (newortdetail) { | 72 if (newortdetail) { |
73 // TODO: Get ID from new created ortdetail and set it to the ort | 73 // Get ID from new created ortdetail and set it to the ort |
74 ortid = 1; | 74 var response = options.operations.update[0].store.proxy.reader.jsonData; |
75 form.model.set('ortId', ortid); | 75 form.model.set('ortId', response.ortId); |
76 } | 76 } |
77 form.commit(); | 77 form.commit(); |
78 }, | 78 }, |
79 failure: function() { | 79 failure: function() { |
80 console.log('Error on saving Ortdetails'); | 80 console.log('Error on saving Ortdetails'); |