raimund@590: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@590: * Software engineering by Intevation GmbH raimund@590: * raimund@590: * This file is Free Software under the GNU GPL (v>=3) raimund@590: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@590: * the documentation coming with IMIS-Labordaten-Application for details. raimund@590: */ raimund@590: raimund@590: Ext.define('Lada.controller.grid.Messwert', { raimund@590: extend: 'Ext.app.Controller', raimund@590: raimund@590: init: function() { raimund@590: this.control({ raimund@590: 'messwertgrid': { raimund@590: edit: this.gridSave raimund@590: }, raimund@590: 'messwertgrid button[action=add]': { raimund@590: click: this.add raimund@590: }, raimund@590: 'messwertgrid button[action=delete]': { raimund@590: click: this.remove raimund@590: } raimund@590: }); raimund@590: }, raimund@590: raimund@590: gridSave: function(editor, context) { raimund@590: context.record.save({ raimund@590: success: function() { raimund@590: context.grid.store.reload(); raimund@590: context.grid.up('window').initData(); raimund@590: }, raimund@590: failure: function() { raimund@590: // TODO raimund@590: } raimund@590: }); raimund@590: }, raimund@590: raimund@590: add: function(button) { raimund@590: var record = Ext.create('Lada.model.Messwert', { raimund@590: messungsId: button.up('messwertgrid').recordId raimund@590: }); raimund@590: button.up('messwertgrid').store.insert(0, record); raimund@590: button.up('messwertgrid').rowEditing.startEdit(0, 1); raimund@590: }, raimund@590: raimund@590: remove: function(button) { raimund@590: var grid = button.up('grid'); raimund@590: var selection = grid.getView().getSelectionModel().getSelection()[0]; raimund@590: Ext.MessageBox.confirm('Messwert löschen', 'Sind Sie sicher?', function(btn) { raimund@590: if (btn === 'yes') { raimund@590: selection.destroy({ raimund@590: success: function() { raimund@590: button.up('window').initData(); raimund@590: grid.initData(); raimund@590: }, raimund@590: failure: function() { raimund@590: // TODO raimund@590: } raimund@590: }); raimund@590: } raimund@590: }); raimund@590: } raimund@590: });