# HG changeset patch # User Torsten Irländer # Date 1367851299 -7200 # Node ID 9e1a40312bbe192c798bd29862fc49f9937c697e # Parent 3eaeeec2bb28d3cfb17e6fb54013eb5f8f8ed65f Implemented a basic edit dialog. Data will be set to data/proben2.json url which is currently just a dummy file to make to request work. But currently no data is actually saved. The urls need to be replaced with the correct urls in the application backend. diff -r 3eaeeec2bb28 -r 9e1a40312bbe app/controller/Proben.js --- a/app/controller/Proben.js Tue Apr 30 17:55:48 2013 +0200 +++ b/app/controller/Proben.js Mon May 06 16:41:39 2013 +0200 @@ -1,7 +1,8 @@ Ext.define('Lada.controller.Proben', { extend: 'Ext.app.Controller', views: [ - 'proben.List' + 'proben.List', + 'proben.Edit' ], stores: [ 'Proben' @@ -14,11 +15,14 @@ this.control({ // CSS like selector to select element in the viewport. See // ComponentQuery documentation for more details. - 'viewport > probenlist': { + 'probenlist': { // Map the "render" event to the given function. render: this.onPanelRendered, // Map Doubleclick on rows of the probenlist. itemdblclick: this.editProbe + }, + 'probenedit button[action=save]': { + click: this.updateProbe } }); }, @@ -27,5 +31,25 @@ }, editProbe: function(grid, record) { console.log('Double click on ' + record.get('name')); + // Create new window to edit the seletced record. + var view = Ext.widget('probenedit'); + view.down('form').loadRecord(record); + }, + updateProbe: function(button) { + console.log('Click save'); + // We only have a reference to the button here but we really wnat to + // get the form and the window. So first get the window and form and + // the the record an values. + var win = button.up('window'); + var form = win.down('form'); + var record = form.getRecord(); + var values = form.getValues(); + + record.set(values); + win.close(); + // synchronize the store after editing the record + // NOTE: The function 'getProbenStore' will be generated + // dynamically based on the Name of the configured Store!!! + this.getProbenStore().sync(); } }); diff -r 3eaeeec2bb28 -r 9e1a40312bbe app/store/Proben.js --- a/app/store/Proben.js Tue Apr 30 17:55:48 2013 +0200 +++ b/app/store/Proben.js Mon May 06 16:41:39 2013 +0200 @@ -5,7 +5,10 @@ autoLoad: true, proxy: { type: 'ajax', - url: 'data/proben.json', + api: { + read: 'data/proben.json', + update: 'data/proben2.json' + }, reader: { type: 'json', root: 'proben' diff -r 3eaeeec2bb28 -r 9e1a40312bbe app/view/proben/Edit.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/proben/Edit.js Mon May 06 16:41:39 2013 +0200 @@ -0,0 +1,41 @@ +Ext.define('Lada.view.proben.Edit', { + extend: 'Ext.window.Window', + alias: 'widget.probenedit', + + title: 'Maske für §3-Proben', + layout: 'fit', + autoShow: true, + + initComponent: function() { + this.items = [ + { + xtype: 'form', + items: [ + { + xtype: 'textfield', + name : 'probeId', + fieldLabel: 'ID' + }, + { + xtype: 'textfield', + name : 'datenbasisId', + fieldLabel: 'Datenbasis' + } + ] + } + ]; + + this.buttons = [ + { + text: 'Speichern', + action: 'save' + }, + { + text: 'Verwerfen', + scope: this, + handler: this.close + } + ]; + this.callParent(arguments); + } +});