Mercurial > lada > lada-client
changeset 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 | e9fb4814153a |
children | 5414e611097e |
files | app/controller/Orte.js app/model/Ort.js app/model/Ortdetail.js app/view/orte/Create.js app/view/orte/CreateForm.js app/view/proben/EditForm.js |
diffstat | 6 files changed, 45 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/Orte.js Tue Jul 02 14:08:18 2013 +0200 +++ b/app/controller/Orte.js Tue Jul 02 15:28:41 2013 +0200 @@ -43,7 +43,44 @@ saveOrt: function(button) { console.log('Saving Ort'); var form = button.up('window').down('form'); - form.commit(); + var fform = form.getForm(); + + var ortdetail = null; + var ortdetailstore = Ext.getStore('Ortedetails'); + var newortdetail = true; + + var ortid = fform.findField('ortId').getValue(); + if (ortid === null) { + console.log('New Ortdetail'); + ortdetail = Ext.create('Lada.model.Ortdetail'); + ortdetailstore.add(ortdetail); + newortdetail = true; + } else { + console.log('Editing Ortdetail'); + ortdetail = ortdetailstore.getById(ortid); + } + + var fields = ['beschreibung', 'bezeichnung', 'hoeheLand', + 'latitude', 'longitude', 'staatId', 'gemId']; + for (var i = fields.length - 1; i >= 0; i--){ + ffield = fform.findField("ort_"+fields[i]); + ortdetail.set(fields[i], ffield.getValue()); + } + // Create a new Ortedetail if nessecary + ortdetailstore.sync({ + success: function() { + if (newortdetail) { + // TODO: Get ID from new created ortdetail and set it to the ort + ortid = 1; + form.model.set('ortId', ortid); + } + form.commit(); + }, + failure: function() { + console.log('Error on saving Ortdetails'); + } + }); + }, addOrt: function(button) { console.log('Adding new Ort for Probe ' + button.probeId);
--- a/app/model/Ort.js Tue Jul 02 14:08:18 2013 +0200 +++ b/app/model/Ort.js Tue Jul 02 15:28:41 2013 +0200 @@ -6,7 +6,7 @@ {name: "ortId", type: 'int'}, {name: "probeId"}, {name: "ortsTyp"}, - {name: "ortzusatztext"}, + {name: "ortszusatztext"}, {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()} ], idProperty: "portId",
--- a/app/model/Ortdetail.js Tue Jul 02 14:08:18 2013 +0200 +++ b/app/model/Ortdetail.js Tue Jul 02 15:28:41 2013 +0200 @@ -4,7 +4,7 @@ {name: "ortId"}, {name: "bezeichnung"}, {name: "beschreibung"}, - {name: "usnscharf"}, + {name: "unscharf"}, {name: "nutsCode"}, {name: "koordXExtern"}, {name: "koordYExtern"}, @@ -14,7 +14,7 @@ {name: "latitude", type: 'float'}, {name: "staatId"}, {name: "gemId"}, - {name: "oTyp"} + {name: "otyp"} ], idProperty: "ortId", proxy: {
--- a/app/view/orte/Create.js Tue Jul 02 14:08:18 2013 +0200 +++ b/app/view/orte/Create.js Tue Jul 02 15:28:41 2013 +0200 @@ -11,7 +11,7 @@ 'Lada.view.orte.CreateForm' ], initComponent: function() { - var form = Ext.create('Lada.view.orte.CreateForm'); + var form = Ext.create('Lada.view.orte.CreateForm', this.initialConfig); this.items = [form]; this.buttons = [ {
--- a/app/view/orte/CreateForm.js Tue Jul 02 14:08:18 2013 +0200 +++ b/app/view/orte/CreateForm.js Tue Jul 02 15:28:41 2013 +0200 @@ -26,10 +26,7 @@ for (var i = fields.length - 1; i >= 0; i--){ ffield = form.findField("ort_"+fields[i]); ffield.setValue(ort.get(fields[i])); - ffield.setReadOnly(true); } - } else { - this.setReadOnly(false); } } } @@ -38,7 +35,7 @@ xtype: 'textfield', name: 'ortsTyp', maxLength: 1, - fieldLabel: 'Type' + fieldLabel: 'Typ' }, { xtype: 'textareafield',