diff --git a/ehr/resources/web/ehr/DataEntryUtils.js b/ehr/resources/web/ehr/DataEntryUtils.js index dd9d0239c..6d2fc7253 100644 --- a/ehr/resources/web/ehr/DataEntryUtils.js +++ b/ehr/resources/web/ehr/DataEntryUtils.js @@ -1112,6 +1112,24 @@ EHR.DataEntryUtils = new function(){ } return projectStore.getAt(recIdx).get('project'); + }, + + ensureLookupPlugin(editor, initPlugin) { + const xtype = editor?.xtype; + if ((xtype === 'combo' || xtype === 'labkey-combo' || xtype === 'ehr-simplecombo') + && !editor.plugins?.find(p => p.ptype === 'ldk-usereditablecombo')) { + + const plugin = Ext4.create('LDK.plugin.UserEditableCombo', { + allowChooseOther: false, + }); + editor.plugins = editor.plugins || []; + editor.plugins.push(plugin); + + if (initPlugin) + plugin.init(editor); + } + + return editor; } } }; diff --git a/ehr/resources/web/ehr/grid/Panel.js b/ehr/resources/web/ehr/grid/Panel.js index 86d273f54..3f7c1638f 100644 --- a/ehr/resources/web/ehr/grid/Panel.js +++ b/ehr/resources/web/ehr/grid/Panel.js @@ -89,6 +89,8 @@ Ext4.define('EHR.grid.Panel', { this.dataEntryPanel.updateMinWidth(this.minWidth); } + this.addComboEditorPlugin(this.columns); + }, pendingChanges: {}, @@ -107,6 +109,14 @@ Ext4.define('EHR.grid.Panel', { } }, + addComboEditorPlugin: function(columns){ + Ext4.Array.forEach(columns, function(col){ + if (col.editor) { + col.editor = EHR.DataEntryUtils.ensureLookupPlugin(col.editor, false); + } + }, this); + }, + resizeHeight: function(){ // A bit of a hack but there are some cases where the gridview does not resize height to match its contents. Called // on store validation complete as this covers initial load and adding new rows scenario. Also done on cell edit diff --git a/ehr/resources/web/ehr/plugin/ClinicalObservationsCellEditing.js b/ehr/resources/web/ehr/plugin/ClinicalObservationsCellEditing.js index 00b8267c7..16675a955 100644 --- a/ehr/resources/web/ehr/plugin/ClinicalObservationsCellEditing.js +++ b/ehr/resources/web/ehr/plugin/ClinicalObservationsCellEditing.js @@ -71,6 +71,9 @@ Ext4.define('EHR.grid.plugin.ClinicalObservationsCellEditing', { // Keep upward pointer correct for each use - editors are shared between locking sides editor.editingPlugin = me; + if (editor.field) + editor.field = EHR.DataEntryUtils.ensureLookupPlugin(editor.field, true); + return editor; } }); \ No newline at end of file