Skip to content

Commit 3cd656f

Browse files
committed
Case insensitive animal history search
1 parent 6f792f6 commit 3cd656f

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

LDK/resources/web/LDK/panel/SingleSubjectFilterType.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ Ext4.define('LDK.panel.SingleSubjectFilterType', {
155155

156156
aliasTableConfig: function (subjectArray) {
157157
this.aliasTable.scope = this;
158-
this.aliasTable.filterArray = [LABKEY.Filter.create('alias', subjectArray.join(';'), LABKEY.Filter.Types.EQUALS_ONE_OF)];
158+
159+
// Use contains filter to ensure case insensitivity across dbs
160+
var filterType = this.caseInsensitive ? LABKEY.Filter.Types.CONTAINS_ONE_OF : LABKEY.Filter.Types.EQUALS_ONE_OF;
161+
this.aliasTable.filterArray = [LABKEY.Filter.create('alias', subjectArray.join(';'), filterType)];
159162
this.aliasTable.columns = this.aliasTable.idColumn + (Ext4.isDefined(this.aliasTable.aliasColumn) ? ',' + this.aliasTable.aliasColumn : '');
160163
},
161164

@@ -179,14 +182,28 @@ Ext4.define('LDK.panel.SingleSubjectFilterType', {
179182

180183
// Remove from notFound array if found
181184
var subjIndex = this.notFound.indexOf(row[this.aliasTable.aliasColumn]);
182-
if (subjIndex != -1) {
185+
if (subjIndex === -1 && this.caseInsensitive) {
186+
subjIndex = this.notFound.findIndex(nf => {
187+
return row[this.aliasTable.aliasColumn].toLowerCase() === nf.toLowerCase()
188+
});
189+
}
190+
191+
if (subjIndex !== -1) {
183192
this.notFound.splice(subjIndex, 1);
193+
if (this.caseInsensitive) // Ensure case mismatch corrected
194+
this.subjects.splice(subjIndex, 1, row[this.aliasTable.aliasColumn]);
184195
}
185196

186197
// Resolve aliases
187-
if (row[this.aliasTable.idColumn] != row[this.aliasTable.aliasColumn]) {
198+
if (row[this.aliasTable.idColumn] !== row[this.aliasTable.aliasColumn]) {
188199
var index = this.subjects.indexOf(row[this.aliasTable.aliasColumn]);
189-
if (index != -1) {
200+
if (index === -1 && this.caseInsensitive) {
201+
index = this.subjects.findIndex(subj => {
202+
return row[this.aliasTable.aliasColumn].toLowerCase() === subj.toLowerCase()
203+
});
204+
}
205+
206+
if (index !== -1) {
190207
this.aliases[row[this.aliasTable.aliasColumn]] = [row[this.aliasTable.idColumn]];
191208
this.subjects.splice(index, 1, row[this.aliasTable.idColumn]);
192209
}
@@ -205,6 +222,11 @@ Ext4.define('LDK.panel.SingleSubjectFilterType', {
205222
else {
206223
// Remove from notFound array if found
207224
var idIndex = this.notFound.indexOf(row[this.aliasTable.idColumn]);
225+
if (idIndex === -1 && this.caseInsensitive) {
226+
idIndex = this.notFound.findIndex(nf => {
227+
return row[this.aliasTable.idColumn].toLowerCase() == nf.toLowerCase()
228+
});
229+
}
208230

209231
// TODO: Update this and LDK.Utils.splitIds when the case sensitive cache issues are fixed
210232
if (idIndex == -1) {

0 commit comments

Comments
 (0)