dustin@561: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@561: * Software engineering by Intevation GmbH dustin@561: * dustin@561: * This file is Free Software under the GNU GPL (v>=3) dustin@561: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@561: * the documentation coming with IMIS-Labordaten-Application for details. dustin@561: */ dustin@561: dustin@561: /* dustin@561: * Grid to list Messungen dustin@561: */ dustin@561: Ext.define('Lada.view.grid.Messungen', { dustin@561: extend: 'Ext.grid.Panel', dustin@561: alias: 'widget.messungengrid', dustin@561: dustin@561: maxHeight: 350, dustin@561: emptyText: 'Keine Messungen gefunden', dustin@561: minHeight: 110, dustin@561: viewConfig: { dustin@561: deferEmptyText: false dustin@561: }, dustin@561: margin: '0, 5, 5, 5', dustin@561: dustin@561: recordId: null, dustin@561: dustin@561: warnings: null, dustin@561: errors: null, dustin@561: dustin@561: initComponent: function() { dustin@561: var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { dustin@561: clicksToMoveEditor: 1, dustin@561: autoCancel: false, dustin@561: itemId: 'rowedit' dustin@561: }); dustin@561: this.plugins = [rowEditing]; dustin@561: this.dockedItems = [{ dustin@561: xtype: 'toolbar', dustin@561: dock: 'bottom', dustin@561: items: ['->', { dustin@561: text: 'Details', dustin@561: icon: 'resources/img/document-open.png', dustin@561: action: 'open', dustin@561: disabled: true dustin@561: }, { dustin@561: text: 'Hinzufügen', dustin@561: icon: 'resources/img/list-add.png', dustin@561: action: 'add', dustin@561: probeId: this.recordId dustin@561: }, { dustin@561: text: 'Löschen', dustin@561: icon: 'resources/img/list-remove.png', dustin@561: action: 'delete' dustin@561: }] dustin@561: }]; dustin@561: this.columns = [{ dustin@561: header: 'Mess-ID', dustin@561: dataIndex: 'id', dustin@561: flex: 1, dustin@561: editor: { dustin@561: allowBlank: false dustin@561: } dustin@561: }, { dustin@561: /* dustin@561: header: 'Probe-ID', dustin@561: dataIndex: 'probeId', dustin@561: flex: 1, dustin@561: editor: { dustin@561: allowBlank: false dustin@561: } dustin@561: }, { dustin@561: */ dustin@561: header: 'Nebenproben-Nr.', dustin@561: dataIndex: 'nebenprobenNr', dustin@561: flex: 1, dustin@561: editor: { dustin@561: allowBlank: false dustin@561: } dustin@561: }, { dustin@561: header: 'MMT', dustin@561: dataIndex: 'mmtId', dustin@561: flex: 1, dustin@561: editor: { dustin@561: allowBlank: false dustin@561: } dustin@561: }, { dustin@561: header: 'Messzeit', dustin@561: dataIndex: 'messzeitpunkt', dustin@561: flex: 2, dustin@561: editor: { dustin@561: xtype: 'datefield', dustin@561: allowBlank: false, dustin@561: format: 'd.m.Y', dustin@561: //minValue: '01.01.2001', //todo: gibt es das? dustin@561: //minText: 'Das Datum der Messung darf nicht vor dem 01.01.2001 liegen.', dustin@561: maxValue: Ext.Date.format(new Date(), 'd.m.Y') dustin@561: } dustin@561: } dustin@561: /* dustin@561: , { dustin@561: header: 'Messdauer', dustin@561: dataIndex: 'messdauer', dustin@561: width: 50, dustin@561: editor: { dustin@561: allowBlank: false dustin@561: } dustin@561: }, { dustin@561: header: 'Geplant', dustin@561: dataIndex: 'geplant', dustin@561: width: 10, dustin@561: editor: { dustin@561: xtype: 'checkboxfield', dustin@561: allowBlank: false dustin@561: } dustin@561: }, { dustin@561: header: 'Letzte Änderung', dustin@561: dataIndex: 'letzteAenderung', dustin@561: width: 50, dustin@561: editor: { dustin@561: xtype: 'datefield', dustin@561: allowBlank: false, dustin@561: format: 'd.m.Y', dustin@561: //minValue: '01.01.2001', //todo: gibt es das? dustin@561: //minText: 'Das Datum der letzten Änderung darf nicht vor dem 01.01.2001 liegen.', dustin@561: maxValue: Ext.Date.format(new Date(), 'd.m.Y') dustin@561: } dustin@561: }*/ dustin@561: , { dustin@561: header: 'Status', dustin@565: flex: 1, dustin@561: dataIndex: 'id', dustin@561: renderer: function(value) { dustin@565: //fixme: dezeit existiert nur 1 status daher immer unbekannt dustin@565: this.statusStore.load( dustin@565: { dustin@561: params: { dustin@565: messungsId: value, dustin@561: } dustin@561: }); dustin@565: dustin@565: if (!this.statusStore){ dustin@561: return 'unbekannt'; dustin@561: } dustin@565: if (this.statusStore.getTotalCount() === 0) { dustin@565: return 'unbekannt'; dustin@565: } dustin@565: return this.statusStore.last().get('status'); dustin@561: } dustin@561: }, { dustin@561: header: 'OK-Flag', dustin@561: dataIndex: 'fertig', dustin@561: flex: 1, dustin@561: renderer: function(value){ dustin@561: if(value){ dustin@561: return 'Ja'; dustin@561: } dustin@561: return 'Nein'; dustin@561: }, dustin@561: editor: { dustin@561: xtype: 'checkboxfield', dustin@561: allowBlank: false dustin@561: } dustin@561: }, { dustin@561: header: 'Anzahl Nuklide', dustin@565: // Gibt die Anzahl der Messwerte wieder, dustin@565: // NICHT die Anzahl der verschiedenen Nukleide dustin@565: // Eventuell ist die Bezeichnug daher irreführend dustin@561: flex: 1, dustin@565: dataIndex: 'id', dustin@561: renderer: function(value) { dustin@565: //fixme: gibt immer 0 aus dustin@565: this.messwerteStore.load({ dustin@561: params: { dustin@565: messungId: value, dustin@561: } dustin@561: }); dustin@565: dustin@565: if (!this.messwerteStore){ dustin@565: return 'unbekannt'; dustin@565: } dustin@565: return this.messwerteStore.getCount(); dustin@561: } dustin@561: }, { dustin@561: header: 'Anzahl Kommentare', dustin@561: flex: 1, dustin@565: dataIndex: 'id', dustin@561: renderer: function(value) { dustin@565: //fixme: gibt immer 0 aus dustin@565: this.mKommentareStore.load({ dustin@561: params: { dustin@565: messungsId: value, dustin@561: } dustin@561: }); dustin@565: dustin@565: if (!this.mKommentareStore){ dustin@565: return 'unbekannt'; dustin@565: } dustin@565: dustin@565: return this.mKommentareStore.getTotalCount(); dustin@561: } dustin@561: }]; dustin@561: this.initData(); dustin@561: this.callParent(arguments); dustin@561: }, dustin@561: dustin@561: initData: function(){ dustin@561: this.store = Ext.create('Lada.store.Messungen'); dustin@565: this.statusStore = Ext.create('Lada.store.Status'); dustin@565: this.messwerteStore = Ext.create('Lada.store.Messwerte'); dustin@565: this.mKommentareStore = Ext.create('Lada.store.MKommentare'); dustin@565: dustin@561: this.store.load({ dustin@561: params: { dustin@561: probeId: this.recordId dustin@561: } dustin@561: }); dustin@565: dustin@565: /* dustin@565: this.statusStore.load({ dustin@565: params: { dustin@565: messungId: this.recordId dustin@565: } dustin@565: }); dustin@565: this.messwerteStore.load({ dustin@565: params: { dustin@565: messungId: this.recordId dustin@565: } dustin@565: }); dustin@565: this.mKommentareStore.load({ dustin@565: params: { dustin@565: messungsId: this.recordId dustin@565: } dustin@565: }); dustin@565: */ dustin@565: dustin@561: }, dustin@561: listeners: { dustin@561: selectionchange: function(model, selected, eOpts) { dustin@561: /* dustin@561: * Enable the 'details' button only when an item is selected dustin@561: */ dustin@561: if (selected.length > 0) { dustin@561: this.down('button[action=open]').enable(); dustin@561: } dustin@561: } dustin@561: } dustin@561: });