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@285: /** torsten@285: * Controller for Kommentare torsten@285: */ torsten@54: Ext.define('Lada.controller.Kommentare', { torsten@286: extend: 'Lada.controller.Base', raimund@491: torsten@54: views: [ torsten@107: 'kommentare.Create' torsten@54: ], raimund@491: torsten@54: stores: [ raimund@490: 'KommentareP' torsten@54: ], raimund@491: torsten@54: models: [ raimund@490: 'KommentarP' torsten@54: ], raimund@491: torsten@288: init: function() { torsten@288: console.log('Initialising the Kommentare controller'); torsten@288: this.callParent(); torsten@288: }, raimund@491: torsten@286: addListeners: function() { torsten@54: this.control({ torsten@55: 'kommentarelist': { torsten@286: itemdblclick: this.editItem torsten@59: }, torsten@60: 'kommentarelist toolbar button[action=add]': { torsten@286: click: this.addItem torsten@60: }, torsten@59: 'kommentarelist toolbar button[action=delete]': { torsten@286: click: this.deleteItem torsten@60: }, torsten@144: 'kommentarecreate button[action=save]': { torsten@286: click: this.saveItem torsten@144: }, torsten@111: 'kommentarecreate form': { torsten@111: savesuccess: this.createSuccess, torsten@111: savefailure: this.createFailure torsten@55: } torsten@54: }); torsten@54: }, raimund@491: torsten@286: addItem: function(button) { torsten@144: console.log('Adding new Kommentar for Probe ' + button.probeId); raimund@490: var kommentar = Ext.create('Lada.model.KommentarP'); torsten@144: kommentar.set('probeId', button.probeId); raimund@491: var view = Ext.widget('kommentarecreate', { raimund@491: model: kommentar raimund@491: }); torsten@111: }, raimund@491: torsten@286: editItem: function(grid, record) { torsten@111: console.log('Editing Kommentar'); torsten@362: record.getAuthInfo(this.initEditWindow) torsten@362: console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID torsten@362: }, raimund@491: torsten@362: initEditWindow: function(record, readonly, owner) { raimund@491: var view = Ext.widget('kommentarecreate', { 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@60: }, raimund@491: torsten@111: createSuccess: function(form, record, operation) { raimund@490: var store = this.getKommentarePStore(); torsten@111: store.reload(); torsten@111: var win = form.up('window'); torsten@111: win.close(); torsten@54: } torsten@54: });