# HG changeset patch # User Torsten Irländer # Date 1369836403 -7200 # Node ID 5db7ab34af6d223e771334e81c6b1fdbfdc94654 # Parent 9e23eca8dfc770aa39c701aaeeb4795e47b532c0 Implemented Adding und Editing Kommentare diff -r 9e23eca8dfc7 -r 5db7ab34af6d app/controller/Kommentare.js --- a/app/controller/Kommentare.js Wed May 29 15:27:07 2013 +0200 +++ b/app/controller/Kommentare.js Wed May 29 16:06:43 2013 +0200 @@ -19,14 +19,28 @@ // Map Doubleclick on rows of the probenlist. itemdblclick: this.editKommentar }, + 'kommentarelist toolbar button[action=add]': { + click: this.addKommentar + }, 'kommentarelist toolbar button[action=delete]': { click: this.deleteKommentar + }, + 'kommentaredit button[action=save]': { + click: this.saveKommentar } //'probenedit button[action=save]': { // click: this.updateProbe //} }); }, + addKommentar: function(button) { + console.log('Adding new Kommentar'); + var view = Ext.widget('kommentaredit'); + var form = view.down('form'); + // Create a new Kommentar + var record = Ext.create('Lada.model.Kommentar'); + form.loadRecord(record); + }, deleteKommentar: function(button) { // Get selected item in grid var grid = button.up('grid'); @@ -66,5 +80,16 @@ //// NOTE: The function 'getProbenStore' will be generated //// dynamically based on the Name of the configured Store!!! //this.getProbenStore().sync(); + saveKommentar: function(button) { + var win = button.up('window'); + var form = win.down('form'); + var record = form.getRecord(); + var values = form.getValues(); + var store = this.getKommentareStore(); + record.set(values); + store.add(record); + store.sync(); + console.log('Saving Kommentar'); + win.close(); } });