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@500: * 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() { raimund@491: this.callParent(arguments); torsten@295: }, raimund@491: torsten@295: addListeners: function() { torsten@202: this.control({ roland@540: 'statuslist toolbar button[action=open]': { roland@540: click: this.editItem roland@540: }, 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@500: Ext.widget('statuscreate', { raimund@491: model: zusatzwert raimund@491: }); torsten@202: }, 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 statusId = selection.getId(); roland@540: var record = selection.store.getById(statusId); roland@540: 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: }, raimund@491: raimund@500: initEditWindow: function(record, readonly) { raimund@491: var view = Ext.widget('statuscreate', { raimund@491: model: record raimund@491: }); raimund@500: var ignore = []; torsten@362: if (readonly) { torsten@362: var form = view.down('form'); torsten@362: form.setReadOnly(true, ignore); torsten@362: } torsten@202: }, raimund@491: raimund@500: createSuccess: function(form) { 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: raimund@500: editSuccess: function(form) { 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: });