torsten@472: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz torsten@472: * Software engineering by Intevation GmbH torsten@472: * torsten@472: * This file is Free Software under the GNU GPL (v>=3) torsten@472: * and comes with ABSOLUTELY NO WARRANTY! Check out torsten@472: * the documentation coming with IMIS-Labordaten-Application for details. torsten@472: */ torsten@472: torsten@110: Ext.define('Lada.controller.Zusatzwerte', { torsten@296: extend: 'Lada.controller.Base', torsten@110: views: [ torsten@110: 'zusatzwerte.Create' torsten@110: ], raimund@491: torsten@110: stores: [ raimund@496: 'Zusatzwerte' torsten@110: ], raimund@491: torsten@110: init: function() { torsten@110: console.log('Initialising the Zusatzwerte controller'); raimund@491: this.callParent(arguments); torsten@296: }, raimund@491: torsten@296: addListeners: function() { torsten@110: this.control({ torsten@110: 'zusatzwertelist': { torsten@451: itemdblclick: this.editItem torsten@110: }, torsten@110: 'zusatzwertelist toolbar button[action=add]': { torsten@451: click: this.addItem torsten@110: }, torsten@110: 'zusatzwertelist toolbar button[action=delete]': { torsten@451: click: this.deleteItem torsten@110: }, torsten@110: 'zusatzwertecreate form': { torsten@110: savesuccess: this.createSuccess, torsten@110: savefailure: this.createFailure torsten@110: }, torsten@122: 'zusatzwertecreate button[action=save]': { torsten@451: click: this.saveItem torsten@122: }, torsten@110: 'zusatzwerteedit form': { torsten@110: savesuccess: this.editSuccess, torsten@110: savefailure: this.editFailure torsten@110: } torsten@110: }); torsten@110: }, raimund@491: torsten@451: saveItem: function(button) { torsten@451: console.log('Saving new Zusatzwert for Probe ' + button.probeId); torsten@451: var form = button.up('window').down('form'); torsten@451: form.commit(); torsten@451: }, raimund@491: torsten@451: addItem: function(button) { torsten@172: console.log('Adding new Zusatzwert for Probe' + button.probeId); torsten@126: var zusatzwert = Ext.create('Lada.model.Zusatzwert'); torsten@126: zusatzwert.set('probeId', button.probeId); raimund@491: var view = Ext.widget('zusatzwertecreate', { raimund@491: model: zusatzwert raimund@491: }); torsten@110: }, raimund@491: torsten@451: editItem: function(grid, record) { torsten@110: console.log('Editing Zusatzwert'); torsten@362: record.getAuthInfo(this.initEditWindow) torsten@362: console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID torsten@362: }, raimund@491: torsten@362: initEditWindow: function(record, readonly, owner) { raimund@491: var view = Ext.widget('zusatzwertecreate', { raimund@491: model: record raimund@491: }); torsten@264: // Mark PZW Selection readonly. torsten@264: view.down('probenzusatzwert').disabled = true; torsten@362: var ignore = Array(); torsten@362: if (readonly) { torsten@362: var form = view.down('form'); torsten@362: form.setReadOnly(true, ignore); torsten@362: } torsten@110: }, raimund@491: torsten@110: createSuccess: function(form, record, operation) { torsten@110: // Reload store torsten@110: var store = this.getZusatzwerteStore(); torsten@110: store.reload(); torsten@110: var win = form.up('window'); torsten@110: win.close(); torsten@110: }, raimund@491: torsten@110: editSuccess: function(form, record, operation) { torsten@110: // Reload store torsten@110: var store = this.getZusatzwerteStore(); torsten@110: store.reload(); torsten@110: var win = form.up('window'); torsten@110: win.close(); torsten@110: } torsten@110: });