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: 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, dustin@1000: statusWerteStore: null, tom@1217: statusStufeStore: null, raimund@594: raimund@594: initComponent: function() { dustin@998: var i18n = Lada.getApplication().bundle; dustin@998: this.emptyText = i18n.getMsg('statusgrid.emptyText'); dustin@998: dustin@1000: this.statusWerteStore = Ext.create('Lada.store.StatusWerte'); dustin@1001: this.statusWerteStore.load({ dustin@963: params: { dustin@963: messungsId: this.recordId dustin@963: } dustin@963: }); tom@1217: this.statusStufeStore = Ext.create('Lada.store.StatusStufe'); tom@1217: this.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: ['->', { dustin@998: text: i18n.getMsg('reset'), dustin@994: icon: 'resources/img/edit-redo.png', dustin@994: action: 'reset', dustin@994: probeId: this.probeId, dustin@994: parentId: this.parentId dustin@994: }, { dustin@998: text: i18n.getMsg('add'), 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 = [{ dustin@998: header: i18n.getMsg('statusgrid.header.datum'), 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: }, { dustin@998: header: i18n.getMsg('statusgrid.header.erzeuger'), tom@1217: dataIndex: 'mstId', raimund@594: renderer: function(value) { dustin@961: var r = ''; raimund@594: if (!value || value === '') { dustin@998: r = i18n.getMsg('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, raimund@1044: queryMode: 'local', raimund@1044: editable: false dustin@945: }, dustin@965: sortable: false raimund@594: }, { dustin@998: header: i18n.getMsg('statusgrid.header.statusStufe'), tom@1217: dataIndex: 'statusKombi', dustin@956: renderer: function(value) { tom@1217: var kombi = Ext.data.StoreManager.get('statuskombi'); tom@1217: var r = ''; tom@1217: var item = kombi.getById(value); dustin@957: if (item) { tom@1217: r = item.raw.statusStufe.stufe; dustin@957: } dustin@956: return r; dustin@956: }, tom@1217: editor: { tom@1217: xtype: 'combobox', tom@1217: store: this.statusStufeStore, tom@1217: queryMode: 'local', tom@1217: displayField: 'stufe', tom@1217: valueField: 'id', tom@1217: allowBlank: false, tom@1217: editable: false, tom@1217: forceSelection: true tom@1217: }, dustin@965: sortable: false dustin@956: }, { dustin@998: header: i18n.getMsg('statusgrid.header.statusWert'), tom@1217: dataIndex: 'statusKombi', raimund@594: renderer: function(value) { tom@1217: var kombi = Ext.data.StoreManager.get('statuskombi'); dustin@963: //This store is NOT used in the editor... tom@1217: var r = ''; tom@1217: var item = kombi.getById(value); dustin@957: if (item) { tom@1217: r = item.raw.statusWert.wert; dustin@957: } dustin@956: return r; raimund@594: }, raimund@594: editor: { raimund@594: xtype: 'combobox', dustin@1001: store: this.statusWerteStore, dustin@968: queryMode: 'local', dustin@945: displayField: 'wert', raimund@594: valueField: 'id', dustin@663: allowBlank: false, dustin@1027: editable: false, dustin@1027: forceSelection: true dustin@945: }, dustin@965: sortable: false raimund@594: }, { dustin@998: header: i18n.getMsg('statusgrid.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: } dustin@1017: raimund@594: this.store.load({ raimund@594: params: { mstanko@1280: 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@996: } dustin@996: }, dustin@996: dustin@996: setResetable: function(b) { dustin@996: if (b == true){ dustin@994: this.down('button[action=reset]').enable(); dustin@996: }else{ dustin@996: this.down('button[action=reset]').disable(); dustin@684: } raimund@594: } raimund@594: });