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 raimund@497: * 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() { raimund@491: this.callParent(arguments); torsten@296: }, raimund@491: torsten@296: addListeners: function() { torsten@110: this.control({ roland@540: 'zusatzwertelist toolbar button[action=open]': { roland@540: click: this.editItem roland@540: }, 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: var form = button.up('window').down('form'); torsten@451: form.commit(); torsten@451: }, raimund@491: torsten@451: addItem: function(button) { torsten@126: var zusatzwert = Ext.create('Lada.model.Zusatzwert'); torsten@126: zusatzwert.set('probeId', button.probeId); raimund@497: Ext.widget('zusatzwertecreate', { raimund@491: model: zusatzwert raimund@491: }); torsten@110: }, raimund@491: roland@540: editItem: function(button) { roland@540: var grid = button.up('grid'); roland@540: var selection = grid.getView().getSelectionModel().getSelection()[0]; roland@540: var id = selection.getId(); roland@540: var record = selection.store.getById(id); roland@540: raimund@497: record.getAuthInfo(this.initEditWindow); torsten@362: }, raimund@491: raimund@497: initEditWindow: function(record, readonly) { 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; raimund@497: var ignore = []; torsten@362: if (readonly) { torsten@362: var form = view.down('form'); torsten@362: form.setReadOnly(true, ignore); torsten@362: } torsten@110: }, raimund@491: raimund@497: createSuccess: function(form) { 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: raimund@497: editSuccess: function(form) { 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: });