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@202: Ext.define('Lada.controller.Status', { torsten@295: extend: 'Lada.controller.Base', raimund@491: torsten@202: views: [ torsten@202: 'status.Create' torsten@202: ], raimund@491: torsten@202: stores: [ torsten@202: 'Status' torsten@202: ], raimund@491: torsten@202: init: function() { torsten@202: console.log('Initialising the Status controller'); raimund@491: this.callParent(arguments); torsten@295: }, raimund@491: torsten@295: addListeners: function() { torsten@202: this.control({ torsten@202: 'statuslist': { torsten@295: itemdblclick: this.editItem torsten@202: }, torsten@202: 'statuslist toolbar button[action=add]': { torsten@295: click: this.addItem torsten@202: }, torsten@202: 'statuslist toolbar button[action=delete]': { torsten@295: click: this.deleteItem torsten@202: }, torsten@202: 'statuscreate form': { torsten@202: savesuccess: this.createSuccess, torsten@202: savefailure: this.createFailure torsten@202: }, torsten@202: 'statuscreate button[action=save]': { torsten@295: click: this.saveItem torsten@202: }, torsten@202: 'statusedit form': { torsten@202: savesuccess: this.editSuccess, torsten@202: savefailure: this.editFailure torsten@202: } torsten@202: }); torsten@202: }, raimund@491: torsten@295: addItem: function(button) { torsten@202: var zusatzwert = Ext.create('Lada.model.Status'); torsten@202: zusatzwert.set('probeId', button.probeId); torsten@202: zusatzwert.set('messungsId', button.parentId); raimund@491: var view = Ext.widget('statuscreate', { raimund@491: model: zusatzwert raimund@491: }); torsten@202: }, raimund@491: torsten@295: editItem: function(grid, record) { torsten@202: console.log('Editing Status'); raimund@490: var mstore = Ext.data.StoreManager.get('Messungen'); raimund@490: var messung = mstore.getById(record.get('messungsId')); raimund@490: record.getAuthInfo(this.initEditWindow, messung.get('probeId')); torsten@362: console.log("Loaded Status with ID " + record.getId()); //outputs ID torsten@362: }, raimund@491: torsten@362: initEditWindow: function(record, readonly, owner) { raimund@491: var view = Ext.widget('statuscreate', { raimund@491: model: record raimund@491: }); 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@202: }, raimund@491: torsten@202: createSuccess: function(form, record, operation) { torsten@202: // Reload store torsten@202: var store = this.getStatusStore(); torsten@202: store.reload(); torsten@202: var win = form.up('window'); torsten@202: win.close(); torsten@202: }, raimund@491: torsten@202: editSuccess: function(form, record, operation) { torsten@202: // Reload store torsten@202: var store = this.getStatusStore(); torsten@202: store.reload(); torsten@202: var win = form.up('window'); torsten@202: win.close(); rrenkert@422: } torsten@202: });