Skip to content

Commit d75a640

Browse files
Broken lookups in EHR forms (#958)
* Use user editable lookup if there are broken lookups
1 parent 1901d97 commit d75a640

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

ehr/resources/web/ehr/DataEntryUtils.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,24 @@ EHR.DataEntryUtils = new function(){
11121112
}
11131113

11141114
return projectStore.getAt(recIdx).get('project');
1115+
},
1116+
1117+
ensureLookupPlugin(editor, initPlugin) {
1118+
const xtype = editor?.xtype;
1119+
if ((xtype === 'combo' || xtype === 'labkey-combo' || xtype === 'ehr-simplecombo')
1120+
&& !editor.plugins?.find(p => p.ptype === 'ldk-usereditablecombo')) {
1121+
1122+
const plugin = Ext4.create('LDK.plugin.UserEditableCombo', {
1123+
allowChooseOther: false,
1124+
});
1125+
editor.plugins = editor.plugins || [];
1126+
editor.plugins.push(plugin);
1127+
1128+
if (initPlugin)
1129+
plugin.init(editor);
1130+
}
1131+
1132+
return editor;
11151133
}
11161134
}
11171135
};

ehr/resources/web/ehr/grid/Panel.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Ext4.define('EHR.grid.Panel', {
8989
this.dataEntryPanel.updateMinWidth(this.minWidth);
9090
}
9191

92+
this.addComboEditorPlugin(this.columns);
93+
9294
},
9395

9496
pendingChanges: {},
@@ -107,6 +109,14 @@ Ext4.define('EHR.grid.Panel', {
107109
}
108110
},
109111

112+
addComboEditorPlugin: function(columns){
113+
Ext4.Array.forEach(columns, function(col){
114+
if (col.editor) {
115+
col.editor = EHR.DataEntryUtils.ensureLookupPlugin(col.editor, false);
116+
}
117+
}, this);
118+
},
119+
110120
resizeHeight: function(){
111121
// A bit of a hack but there are some cases where the gridview does not resize height to match its contents. Called
112122
// on store validation complete as this covers initial load and adding new rows scenario. Also done on cell edit

ehr/resources/web/ehr/plugin/ClinicalObservationsCellEditing.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Ext4.define('EHR.grid.plugin.ClinicalObservationsCellEditing', {
7171
// Keep upward pointer correct for each use - editors are shared between locking sides
7272
editor.editingPlugin = me;
7373

74+
if (editor.field)
75+
editor.field = EHR.DataEntryUtils.ensureLookupPlugin(editor.field, true);
76+
7477
return editor;
7578
}
7679
});

0 commit comments

Comments
 (0)