torsten@1: Ext.define('Lada.controller.Proben', { torsten@1: extend: 'Ext.app.Controller', torsten@4: views: [ torsten@65: 'proben.Edit', torsten@65: 'proben.Create' torsten@4: ], torsten@13: stores: [ torsten@122: 'Proben', torsten@135: 'Zusatzwerte', torsten@144: 'Probenzusatzwerte', torsten@149: 'Kommentare', torsten@157: 'Orte', torsten@157: 'Messungen' torsten@13: ], torsten@1: init: function() { torsten@1: console.log('Initialising the Proben controller'); torsten@1: this.control({ torsten@1: // CSS like selector to select element in the viewport. See torsten@1: // ComponentQuery documentation for more details. torsten@18: 'probenlist': { torsten@5: itemdblclick: this.editProbe torsten@18: }, torsten@64: 'probenlist toolbar button[action=add]': { torsten@64: click: this.addProbe torsten@64: }, torsten@70: 'probencreate form': { torsten@70: savesuccess: this.createSuccess, torsten@70: savefailure: this.createFailure torsten@70: }, torsten@70: 'probenedit form': { torsten@70: savesuccess: this.editSuccess, torsten@70: savefailure: this.editFailure torsten@1: } torsten@1: }); torsten@1: }, torsten@64: addProbe: function(button) { torsten@71: console.log('Adding new Probe'); torsten@65: var view = Ext.widget('probencreate'); torsten@64: }, torsten@5: editProbe: function(grid, record) { torsten@71: console.log('Editing Probe'); torsten@71: var id = record.get('probeId'); torsten@71: var view = Ext.widget('probenedit', {modelId: id}); torsten@122: torsten@122: // Load Zusatzwerte torsten@135: var pstore = this.getProbenzusatzwerteStore(); torsten@135: pstore.load(); torsten@122: var zstore = this.getZusatzwerteStore(); torsten@122: zstore.load({ torsten@122: params: { torsten@139: probeId: id torsten@122: } torsten@122: }); torsten@149: // Load Kommentare torsten@144: var kstore = this.getKommentareStore(); torsten@144: kstore.load({ torsten@144: params: { torsten@144: probeId: id torsten@144: } torsten@144: }); torsten@149: // Load Orte torsten@149: var ostore = this.getOrteStore(); torsten@149: ostore.load({ torsten@149: params: { torsten@149: probeId: id torsten@149: } torsten@149: }); torsten@157: // Load Orte torsten@157: var mstore = this.getMessungenStore(); torsten@157: mstore.load({ torsten@157: params: { torsten@157: probeId: id torsten@157: } torsten@157: }); torsten@71: console.log("Loaded Probe with ID " + record.getId()); //outputs ID torsten@18: }, torsten@255: createSuccess: function(form, record, response) { torsten@256: // Close Createdialog torsten@69: var win = form.up('window'); torsten@18: win.close(); torsten@256: // Reload store torsten@256: var store = this.getProbenStore(); torsten@256: store.reload({ torsten@256: scope: this, torsten@256: callback: function(records, operation, success) { torsten@256: console.log('Reloaded store'); torsten@256: // Open Editdialog torsten@256: var json = Ext.decode(response.responseText); torsten@256: if (json) { torsten@256: var probeId = json.data.probeId; torsten@256: var probe = store.findRecord("probeId", probeId); torsten@256: this.editProbe(null, probe); torsten@256: } torsten@256: } torsten@256: }); torsten@70: }, torsten@255: createFailure: function(form, record, response) { torsten@70: Ext.MessageBox.show({ torsten@70: title: 'Fehler beim Speichern', torsten@76: msg: form.message, torsten@70: icon: Ext.MessageBox.ERROR, torsten@70: buttons: Ext.Msg.OK torsten@70: }); torsten@70: }, torsten@255: editSuccess: function(form, record, response) { torsten@86: // Reload store torsten@86: var store = this.getProbenStore(); torsten@86: store.reload(); torsten@70: var win = form.up('window'); torsten@70: win.close(); torsten@70: }, torsten@255: editFailure: function(form, record, response) { torsten@70: Ext.MessageBox.show({ torsten@70: title: 'Fehler beim Speichern', torsten@76: msg: form.message, torsten@70: icon: Ext.MessageBox.ERROR, torsten@70: buttons: Ext.Msg.OK torsten@70: }); torsten@1: } torsten@1: });