Skip to content
Merged
18 changes: 18 additions & 0 deletions ehr/resources/web/ehr/DataEntryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
};
10 changes: 10 additions & 0 deletions ehr/resources/web/ehr/grid/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Ext4.define('EHR.grid.Panel', {
this.dataEntryPanel.updateMinWidth(this.minWidth);
}

this.addComboEditorPlugin(this.columns);

},

pendingChanges: {},
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});