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: this.dockedItems = [{
dustin@561: xtype: 'toolbar',
dustin@561: dock: 'bottom',
dustin@561: items: ['->', {
dustin@561: text: 'Hinzufügen',
dustin@561: icon: 'resources/img/list-add.png',
dustin@561: action: 'add',
dustin@566: probeId: this.probeId
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,
raimund@586: editor: {
raimund@586: allowBlank: false
raimund@586: }
dustin@561: }, {
dustin@561: header: 'Nebenproben-Nr.',
dustin@561: dataIndex: 'nebenprobenNr',
dustin@561: flex: 1,
raimund@586: editor: {
raimund@586: allowBlank: false
raimund@586: }
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,
raimund@586: editor: {
raimund@586: xtype: 'datefield',
raimund@586: allowBlank: false,
raimund@586: format: 'd.m.Y',
raimund@586: // minValue: '01.01.2001', //todo: gibt es das?
raimund@586: // minText: 'Das Datum der Messung darf nicht vor dem 01.01.2001 liegen.',
raimund@586: maxValue: Ext.Date.format(new Date(), 'd.m.Y')
raimund@586: }
dustin@561: }, {
dustin@561: header: 'Status',
dustin@565: flex: 1,
dustin@561: dataIndex: 'id',
dustin@561: renderer: function(value) {
raimund@585: var id = 'messung-status-item' + value;
raimund@585: this.updateStatus(value, id);
raimund@585: return '
Lade...
';
dustin@561: }
dustin@561: }, {
dustin@561: header: 'OK-Flag',
dustin@561: dataIndex: 'fertig',
dustin@561: flex: 1,
raimund@585: renderer: function(value) {
raimund@585: 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
raimund@585: dataIndex: 'id',
dustin@561: flex: 1,
dustin@561: renderer: function(value) {
raimund@585: var id = 'messung-nuklid-item' + value;
raimund@585: this.updateNuklide(value, id);
raimund@585: return 'Lade...
';
dustin@561: }
dustin@561: }, {
dustin@561: header: 'Anzahl Kommentare',
dustin@561: flex: 1,
dustin@565: dataIndex: 'id',
dustin@561: renderer: function(value) {
raimund@585: var id = 'messung-kommentar-item' + value;
raimund@585: this.updateKommentare(value, id);
raimund@585: return 'Lade...
';
dustin@561: }
dustin@561: }];
dustin@561: this.initData();
dustin@561: this.callParent(arguments);
dustin@561: },
dustin@561:
raimund@585: initData: function() {
dustin@561: this.store = Ext.create('Lada.store.Messungen');
dustin@561: this.store.load({
dustin@561: params: {
dustin@561: probeId: this.recordId
dustin@561: }
dustin@561: });
raimund@585: },
raimund@585:
raimund@585: updateStatus: function(value, divId) {
raimund@585: var statusStore = Ext.create('Lada.store.Status');
raimund@585: statusStore.on('load',
raimund@585: this.updateStatusColumn,
raimund@585: this,
raimund@585: {divId: divId});
raimund@585: statusStore.load({
raimund@585: params: {
raimund@585: messungsId: value
raimund@585: }
raimund@585: });
raimund@585: },
raimund@585:
raimund@585: updateNuklide: function(value, divId) {
raimund@585: var messwerte = Ext.create('Lada.store.Messwerte');
raimund@585: messwerte.on('load',
raimund@585: this.updateColumn,
raimund@585: this,
raimund@585: {divId: divId});
raimund@585: messwerte.load({
raimund@585: params: {
raimund@585: messungsId: value
raimund@585: }
raimund@585: });
raimund@585: },
raimund@585:
raimund@585: updateKommentare: function(value, divId) {
raimund@585: var kommentare = Ext.create('Lada.store.MKommentare');
raimund@585: kommentare.on('load',
raimund@585: this.updateColumn,
raimund@585: this,
raimund@585: {divId: divId});
raimund@585: kommentare.load({
raimund@585: params: {
raimund@585: messungsId: value
raimund@585: }
raimund@585: });
raimund@585: },
raimund@585:
raimund@585: updateColumn: function(store, record, success, opts) {
raimund@585: var value;
raimund@585: if (store.getTotalCount() === 0) {
raimund@585: value = 'Keine';
raimund@585: }
raimund@585: else {
raimund@585: value = store.getTotalCount();
raimund@585: }
raimund@585: Ext.fly(opts.divId).update(value);
raimund@585: },
raimund@585:
raimund@585: updateStatusColumn: function(sstore, record, success, opts) {
raimund@585: var value;
raimund@585: if (sstore.getTotalCount() === 0) {
raimund@585: value = 'unbekannt';
raimund@585: }
raimund@585: else {
raimund@585: value = sstore.last().get('status');
raimund@585: }
raimund@585: if (Ext.fly(opts.divId)) {
raimund@585: Ext.fly(opts.divId).update(value);
raimund@585: }
dustin@561: }
dustin@561: });