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: dustin@893: /** 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, dustin@824: readOnly: true, dustin@824: allowDeselect: true, raimund@594: raimund@594: initComponent: function() { dustin@963: var statusWerteStore = Ext.create('Lada.store.StatusWerte'); dustin@963: statusWerteStore.load({ dustin@963: params: { dustin@963: messungsId: this.recordId dustin@963: } dustin@963: }); dustin@963: var statusStufeStore = Ext.create('Lada.store.StatusStufe'); dustin@963: statusStufeStore.load(); dustin@963: raimund@594: this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { raimund@594: clicksToMoveEditor: 1, dustin@683: autoCancel: false, dustin@990: disabled: true, //has no effect... but why? dustin@990: pluginId: 'rowedit', dustin@990: listeners: { dustin@990: beforeedit: function(editor, context, eOpts) { dustin@990: if (context.record.get('id') || dustin@990: ! context.grid.up('window').record.get('statusEdit')) { dustin@990: //Check if edit is allowed, this is true, when the selected dustin@990: // Record has an id (=is not new) dustin@990: // or is not allowed to add records. dustin@990: dustin@990: return false; dustin@990: } dustin@990: dustin@990: dustin@990: } dustin@990: } dustin@945: }); raimund@594: this.plugins = [this.rowEditing]; 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: }]; raimund@594: this.columns = [{ mstanko@944: header: 'erstellt', dustin@945: dataIndex: 'datum', mstanko@944: xtype: 'datecolumn', mstanko@944: format: 'd.m.Y H:i', mstanko@944: width: 110, dustin@965: sortable: false mstanko@944: }, { raimund@594: header: 'Erzeuger', raimund@594: dataIndex: 'erzeuger', raimund@594: renderer: function(value) { dustin@961: var r = ''; raimund@594: if (!value || value === '') { dustin@961: r = 'Error'; raimund@594: } raimund@594: var mstore = Ext.data.StoreManager.get('messstellen'); dustin@961: var item = mstore.getById(value); dustin@961: if (item) { dustin@961: r = item.get('messStelle'); dustin@961: } dustin@961: return r; raimund@594: }, raimund@594: editor: { raimund@594: xtype: 'combobox', dustin@967: store: Ext.data.StoreManager.get('messstellenFiltered'), raimund@594: displayField: 'messStelle', raimund@594: valueField: 'id', dustin@663: allowBlank: false, dustin@663: editable: false dustin@945: }, dustin@965: sortable: false raimund@594: }, { dustin@956: header: 'Stufe', dustin@956: dataIndex: 'statusStufe', dustin@956: renderer: function(value) { dustin@963: var sta = Ext.data.StoreManager.get('statusstufe'); dustin@958: var r; dustin@957: if (value===null || value === '') { dustin@958: r = 'Error'; dustin@956: } dustin@963: var item = sta.getById(value); dustin@957: if (item) { dustin@957: r = item.get('stufe'); dustin@957: } dustin@956: return r; dustin@956: }, dustin@965: sortable: false dustin@956: }, { raimund@594: header: 'Status', dustin@945: dataIndex: 'statusWert', raimund@594: renderer: function(value) { dustin@963: var sta = Ext.data.StoreManager.get('statuswerte'); dustin@963: //This store is NOT used in the editor... dustin@958: var r; dustin@950: if (value===null || value === '') { dustin@958: r = 'Error'; raimund@594: } dustin@963: var item = sta.getById(value); dustin@957: if (item) { dustin@957: r = item.get('wert'); dustin@957: } dustin@956: return r; raimund@594: }, raimund@594: editor: { raimund@594: xtype: 'combobox', dustin@956: store: statusWerteStore, dustin@968: queryMode: 'local', dustin@945: displayField: 'wert', raimund@594: valueField: 'id', dustin@663: allowBlank: false, dustin@663: editable: false dustin@945: }, dustin@965: sortable: false raimund@594: }, { raimund@594: header: 'Text', dustin@945: dataIndex: 'text', raimund@594: flex: 1, raimund@594: editor: { dustin@663: allowBlank: true, dustin@663: maxLength: 1000, dustin@663: enforceMaxLength: true dustin@945: }, dustin@965: sortable: false raimund@594: }]; raimund@594: this.initData(); raimund@594: this.callParent(arguments); dustin@824: this.setReadOnly(true); //Grid is always initialised as RO raimund@594: }, raimund@594: raimund@594: initData: function() { raimund@594: if (this.store) { raimund@594: this.store.removeAll(); raimund@594: } raimund@594: else { dustin@990: this.store = Ext.create('Lada.store.Status',{ dustin@990: sorters: [{ dustin@990: property: 'datum', dustin@990: direction: 'ASC' dustin@990: }] dustin@990: }); raimund@594: } raimund@594: this.store.load({ raimund@594: params: { dustin@990: messungsId: this.recordId, raimund@594: } raimund@594: }); dustin@684: }, dustin@684: dustin@684: setReadOnly: function(b) { dustin@684: if (b == true){ dustin@684: //Readonly dustin@684: this.down('button[action=add]').disable(); dustin@684: }else{ dustin@684: //Writable dustin@684: this.down('button[action=add]').enable(); dustin@684: } raimund@594: } raimund@594: });