@@ -189,10 +189,60 @@ 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+ if ( hasAlias ) {
201+ var rowAlias = row [ this . aliasTable . aliasColumn ] ;
202+
203+ var aliasIndex = this . subjects . indexOf ( rowAlias ) ;
204+ if ( aliasIndex === - 1 ) {
205+ for ( var i = 0 ; i < this . subjects . length ; i ++ ) {
206+ if ( rowAlias . toLowerCase ( ) === this . subjects [ i ] . toString ( ) . toLowerCase ( ) ) {
207+ aliasIndex = i ;
208+ break ;
209+ }
210+ }
211+ }
212+
213+ if ( aliasIndex !== - 1 ) {
214+ updatedResults . push ( row ) ;
215+ }
216+ }
217+ else {
218+ var rowId = row [ this . aliasTable . idColumn ] ;
219+
220+ var rowIndex = this . subjects . indexOf ( rowId ) ;
221+ if ( rowIndex === - 1 ) {
222+ for ( var i = 0 ; i < this . subjects . length ; i ++ ) {
223+ if ( rowId . toLowerCase ( ) === this . subjects [ i ] . toString ( ) . toLowerCase ( ) ) {
224+ rowIndex = i ;
225+ break ;
226+ }
227+ }
228+ }
229+
230+ if ( rowIndex !== - 1 ) {
231+ updatedResults . push ( row ) ;
232+ }
233+ }
234+ } , this )
235+ return updatedResults ;
236+ } ,
237+
238+
192239 handleAliasResults : function ( results ) {
193240 this . notFound = Ext4 . clone ( this . subjects ) ;
241+
242+ var rows = this . caseInsensitive ? this . getCaseInsensitiveMatches ( results ) : results . rows ;
194243 var updatedSubjects = [ ] ;
195- Ext4 . each ( results . rows , function ( row ) {
244+
245+ Ext4 . each ( rows , function ( row ) {
196246
197247 var rowId = row [ this . aliasTable . idColumn ] ;
198248 updatedSubjects . push ( rowId ) ;
@@ -216,16 +266,6 @@ Ext4.define('LDK.panel.SingleSubjectFilterType', {
216266 this . notFound . splice ( subjIndex , 1 ) ;
217267 }
218268
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-
229269 // Resolve aliases
230270 if ( rowId !== rowAlias ) {
231271
0 commit comments