Mercurial > lada > lada-client
changeset 53:73bc17de6ff2
Added store, view and model for kommentare. Load kommentare when opening a probe.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 28 May 2013 10:58:47 +0200 |
parents | af418743e1f4 |
children | 3c7bfff8bd64 |
files | app/controller/Proben.js app/model/Kommentar.js app/store/Kommentare.js app/view/kommentare/List.js app/view/proben/Edit.js |
diffstat | 5 files changed, 81 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/Proben.js Mon May 27 14:59:59 2013 +0200 +++ b/app/controller/Proben.js Tue May 28 10:58:47 2013 +0200 @@ -10,7 +10,8 @@ 'Datenbasis', 'Probenart', 'Betriebsart', - 'Testdatensatz' + 'Testdatensatz', + 'Kommentare' ], models: [ 'Probe' @@ -38,13 +39,20 @@ console.log('Double click on ' + record.get('probeId')); // Create new window to edit the seletced record. var view = Ext.widget('probenedit'); - //console.log(Ext.ModelManager.getModel('Lada.model.Probe')); - Ext.ModelManager.getModel('Lada.model.Probe').load(record.get('probeId'), { - success: function(record) { - view.down('form').loadRecord(record); - console.log("Loaded probe with ID " + record.getId()); //outputs ID + var form = view.down('form'); + form.loadRecord(record); + + // Load kommentare + var kommentare = form.down('kommentarelist'); //form.down('kommentare'); + var kstore = kommentare.getStore(); + kstore.load({ + params: { + probe: record.data['probeId'] } }); + + // Set form data + console.log("Loaded probe with ID " + record.getId()); //outputs ID }, updateProbe: function(button) { console.log('Click save');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/model/Kommentar.js Tue May 28 10:58:47 2013 +0200 @@ -0,0 +1,20 @@ +Ext.define('Lada.model.Kommentar', { + extend: 'Ext.data.Model', + fields: [ + {name: "id"}, + {name: "probeId"}, + {name: "erzeuger"}, + {name: "kdatum"}, + {name: "ktext"} + ], + proxy: { + type: 'rest', + appendId: true, //default + url: 'server/rest/kommentare', + api: { + }, + reader: { + type: 'json' + } + } +});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/store/Kommentare.js Tue May 28 10:58:47 2013 +0200 @@ -0,0 +1,6 @@ +Ext.define('Lada.store.Kommentare', { + extend: 'Ext.data.Store', + storeId: 'kommentareStore', + model: 'Lada.model.Kommentar' +}); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/kommentare/List.js Tue May 28 10:58:47 2013 +0200 @@ -0,0 +1,38 @@ +Ext.define('Lada.view.kommentare.List' ,{ + extend: 'Ext.grid.Panel', + alias: 'widget.kommentarelist', + store: 'Kommentare', + viewConfig: { + maxHeight: 350, + emptyText: 'Keine Kommentaregefunden.', + // minHeight and deferEmptyText are needed to be able to show the + // emptyText message. + minHeight: 35, + deferEmptyText: false + }, + initComponent: function() { + this.dockedItems = [ + { + xtype: 'toolbar', + dock: 'top', + items: [ + { + text: 'Hinzufügen', + icon: 'gfx/plus.gif' + }, + { + text: 'Löschen', + icon: 'gfx/minus.gif' + } + ] + } + ]; + this.columns = [ + {header: 'Erzeuger', dataIndex: 'erzeuger'}, + {header: 'Datum', dataIndex: 'kdatum'}, + {header: 'Text', dataIndex: 'ktext', flex: 1} + ]; + this.callParent(arguments); + } +}); +
--- a/app/view/proben/Edit.js Mon May 27 14:59:59 2013 +0200 +++ b/app/view/proben/Edit.js Tue May 28 10:58:47 2013 +0200 @@ -16,7 +16,8 @@ 'Lada.view.widgets.Datenbasis', 'Lada.view.widgets.Probenart', 'Lada.view.widgets.Betriebsart', - 'Lada.view.widgets.Testdatensatz' + 'Lada.view.widgets.Testdatensatz', + 'Lada.view.kommentare.List' ], initComponent: function() { @@ -263,35 +264,7 @@ padding: '10 10', items: [ { - xtype: 'grid', - dockedItems: [ - { - xtype: 'toolbar', - dock: 'top', - items: [ - { - text: 'Hinzufügen', - icon: 'gfx/plus.gif' - }, - { - text: 'Löschen', - icon: 'gfx/minus.gif' - } - ] - } - ], - columns: [ - { - text: 'Erzeuger' - }, - { - text: 'Datum' - }, - { - text: 'Text', - flex: 1 - } - ] + xtype: 'kommentarelist' } ] },