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