raimund@594: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
raimund@594:  * Software engineering by Intevation GmbH
raimund@594:  *
raimund@594:  * This file is Free Software under the GNU GPL (v>=3)
raimund@594:  * and comes with ABSOLUTELY NO WARRANTY! Check out
raimund@594:  * the documentation coming with IMIS-Labordaten-Application for details.
raimund@594:  */
raimund@594: 
raimund@594: /*
raimund@594:  * Grid to list Status
raimund@594:  */
raimund@594: Ext.define('Lada.view.grid.Status', {
raimund@594:     extend: 'Ext.grid.Panel',
raimund@594:     alias: 'widget.statusgrid',
raimund@594: 
raimund@594:     maxHeight: 350,
raimund@594:     emptyText: 'Keine Statusangaben gefunden.',
raimund@594:     minHeight: 110,
raimund@594:     viewConfig: {
raimund@594:         deferEmptyText: false
raimund@594:     },
raimund@594: 
raimund@594:     recordId: null,
raimund@594: 
raimund@594:     initComponent: function() {
raimund@594:         this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
raimund@594:             clicksToMoveEditor: 1,
raimund@594:             autoCancel: false
raimund@594:         });
raimund@594:         this.plugins = [this.rowEditing];
raimund@594: 
raimund@594:         var statusStore = Ext.create('Ext.data.Store', {
raimund@594:             fields: ['display', 'id'],
raimund@594:             data: [{
raimund@594:                 display: 'unbekannt', id: 0
raimund@594:             }, {
raimund@594:                 display: 'nicht vergeben', id: 1
raimund@594:             }, {
raimund@594:                 display: 'plausibel', id: 2
raimund@594:             }, {
raimund@594:                 display: 'nicht repräsentativ', id: 3
raimund@594:             }, {
raimund@594:                 display: 'nicht plausibel', id: 4
raimund@594:             }]
raimund@594:         });
raimund@594:         this.dockedItems = [{
raimund@594:             xtype: 'toolbar',
raimund@594:             dock: 'bottom',
raimund@594:             items: ['->', {
raimund@594:                 text: 'Hinzufügen',
raimund@594:                 icon: 'resources/img/list-add.png',
raimund@594:                 action: 'add',
raimund@594:                 probeId: this.probeId,
raimund@594:                 parentId: this.parentId
raimund@594:             }, {
raimund@594:                 text: 'Löschen',
raimund@594:                 icon: 'resources/img/list-remove.png',
raimund@594:                 action: 'delete'
raimund@594:             }]
raimund@594:         }];
raimund@594:         this.columns = [{
raimund@594:             header: 'Erzeuger',
raimund@594:             dataIndex: 'erzeuger',
raimund@594:             renderer: function(value) {
raimund@594:                 if (!value || value === '') {
raimund@594:                     return '';
raimund@594:                 }
raimund@594:                 var mstore = Ext.data.StoreManager.get('messstellen');
raimund@594:                 return mstore.getById(value).get('messStelle');
raimund@594:             },
raimund@594:             editor: {
raimund@594:                 xtype: 'combobox',
raimund@594:                 store: Ext.data.StoreManager.get('messstellen'),
raimund@594:                 displayField: 'messStelle',
raimund@594:                 valueField: 'id',
raimund@594:                 allowBlank: false
raimund@594:             }
raimund@594:         }, {
raimund@594:             header: 'Status',
raimund@594:             dataIndex: 'status',
raimund@594:             renderer: function(value) {
raimund@594:                 if (!value || value === '') {
raimund@594:                     return '';
raimund@594:                 }
raimund@594:                 return statusStore.getById(value).get('display');
raimund@594:             },
raimund@594:             editor: {
raimund@594:                 xtype: 'combobox',
raimund@594:                 store: statusStore,
raimund@594:                 displayField: 'display',
raimund@594:                 valueField: 'id',
raimund@594:                 allowBlank: false
raimund@594:             }
raimund@594:         }, {
raimund@594:             header: 'Datum',
raimund@594:             dataIndex: 'sdatum',
dustin@630:             xtype: 'datecolumn',
dustin@630:             format: 'd.m.Y H:i',
raimund@594:             editor: {
raimund@594:                 xtype: 'datefield',
raimund@594:                 allowBlank: false,
dustin@630:                 format: 'd.m.Y H:i',
raimund@594:                 maxValue: Ext.Date.format(new Date(), 'd.m.Y')
raimund@594:             }
raimund@594:         }, {
raimund@594:             header: 'Text',
raimund@594:             dataIndex: 'skommentar',
raimund@594:             flex: 1,
raimund@594:             editor: {
raimund@594:                 allowBlank: true
raimund@594:             }
raimund@594:         }];
raimund@594:         this.initData();
raimund@594:         this.callParent(arguments);
raimund@594:     },
raimund@594: 
raimund@594:     initData: function() {
raimund@594:         if (this.store) {
raimund@594:             this.store.removeAll();
raimund@594:         }
raimund@594:         else {
raimund@594:             this.store = Ext.create('Lada.store.Status');
raimund@594:         }
raimund@594:         this.store.load({
raimund@594:             params: {
raimund@594:                 messungsId: this.recordId
raimund@594:             }
raimund@594:         });
raimund@594:     }
raimund@594: });