torsten@108: Ext.define('Lada.controller.Messungen', { torsten@108: extend: 'Ext.app.Controller', torsten@172: views: [ torsten@172: 'messungen.Create' torsten@172: ], torsten@108: stores: [ torsten@163: 'Messungen', torsten@168: 'Messwerte', torsten@168: 'MKommentare', torsten@168: 'Status' torsten@108: ], torsten@108: init: function() { torsten@108: console.log('Initialising the Messungen controller'); torsten@108: this.control({ torsten@108: // CSS like selector to select element in the viewpzusatzwert. See torsten@108: // ComponentQuery documentation for more details. torsten@108: 'messungenlist': { torsten@108: itemdblclick: this.editZusatzwert torsten@108: }, torsten@108: 'messungenlist toolbar button[action=add]': { torsten@108: click: this.addZusatzwert torsten@108: }, torsten@108: 'messungenlist toolbar button[action=delete]': { torsten@108: click: this.deleteZusatzwert torsten@108: }, torsten@108: 'messungencreate form': { torsten@108: savesuccess: this.createSuccess, torsten@108: savefailure: this.createFailure torsten@108: }, torsten@108: 'messungenedit form': { torsten@108: savesuccess: this.editSuccess, torsten@108: savefailure: this.editFailure torsten@108: } torsten@108: }); torsten@108: }, torsten@108: addZusatzwert: function(button) { torsten@172: console.log('Adding new Messung for Probe ' + button.probeId); torsten@172: var messung = Ext.create('Lada.model.Messung'); torsten@172: messung.set('probeId', button.probeId); torsten@172: var view = Ext.widget('messungencreate', {model: messung}); torsten@108: }, torsten@108: editZusatzwert: function(grid, record) { torsten@108: console.log('Editing Zusatzwert'); torsten@108: var view = Ext.widget('messungencreate', {model: record}); torsten@108: console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID torsten@108: }, torsten@108: deleteZusatzwert: function(button) { torsten@108: // Get selected item in grid torsten@108: var grid = button.up('grid'); torsten@108: var selection = grid.getView().getSelectionModel().getSelection()[0]; torsten@108: Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ torsten@108: if(btn === 'yes'){ torsten@108: var store = grid.getStore(); torsten@108: store.remove(selection); torsten@108: store.sync(); torsten@108: console.log('Deleting Kommentar'); torsten@108: } else { torsten@108: console.log('Cancel Deleting Kommentar'); torsten@108: } torsten@108: }); torsten@108: }, torsten@108: createSuccess: function(form, record, operation) { torsten@108: // Reload store torsten@108: var store = this.getMessungenStore(); torsten@108: store.reload(); torsten@108: var win = form.up('window'); torsten@108: win.close(); torsten@108: }, torsten@108: createFailure: function(form, record, operation) { torsten@108: Ext.MessageBox.show({ torsten@108: title: 'Fehler beim Speichern', torsten@108: msg: form.message, torsten@108: icon: Ext.MessageBox.ERROR, torsten@108: buttons: Ext.Msg.OK torsten@108: }); torsten@108: }, torsten@108: editSuccess: function(form, record, operation) { torsten@108: // Reload store torsten@108: var store = this.getMessungenStore(); torsten@108: store.reload(); torsten@108: var win = form.up('window'); torsten@108: win.close(); torsten@108: }, torsten@108: editFailure: function(form, record, operation) { torsten@108: Ext.MessageBox.show({ torsten@108: title: 'Fehler beim Speichern', torsten@108: msg: form.message, torsten@108: icon: Ext.MessageBox.ERROR, torsten@108: buttons: Ext.Msg.OK torsten@108: }); torsten@108: } torsten@108: });