Skip to content

Commit 455baec

Browse files
Merge 22.7 to develop
2 parents 93ca3cb + df0b6f2 commit 455baec

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

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

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,41 @@ Ext4.define('LDK.panel.SingleSubjectFilterType', {
189189
LABKEY.Query.selectRows(this.aliasTable);
190190
},
191191

192+
// This looks for rows that match subjects case insensitively. This is called due to the filter in the case insensitive
193+
// case being "contains" instead of "equals" to get all possible casings. This also gets Ids that just contain the
194+
// subject id as a substring. Thus we need this to filter out the non-matching rows.
195+
getCaseInsensitiveMatches: function(results) {
196+
var hasAlias = !!this.aliasTable.aliasColumn;
197+
var updatedResults = [];
198+
199+
Ext4.each(results.rows, function (row) {
200+
var rowValue = hasAlias ? row[this.aliasTable.aliasColumn] : row[this.aliasTable.idColumn];
201+
var index = this.subjects.indexOf(rowValue);
202+
203+
if (index === -1) {
204+
for (var i = 0; i < this.subjects.length; i++) {
205+
if (rowValue.toLowerCase() === this.subjects[i].toString().toLowerCase()) {
206+
index = i;
207+
break;
208+
}
209+
}
210+
}
211+
212+
if (index !== -1) {
213+
updatedResults.push(row);
214+
}
215+
}, this)
216+
return updatedResults;
217+
},
218+
219+
192220
handleAliasResults: function (results) {
193221
this.notFound = Ext4.clone(this.subjects);
222+
223+
var rows = this.caseInsensitive ? this.getCaseInsensitiveMatches(results) : results.rows;
194224
var updatedSubjects = [];
195-
Ext4.each(results.rows, function (row) {
225+
226+
Ext4.each(rows, function (row) {
196227

197228
var rowId = row[this.aliasTable.idColumn];
198229
updatedSubjects.push(rowId);
@@ -216,16 +247,6 @@ Ext4.define('LDK.panel.SingleSubjectFilterType', {
216247
this.notFound.splice(subjIndex, 1);
217248
}
218249

219-
var index = this.subjects.indexOf(rowAlias);
220-
if (index === -1 && this.caseInsensitive) {
221-
for (var i = 0; i < this.subjects.length; i++) {
222-
if (rowAlias.toLowerCase() === this.subjects[i].toString().toLowerCase()) {
223-
index = i;
224-
break;
225-
}
226-
}
227-
}
228-
229250
// Resolve aliases
230251
if (rowId !== rowAlias) {
231252

0 commit comments

Comments
 (0)