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@291: /** torsten@291: * Controller for Kommentare on Messungen torsten@291: */ torsten@205: Ext.define('Lada.controller.MKommentare', { torsten@291: extend: 'Lada.controller.Base', raimund@491: torsten@207: views: [ torsten@207: 'mkommentare.Create' torsten@207: ], raimund@491: torsten@205: stores: [ raimund@490: 'KommentareM' torsten@205: ], raimund@491: torsten@205: models: [ raimund@490: 'KommentarM' torsten@205: ], raimund@491: torsten@207: init: function() { raimund@491: this.callParent(arguments); torsten@291: }, raimund@491: torsten@291: addListeners: function() { torsten@207: this.control({ torsten@207: 'mkommentarelist': { torsten@291: itemdblclick: this.editItem torsten@207: }, torsten@207: 'mkommentarelist toolbar button[action=add]': { torsten@291: click: this.addItem torsten@207: }, torsten@207: 'mkommentarelist toolbar button[action=delete]': { torsten@291: click: this.deleteItem torsten@207: }, torsten@207: 'mkommentarecreate button[action=save]': { torsten@291: click: this.saveItem torsten@207: }, torsten@207: 'mkommentarecreate form': { torsten@207: savesuccess: this.createSuccess, torsten@207: savefailure: this.createFailure torsten@207: } torsten@207: }); torsten@207: }, raimund@491: torsten@291: addItem: function(button) { raimund@490: var kommentar = Ext.create('Lada.model.KommentarM'); torsten@205: kommentar.set('probeId', button.probeId); torsten@205: kommentar.set('messungsId', button.parentId); raimund@497: Ext.widget('mkommentarecreate', { raimund@497: model: kommentar raimund@497: }); torsten@207: }, raimund@491: torsten@291: editItem: function(grid, record) { raimund@490: var mstore = Ext.data.StoreManager.get('Messungen'); raimund@490: var messung = mstore.getById(record.get('messungsId')); raimund@497: record.getAuthInfo(this.initEditWindow, messung.get('probeId')); torsten@362: }, raimund@491: raimund@497: initEditWindow: function(record, readonly) { raimund@491: var view = Ext.widget('mkommentarecreate', { raimund@491: model: record raimund@491: }); raimund@497: var ignore = []; torsten@362: if (readonly) { torsten@362: var form = view.down('form'); torsten@362: form.setReadOnly(true, ignore); torsten@362: } torsten@207: }, raimund@491: raimund@497: createSuccess: function(form) { torsten@205: // Reload store raimund@490: var store = this.getKommentareMStore(); torsten@205: store.reload(); torsten@205: var win = form.up('window'); torsten@205: win.close(); torsten@205: } torsten@205: });