Mercurial > lada > lada-client
changeset 590:e440b66a859f
Added grid (+controller) for messwerte.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 11 Mar 2015 15:23:16 +0100 |
parents | 4c97717b92da |
children | f2742f9b5a64 |
files | app.js app/controller/grid/Messwert.js app/view/grid/Messwert.js app/view/window/MessungEdit.js |
diffstat | 4 files changed, 236 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/app.js Wed Mar 11 15:21:55 2015 +0100 +++ b/app.js Wed Mar 11 15:23:16 2015 +0100 @@ -108,5 +108,6 @@ 'Lada.controller.grid.Probenzusatzwert', 'Lada.controller.grid.PKommentar', 'Lada.controller.grid.Messung', + 'Lada.controller.grid.Messwert' ] });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/controller/grid/Messwert.js Wed Mar 11 15:23:16 2015 +0100 @@ -0,0 +1,64 @@ +/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU GPL (v>=3) + * and comes with ABSOLUTELY NO WARRANTY! Check out + * the documentation coming with IMIS-Labordaten-Application for details. + */ + +Ext.define('Lada.controller.grid.Messwert', { + extend: 'Ext.app.Controller', + + init: function() { + this.control({ + 'messwertgrid': { + edit: this.gridSave + }, + 'messwertgrid button[action=add]': { + click: this.add + }, + 'messwertgrid button[action=delete]': { + click: this.remove + } + }); + }, + + gridSave: function(editor, context) { + context.record.save({ + success: function() { + context.grid.store.reload(); + context.grid.up('window').initData(); + }, + failure: function() { + // TODO + } + }); + }, + + add: function(button) { + console.log('add'); + var record = Ext.create('Lada.model.Messwert', { + messungsId: button.up('messwertgrid').recordId + }); + button.up('messwertgrid').store.insert(0, record); + button.up('messwertgrid').rowEditing.startEdit(0, 1); + }, + + remove: function(button) { + var grid = button.up('grid'); + var selection = grid.getView().getSelectionModel().getSelection()[0]; + Ext.MessageBox.confirm('Messwert löschen', 'Sind Sie sicher?', function(btn) { + if (btn === 'yes') { + selection.destroy({ + success: function() { + button.up('window').initData(); + grid.initData(); + }, + failure: function() { + // TODO + } + }); + } + }); + } +});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/grid/Messwert.js Wed Mar 11 15:23:16 2015 +0100 @@ -0,0 +1,146 @@ +/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU GPL (v>=3) + * and comes with ABSOLUTELY NO WARRANTY! Check out + * the documentation coming with IMIS-Labordaten-Application for details. + */ + +/* + * Grid to list Messwerte + */ +Ext.define('Lada.view.grid.Messwert', { + extend: 'Ext.grid.Panel', + alias: 'widget.messwertgrid', + + requires: [ + 'Lada.view.widget.Messgroesse', + 'Lada.view.widget.Messeinheit' + ], + + maxHeight: 350, + emptyText: 'Keine Messwerte gefunden.', + minHeight: 110, + viewConfig: { + deferEmptyText: false + }, + margin: '0, 5, 5, 5', + + recordId: null, + + initComponent: function() { + this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { + clicksToMoveEditor: 1, + autoCancel: false + }); + + this.plugins = [this.rowEditing]; + + this.dockedItems = [{ + xtype: 'toolbar', + dock: 'bottom', + items: ['->', { + text: 'Hinzufügen', + icon: 'resources/img/list-add.png', + action: 'add', + probeId: this.probeId, + parentId: this.parentId + }, { + text: 'Löschen', + icon: 'resources/img/list-remove.png', + action: 'delete' + }] + }]; + this.columns = [{ + header: 'Messgröße', + dataIndex: 'messgroesseId', + width: 80, + renderer: function(value) { + if (!value || value === '') { + return ''; + } + var store = Ext.data.StoreManager.get('messgroessen'); + return store.findRecord('id', value).get('messgroesse'); + }, + editor: { + xtype: 'combobox', + store: Ext.data.StoreManager.get('messgroessen'), + displayField: 'messgroesse', + valueField: 'id', + allowBlank: false + } + }, { + header: 'Messwert', + dataIndex: 'messwert', + width: 80, + editor: { + xtype: 'numberfield', + allowBlank: false + } + }, { + header: 'Messeinheit', + dataIndex: 'mehId', + width: 90, + renderer: function(value) { + if (!value || value === '') { + return ''; + } + var store = Ext.data.StoreManager.get('messeinheiten'); + return store.findRecord('id', value).get('einheit'); + }, + editor: { + xtype: 'combobox', + store: Ext.data.StoreManager.get('messeinheiten'), + displayField: 'einheit', + valueField: 'id', + allowBlank: false + } + }, { + header: '<NWG', + width: 60, + dataIndex: 'messwertNwg' + }, { + header: 'Nachweisgrenze', + width: 110, + dataIndex: 'nwgZuMesswert' + }, { + header: 'Messfehler', + dataIndex: 'messfehler', + width: 80, + editor: { + xtype: 'numberfield', + allowBlank: false + } + }, { + header: 'Grenzwertüberschreitung', + dataIndex: 'grenzwertueberschreitung', + flex: 1, + renderer: function(value) { + if (value === true) { + return 'Ja'; + } + return 'Nein'; + }, + editor: { + xtype: 'checkbox' + } + }]; + this.initData(); + this.callParent(arguments); + }, + + initData: function() { + console.log('init messwert data'); + if (this.store) { + this.store.removeAll(); + } + else { + this.store = Ext.create('Lada.store.Messwerte'); + } + this.store.load({ + params: { + messungsId: this.recordId + } + }); + } +});
--- a/app/view/window/MessungEdit.js Wed Mar 11 15:21:55 2015 +0100 +++ b/app/view/window/MessungEdit.js Wed Mar 11 15:23:16 2015 +0100 @@ -7,15 +7,15 @@ */ /* - * Window to edit a Messung + * Window to edit a Messung */ Ext.define('Lada.view.window.MessungEdit', { extend: 'Ext.window.Window', alias: 'widget.messungedit', requires: [ - 'Lada.view.form.Messung' - // 'Lada.view.grid.Messwert', + 'Lada.view.form.Messung', + 'Lada.view.grid.Messwert' // 'Lada.view.grid.Messstatus', // 'Lada.view.grid.MKommentar' ], @@ -28,13 +28,13 @@ record: null, - initComponent: function(){ + initComponent: function() { if (this.record === null) { Ext.Msg.alert('Keine valide Messung ausgewählt!'); this.callParent(arguments); return; } - this.title = 'Messung ';// + this.record.get('messungId'); + this.title = 'Messung ' + this.record.get('nebenprobenNr'); this.buttons = [{ text: 'Schließen', scope: this, @@ -48,22 +48,28 @@ autoScroll: true, items: [{ xtype: 'messungform', -// recordId: record.get('id') + recordId: this.record.get('id') }, { xtype: 'fset', name: 'messwerte', - title: 'Messwerte - Stub' - //todo + title: 'Messwerte', + padding: '5, 5', + margin: 5, + items: [{ + xtype: 'messwertgrid', + recordId: this.record.get('id') + }] + // TODO }, { xtype: 'fset', name: 'messungstatus', title: 'Messungstatus - Stub' - //todo + // TODO }, { xtype: 'fset', name: 'messungskommentare', title: 'Messungskommentare - Stub' - //todo + // TODO }] }]; this.callParent(arguments); @@ -72,12 +78,16 @@ initData: function() { this.clearMessages(); Ext.ClassManager.get('Lada.model.Messung').load(this.record.get('id'), { - failure: function(record, action){ - // todo - console.log("failure"); + failure: function(record) { + // TODO + console.log(record); }, - success: function(record, action){ - console.log("success"); + success: function(record, response) { + this.down('messungform').setRecord(record); + var json = Ext.decode(response.response.responseText); + if (json) { + this.setMessages(json.errors, json.warnings); + } }, scope: this }