Mercurial > lada > lada-client
changeset 108:6c69bbb61c65
Added Forms to add Messungen
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Wed, 19 Jun 2013 14:09:53 +0200 |
parents | 84f32c62670f |
children | 2308094f5a8c |
files | app.js app/controller/Messungen.js app/view/messungen/Create.js app/view/messungen/CreateForm.js |
diffstat | 4 files changed, 146 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/app.js Wed Jun 19 11:43:25 2013 +0200 +++ b/app.js Wed Jun 19 14:09:53 2013 +0200 @@ -19,6 +19,8 @@ controllers: [ 'Proben', 'Kommentare', - 'Sql' + 'Sql', + 'Messungen' + ] });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/controller/Messungen.js Wed Jun 19 14:09:53 2013 +0200 @@ -0,0 +1,90 @@ +Ext.define('Lada.controller.Messungen', { + extend: 'Ext.app.Controller', + views: [ + 'messungen.List', + 'messungen.Create' + ], + stores: [ + ], + models: [ + 'Zusatzwert' + ], + init: function() { + console.log('Initialising the Messungen controller'); + this.control({ + // CSS like selector to select element in the viewpzusatzwert. See + // ComponentQuery documentation for more details. + 'messungenlist': { + itemdblclick: this.editZusatzwert + }, + 'messungenlist toolbar button[action=add]': { + click: this.addZusatzwert + }, + 'messungenlist toolbar button[action=delete]': { + click: this.deleteZusatzwert + }, + 'messungencreate form': { + savesuccess: this.createSuccess, + savefailure: this.createFailure + }, + 'messungenedit form': { + savesuccess: this.editSuccess, + savefailure: this.editFailure + } + }); + }, + addZusatzwert: function(button) { + console.log('Adding new Zusatzwert'); + var view = Ext.widget('messungencreate'); + }, + editZusatzwert: function(grid, record) { + console.log('Editing Zusatzwert'); + var view = Ext.widget('messungencreate', {model: record}); + console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID + }, + deleteZusatzwert: function(button) { + // Get selected item in grid + var grid = button.up('grid'); + var selection = grid.getView().getSelectionModel().getSelection()[0]; + Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ + if(btn === 'yes'){ + var store = grid.getStore(); + store.remove(selection); + store.sync(); + console.log('Deleting Kommentar'); + } else { + console.log('Cancel Deleting Kommentar'); + } + }); + }, + createSuccess: function(form, record, operation) { + // Reload store + var store = this.getMessungenStore(); + store.reload(); + var win = form.up('window'); + win.close(); + }, + createFailure: function(form, record, operation) { + Ext.MessageBox.show({ + title: 'Fehler beim Speichern', + msg: form.message, + icon: Ext.MessageBox.ERROR, + buttons: Ext.Msg.OK + }); + }, + editSuccess: function(form, record, operation) { + // Reload store + var store = this.getMessungenStore(); + store.reload(); + var win = form.up('window'); + win.close(); + }, + editFailure: function(form, record, operation) { + Ext.MessageBox.show({ + title: 'Fehler beim Speichern', + msg: form.message, + icon: Ext.MessageBox.ERROR, + buttons: Ext.Msg.OK + }); + } +});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/messungen/Create.js Wed Jun 19 14:09:53 2013 +0200 @@ -0,0 +1,29 @@ +Ext.define('Lada.view.messungen.Create', { + extend: 'Ext.window.Window', + alias: 'widget.messungencreate', + + title: 'Maske für Messungen', + // Make size of the dialog dependend of the available space. + // TODO: Handle resizing the browser window. + width: Ext.getBody().getViewSize().width - 30, + height: Ext.getBody().getViewSize().height - 30, + autoShow: true, + autoScroll: true, + modal: true, + + requires: [ + 'Lada.view.messungen.CreateForm' + ], + initComponent: function() { + var form = Ext.create('Lada.view.messungen.CreateForm'); + this.items = [form]; + this.buttons = [ + { + text: 'Speichern', + handler: form.commit, + scope: form + } + ]; + this.callParent(); + } +});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/messungen/CreateForm.js Wed Jun 19 14:09:53 2013 +0200 @@ -0,0 +1,24 @@ +Ext.define('Lada.view.messungen.CreateForm', { + extend: 'Lada.view.widgets.LadaForm', + model: 'Lada.model.Messung', + initComponent: function() { + this.items = [ + //{ + // xtype: 'textfield', + // name: 'erzeuger', + // fieldLabel: 'Erzeuger' + //}, + //{ + // xtype: 'datefield', + // name: 'kdatum', + // fieldLabel: 'Datum' + //}, + //{ + // xtype: 'textareafield', + // name: 'ktext', + // fieldLabel: 'Text' + //} + ]; + this.callParent(); + } +});