@@ -2,7 +2,7 @@ import { ISPService, ILibsOptions, LibsOrderBy, IFieldsOptions, FieldsOrderBy }
22import { ISPField , ISPList , ISPLists , IUploadImageResult } from "../common/SPEntities" ;
33import { BaseComponentContext } from '@microsoft/sp-component-base' ;
44import { SPHttpClient , ISPHttpClientOptions } from "@microsoft/sp-http" ;
5- import { urlCombine } from "../common/utilities" ;
5+ import { SPHelper , urlCombine } from "../common/utilities" ;
66import filter from 'lodash/filter' ;
77import find from 'lodash/find' ;
88
@@ -170,7 +170,7 @@ export default class SPService implements ISPService {
170170 let isPost = false ;
171171 let processItems : ( ( items : any [ ] ) => any [ ] ) | undefined ;
172172
173- if ( field && field . TypeAsString === 'Calculated' && this . _isTextFieldType ( field . ResultType ) ) { // for calculated fields we need to use CAML query
173+ if ( field && field . TypeAsString === 'Calculated' && SPHelper . isTextFieldType ( field . ResultType ) ) { // for calculated fields we need to use CAML query
174174 let orderByStr = '' ;
175175
176176 if ( orderBy ) {
@@ -187,7 +187,7 @@ export default class SPService implements ISPService {
187187 apiUrl = `${ webAbsoluteUrl } /_api/web/lists('${ listId } ')/GetItems(query=@v1)?$select=${ keyInternalColumnName || 'Id' } ,${ internalColumnName } &@v1=${ JSON . stringify ( { ViewXml : camlQuery } ) } ` ;
188188 isPost = true ;
189189 }
190- else if ( this . _isTextFieldType ( field . TypeAsString ) ) {
190+ else if ( SPHelper . isTextFieldType ( field . TypeAsString ) ) {
191191 const filterStr = substringSearch ? // JJ - 20200613 - find by substring as an option
192192 `${ filterText ? `substringof('${ encodeURIComponent ( filterText . replace ( "'" , "''" ) ) } ',${ internalColumnName } )` : '' } ${ filterString ? ( filterText ? ' and ' : '' ) + filterString : '' } `
193193 : `${ filterText ? `startswith(${ internalColumnName } ,'${ encodeURIComponent ( filterText . replace ( "'" , "''" ) ) } ')` : '' } ${ filterString ? ( filterText ? ' and ' : '' ) + filterString : '' } ` ; //string = filterList ? `and ${filterList}` : '';
@@ -201,8 +201,8 @@ export default class SPService implements ISPService {
201201 return this . _filterListItemsFieldValuesAsText ( cachedItems . items , internalColumnName , filterText , substringSearch ) ;
202202 }
203203
204- apiUrl = `${ webAbsoluteUrl } /_api/web/lists('${ listId } ')/GetItems ?$select=${ keyInternalColumnName || 'Id' } ,FieldValuesAsText/${ internalColumnName } &$expand=FieldValuesAsText&$orderby=${ orderBy } ${ filterString ? '&$filter=' + filterString : '' } ` ;
205- isPost = true ;
204+ apiUrl = `${ webAbsoluteUrl } /_api/web/lists('${ listId } ')/items ?$select=${ keyInternalColumnName || 'Id' } , ${ internalColumnName } ,FieldValuesAsText/${ internalColumnName } &$expand=FieldValuesAsText&$orderby=${ orderBy } ${ filterString ? '&$filter=' + filterString : '' } ` ;
205+ isPost = false ;
206206
207207 processItems = ( items : any [ ] ) => {
208208
@@ -638,14 +638,6 @@ export default class SPService implements ISPService {
638638 return result ;
639639 }
640640
641- private _isTextFieldType ( fieldType ?: string ) : boolean {
642- if ( ! fieldType ) {
643- return true ;
644- }
645- const lowercasedFieldType = fieldType . toLowerCase ( ) ;
646- return lowercasedFieldType === 'text' || lowercasedFieldType === 'note' ;
647- }
648-
649641 private _filterListItemsFieldValuesAsText ( items : any [ ] , internalColumnName : string , filterText : string | undefined , substringSearch : boolean ) : any [ ] {
650642 const lowercasedFilterText = filterText . toLowerCase ( ) ;
651643
0 commit comments