raimund@590: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@590: * Software engineering by Intevation GmbH raimund@590: * raimund@590: * This file is Free Software under the GNU GPL (v>=3) raimund@590: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@590: * the documentation coming with IMIS-Labordaten-Application for details. raimund@590: */ raimund@590: raimund@590: /* raimund@590: * Grid to list Messwerte raimund@590: */ raimund@590: Ext.define('Lada.view.grid.Messwert', { raimund@590: extend: 'Ext.grid.Panel', raimund@590: alias: 'widget.messwertgrid', raimund@590: raimund@590: requires: [ raimund@590: 'Lada.view.widget.Messgroesse', raimund@590: 'Lada.view.widget.Messeinheit' raimund@590: ], raimund@590: raimund@590: maxHeight: 350, raimund@590: emptyText: 'Keine Messwerte gefunden.', raimund@590: minHeight: 110, raimund@590: viewConfig: { raimund@590: deferEmptyText: false raimund@590: }, raimund@590: margin: '0, 5, 5, 5', raimund@590: raimund@590: recordId: null, raimund@590: raimund@590: initComponent: function() { raimund@590: this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { raimund@590: clicksToMoveEditor: 1, dustin@683: autoCancel: false, dustin@703: disabled: false, dustin@684: pluginId: 'rowedit', dustin@683: listeners:{ dustin@683: // Make row ineditable when readonly is set to true dustin@683: // Normally this would belong into a controller an not the view. dustin@703: // But the RowEditPlugin is not handled there. dustin@683: beforeedit: function(e, o) { dustin@703: var readonlywin = o.grid.up('window').record.get('readonly'); dustin@703: var readonlygrid = o.record.get('readonly'); dustin@703: if (readonlywin == true || readonlygrid == true || this.disabled) { dustin@683: return false; dustin@683: } dustin@683: return true; dustin@683: } dustin@683: } dustin@683: }); raimund@590: raimund@590: this.plugins = [this.rowEditing]; raimund@590: raimund@590: this.dockedItems = [{ raimund@590: xtype: 'toolbar', raimund@590: dock: 'bottom', raimund@590: items: ['->', { raimund@590: text: 'Hinzufügen', raimund@590: icon: 'resources/img/list-add.png', raimund@590: action: 'add', raimund@590: probeId: this.probeId, raimund@590: parentId: this.parentId raimund@590: }, { raimund@590: text: 'Löschen', raimund@590: icon: 'resources/img/list-remove.png', raimund@590: action: 'delete' raimund@590: }] raimund@590: }]; raimund@590: this.columns = [{ raimund@590: header: 'Messgröße', raimund@590: dataIndex: 'messgroesseId', raimund@590: width: 80, raimund@590: renderer: function(value) { raimund@590: if (!value || value === '') { raimund@590: return ''; raimund@590: } raimund@590: var store = Ext.data.StoreManager.get('messgroessen'); raimund@590: return store.findRecord('id', value).get('messgroesse'); raimund@590: }, raimund@590: editor: { raimund@590: xtype: 'combobox', raimund@590: store: Ext.data.StoreManager.get('messgroessen'), raimund@590: displayField: 'messgroesse', raimund@590: valueField: 'id', dustin@662: allowBlank: false, dustin@662: editable: false raimund@590: } raimund@590: }, { raimund@590: header: 'Messwert', raimund@590: dataIndex: 'messwert', dustin@624: xtype: 'numbercolumn', raimund@590: width: 80, raimund@590: editor: { raimund@590: xtype: 'numberfield', dustin@662: allowBlank: false, dustin@662: maxLength: 10, dustin@662: allowExponential: false, dustin@662: enforceMaxLength: true, raimund@590: } raimund@590: }, { raimund@590: header: 'Messeinheit', raimund@590: dataIndex: 'mehId', raimund@590: width: 90, raimund@590: renderer: function(value) { raimund@590: if (!value || value === '') { raimund@590: return ''; raimund@590: } raimund@590: var store = Ext.data.StoreManager.get('messeinheiten'); raimund@590: return store.findRecord('id', value).get('einheit'); raimund@590: }, raimund@590: editor: { raimund@590: xtype: 'combobox', raimund@590: store: Ext.data.StoreManager.get('messeinheiten'), raimund@590: displayField: 'einheit', raimund@590: valueField: 'id', dustin@662: allowBlank: false, dustin@662: editable: false raimund@590: } raimund@590: }, { raimund@590: header: '<NWG', dustin@624: xtype: 'numbercolumn', raimund@590: width: 60, raimund@590: dataIndex: 'messwertNwg' raimund@590: }, { raimund@590: header: 'Nachweisgrenze', dustin@624: xtype: 'numbercolumn', raimund@590: width: 110, raimund@590: dataIndex: 'nwgZuMesswert' raimund@590: }, { raimund@590: header: 'Messfehler', raimund@590: dataIndex: 'messfehler', dustin@624: xtype: 'numbercolumn', raimund@590: width: 80, raimund@590: editor: { raimund@590: xtype: 'numberfield', dustin@662: allowBlank: false, dustin@662: maxLength: 10, dustin@662: allowExponential: false, dustin@662: enforceMaxLength: true, raimund@590: } raimund@590: }, { raimund@590: header: 'Grenzwertüberschreitung', raimund@590: dataIndex: 'grenzwertueberschreitung', raimund@590: flex: 1, raimund@590: renderer: function(value) { raimund@590: if (value === true) { raimund@590: return 'Ja'; raimund@590: } raimund@590: return 'Nein'; raimund@590: }, raimund@590: editor: { raimund@590: xtype: 'checkbox' raimund@590: } raimund@590: }]; raimund@590: this.initData(); raimund@590: this.callParent(arguments); raimund@590: }, raimund@590: raimund@590: initData: function() { raimund@590: if (this.store) { raimund@590: this.store.removeAll(); raimund@590: } raimund@590: else { raimund@590: this.store = Ext.create('Lada.store.Messwerte'); raimund@590: } raimund@590: this.store.load({ raimund@590: params: { raimund@590: messungsId: this.recordId raimund@590: } raimund@590: }); dustin@684: }, dustin@684: dustin@684: setReadOnly: function(b) { dustin@684: if (b == true){ dustin@684: //Readonly dustin@684: if (this.getPlugin('rowedit')){ dustin@684: this.getPlugin('rowedit').disable(); dustin@684: } dustin@684: this.down('button[action=delete]').disable(); dustin@684: this.down('button[action=add]').disable(); dustin@684: }else{ dustin@684: //Writable dustin@687: if (this.getPlugin('rowedit')){ dustin@687: this.getPlugin('rowedit').enable(); dustin@687: } dustin@687: this.down('button[action=delete]').enable(); dustin@687: this.down('button[action=add]').enable(); dustin@687: } raimund@590: } raimund@590: });