Mercurial > lada > lada-client
diff app/controller/Orte.js @ 447:12231f31c112
Apply new workflow in orte dialog.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 05 Dec 2013 09:57:57 +0100 |
parents | 6a7a9267e00f |
children | edb9dee114f8 |
line wrap: on
line diff
--- a/app/controller/Orte.js Thu Dec 05 09:56:50 2013 +0100 +++ b/app/controller/Orte.js Thu Dec 05 09:57:57 2013 +0100 @@ -5,7 +5,8 @@ extend: 'Lada.controller.Base', views: [ 'orte.List', - 'orte.Create' + 'orte.Create', + 'orte.CreateOrt' ], stores: [ 'Orte', @@ -34,6 +35,12 @@ 'ortecreate button[action=save]': { click: this.saveItem }, + 'ortecreate form button[action=newort]': { + click: this.createOrt + }, + 'createortdetail button[action=save]': { + click: this.saveNewOrt + }, 'ortecreate form': { savesuccess: this.createSuccess, savefailure: this.createFailure @@ -44,6 +51,41 @@ } }); }, + createOrt: function(button) { + console.log('button clicked'); + var win = Ext.create('Lada.view.orte.CreateOrt',{}); + win.show(); + }, + saveNewOrt: function(button) { + console.log('button clicked'); + + var form = button.up('window').down('form').getForm(); + var ortdetailstore = Ext.getStore('Ortedetails'); + var ortdetail = Ext.create('Lada.model.Ortdetail'); + var fields = ['beschreibung', 'hoeheLand', + 'latitude', 'longitude', 'staatId', 'gemId']; + for (var i = fields.length - 1; i >= 0; i--){ + var ffield = form.findField("ort_"+fields[i]); + ortdetail.set(fields[i], ffield.getValue()); + } + ortdetailstore.add(ortdetail); + ortdetailstore.sync({ + success: function(batch, options) { + console.log(batch); + var od = Ext.ComponentQuery.query('ortdetail'); + console.log(od); + batch.operations[0].resultSet.records[0].data; + var response = batch.operations[0].resultSet.records[0].data; + od[0].setValue(response.ortId); + console.log('id:' + response.ortId); + button.up('window').close(); + }, + failure: function() { + console.log('Error on saving Ortdetails'); + ortdetailstore.remove(ortdetail); + } + }); + }, saveItem: function(button) { console.log('Saving Ort'); var form = button.up('window').down('form'); @@ -100,7 +142,7 @@ console.log("Loaded Ort with ID " + record.getId()); //outputs ID }, initEditWindow: function(record, readonly, owner) { - var view = Ext.widget('ortecreate', {model: record}); + var view = Ext.widget('ortecreate', {model: record, edit: true}); var ignore = Array(); if (readonly) { var form = view.down('form');